diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 22:29:56 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 22:29:56 +0000 |
commit | 9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d (patch) | |
tree | a67a3d0397a03e12ee51aa8720f612c62c20e936 /content/browser/renderer_host/render_widget_host.cc | |
parent | a3102766e725636ad23ad99faa1e8a481a1129e7 (diff) | |
download | chromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.zip chromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.tar.gz chromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.tar.bz2 |
gpu: reference target surfaces through a globally unique surface id.
This allows the gpu process to ignore all knowledge of renderers. It simplifies
some of the gpu <-> browser and gpu <-> renderer IPC, but mostly paves the way
for non-renderer clients.
Surfaces are kept in a global GpuSurfaceTracker which is just a thread-safe map.
BUG=99516
TEST=covered by existing tests. Run chrome, open poster circle (or other accelerated content page).
Review URL: http://codereview.chromium.org/9194005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118172 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/render_widget_host.cc')
-rw-r--r-- | content/browser/renderer_host/render_widget_host.cc | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 786aeef..38f8115 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -16,6 +16,7 @@ #include "content/browser/accessibility/browser_accessibility_state.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host_ui_shim.h" +#include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/backing_store_manager.h" #include "content/browser/renderer_host/render_process_host_impl.h" @@ -80,6 +81,7 @@ RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process, view_(NULL), process_(process), routing_id_(routing_id), + surface_id_(0), is_loading_(false), is_hidden_(false), is_accelerated_compositing_active_(false), @@ -101,8 +103,24 @@ RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process, suppress_next_char_events_(false), pending_mouse_lock_request_(false), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { - if (routing_id_ == MSG_ROUTING_NONE) + if (routing_id_ == MSG_ROUTING_NONE) { routing_id_ = process_->GetNextRoutingID(); + surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( + process_->GetID(), + routing_id_); + } else { + // TODO(piman): This is a O(N) lookup, where we could forward the + // information from the RenderWidgetHelper. The problem is that doing so + // currently leaks outside of content all the way to chrome classes, and + // would be a layering violation. Since we don't expect more than a few + // hundreds of RWH, this seems acceptable. Revisit if performance become a + // problem, for example by tracking in the RenderWidgetHelper the routing id + // (and surface id) that have been created, but whose RWH haven't yet. + surface_id_ = GpuSurfaceTracker::Get()->LookupSurfaceForRenderer( + process_->GetID(), + routing_id_); + DCHECK(surface_id_); + } process_->Attach(this, routing_id_); // Because the widget initializes as is_hidden_ == false, @@ -126,14 +144,19 @@ RenderWidgetHost::~RenderWidgetHost() { // Clear our current or cached backing store if either remains. BackingStoreManager::RemoveBackingStore(this); + GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); + surface_id_ = 0; + process_->Release(routing_id_); } void RenderWidgetHost::SetView(RenderWidgetHostView* view) { view_ = view; - if (!view_) - process_->SetCompositingSurface(routing_id_, gfx::kNullPluginWindow); + if (!view_) { + GpuSurfaceTracker::Get()->SetSurfaceHandle( + surface_id_, gfx::kNullPluginWindow); + } } gfx::NativeViewId RenderWidgetHost::GetNativeViewId() const { @@ -159,8 +182,8 @@ void RenderWidgetHost::Init() { renderer_initialized_ = true; - process_->SetCompositingSurface(routing_id_, - GetCompositingSurface()); + GpuSurfaceTracker::Get()->SetSurfaceHandle( + surface_id_, GetCompositingSurface()); // Send the ack along with the information on placement. Send(new ViewMsg_CreatingNew_ACK(routing_id_, GetNativeViewId())); |