diff options
66 files changed, 589 insertions, 525 deletions
diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc index 32c12ed..921b942 100644 --- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc +++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -59,7 +59,7 @@ class ThumbnailGeneratorTest : public testing::Test { ThumbnailGeneratorTest() { profile_.reset(new TestingProfile()); process_ = new MockRenderProcessHost(profile_.get()); - widget_.reset(new RenderWidgetHost(process_, 1)); + widget_.reset(new RenderWidgetHost(process_, MSG_ROUTING_NONE)); view_.reset(new TestRenderWidgetHostViewWithBackingStoreSkia( widget_.get())); // Paiting will be skipped if there's no view. diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index bd38b63..5125051 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -155,7 +155,8 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { } TabContentsWrapper* CreateTabContents() { - return Browser::TabContentsFactory(profile(), NULL, 0, NULL, NULL); + return Browser::TabContentsFactory( + profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); } TabContentsWrapper* CreateTabContentsWithSharedRPH( @@ -1454,7 +1455,7 @@ TEST_F(TabStripModelTest, AddTabContents_ForgetOpeners) { // Added for http://b/issue?id=958960 TEST_F(TabStripModelTest, AppendContentsReselectionTest) { WebContents* fake_destinations_tab = - WebContents::Create(profile(), NULL, 0, NULL, NULL); + WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); TabContentsWrapper wrapper(fake_destinations_tab); TabStripDummyDelegate delegate(&wrapper); TabStripModel tabstrip(&delegate, profile()); diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index a9b3c15..1b15780 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -403,21 +403,19 @@ void GpuProcessHost::EstablishGpuChannel( void GpuProcessHost::CreateViewCommandBuffer( gfx::PluginWindowHandle compositing_surface, - int32 render_view_id, - int32 client_id, + int surface_id, + int client_id, const GPUCreateCommandBufferConfig& init_params, const CreateCommandBufferCallback& callback) { DCHECK(CalledOnValidThread()); #if defined(TOOLKIT_USES_GTK) - ViewID view_id(client_id, render_view_id); - // There should only be one such command buffer (for the compositor). In // practice, if the GPU process lost a context, GraphicsContext3D with // associated command buffer and view surface will not be gone until new // one is in place and all layers are reattached. linked_ptr<SurfaceRef> surface_ref; - SurfaceRefMap::iterator it = surface_refs_.find(view_id); + SurfaceRefMap::iterator it = surface_refs_.find(surface_id); if (it != surface_refs_.end()) surface_ref = (*it).second; else @@ -426,11 +424,10 @@ void GpuProcessHost::CreateViewCommandBuffer( if (compositing_surface != gfx::kNullPluginWindow && Send(new GpuMsg_CreateViewCommandBuffer( - compositing_surface, render_view_id, client_id, init_params))) { + compositing_surface, surface_id, client_id, init_params))) { create_command_buffer_requests_.push(callback); #if defined(TOOLKIT_USES_GTK) - surface_refs_.insert(std::pair<ViewID, linked_ptr<SurfaceRef> >( - view_id, surface_ref)); + surface_refs_.insert(std::make_pair(surface_id, surface_ref)); #endif } else { CreateCommandBufferError(callback, MSG_ROUTING_NONE); @@ -478,12 +475,9 @@ void GpuProcessHost::OnCommandBufferCreated(const int32 route_id) { } } -void GpuProcessHost::OnDestroyCommandBuffer( - gfx::PluginWindowHandle window, int32 client_id, - int32 render_view_id) { +void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { #if defined(TOOLKIT_USES_GTK) - ViewID view_id(client_id, render_view_id); - SurfaceRefMap::iterator it = surface_refs_.find(view_id); + SurfaceRefMap::iterator it = surface_refs_.find(surface_id); if (it != surface_refs_.end()) surface_refs_.erase(it); #endif // defined(TOOLKIT_USES_GTK) diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 295803a..29ec0df 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -75,8 +75,8 @@ class GpuProcessHost : public BrowserChildProcessHost, // window associated with the given renderer. void CreateViewCommandBuffer( gfx::PluginWindowHandle compositing_surface, - int32 render_view_id, - int32 client_id, + int surface_id, + int client_id, const GPUCreateCommandBufferConfig& init_params, const CreateCommandBufferCallback& callback); @@ -100,8 +100,7 @@ class GpuProcessHost : public BrowserChildProcessHost, // Message handlers. void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); void OnCommandBufferCreated(const int32 route_id); - void OnDestroyCommandBuffer( - gfx::PluginWindowHandle window, int32 client_id, int32 render_view_id); + void OnDestroyCommandBuffer(int32 surface_id); bool LaunchGpuProcess(const std::string& channel_id); @@ -125,9 +124,6 @@ class GpuProcessHost : public BrowserChildProcessHost, std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; #if defined(TOOLKIT_USES_GTK) - typedef std::pair<int32 /* client_id */, - int32 /* render_view_id */> ViewID; - // Encapsulates surfaces that we lock when creating view command buffers. // We release this lock once the command buffer (or associated GPU process) // is destroyed. This prevents the browser from destroying the surface @@ -136,7 +132,7 @@ class GpuProcessHost : public BrowserChildProcessHost, // Multimap is used to simulate reference counting, see comment in // GpuProcessHostUIShim::CreateViewCommandBuffer. class SurfaceRef; - typedef std::multimap<ViewID, linked_ptr<SurfaceRef> > SurfaceRefMap; + typedef std::multimap<int, linked_ptr<SurfaceRef> > SurfaceRefMap; SurfaceRefMap surface_refs_; #endif diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index 488553d..7d26d66 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -13,6 +13,7 @@ #include "base/process_util.h" #include "content/browser/gpu/gpu_data_manager.h" #include "content/browser/gpu/gpu_process_host.h" +#include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" @@ -73,8 +74,13 @@ class ScopedSendOnIOThread { bool cancelled_; }; -RenderWidgetHostView* GetRenderWidgetHostViewFromID(int render_process_id, - int render_widget_id) { +RenderWidgetHostView* GetRenderWidgetHostViewFromSurfaceID(int surface_id) { + int render_process_id = 0; + int render_widget_id = 0; + if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( + surface_id, &render_process_id, &render_widget_id)) + return NULL; + content::RenderProcessHost* process = content::RenderProcessHost::FromID(render_process_id); if (!process) @@ -226,8 +232,7 @@ void GpuProcessHostUIShim::OnGraphicsInfoCollected( #if defined(TOOLKIT_USES_GTK) || defined(OS_WIN) -void GpuProcessHostUIShim::OnResizeView(int32 client_id, - int32 render_view_id, +void GpuProcessHostUIShim::OnResizeView(int32 surface_id, int32 route_id, gfx::Size size) { // Always respond even if the window no longer exists. The GPU process cannot @@ -237,8 +242,7 @@ void GpuProcessHostUIShim::OnResizeView(int32 client_id, host_id_, new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromID(client_id, - render_view_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID(surface_id); if (!view) return; @@ -278,16 +282,16 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( host_id_, new AcceleratedSurfaceMsg_NewACK( params.route_id, - params.surface_id, + params.surface_handle, TransportDIB::DefaultHandleValue())); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( - params.client_id, params.render_view_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + params.surface_id); if (!view) return; - uint64 surface_id = params.surface_id; - TransportDIB::Handle surface_handle = TransportDIB::DefaultHandleValue(); + uint64 surface_handle = params.surface_handle; + TransportDIB::Handle shm_handle = TransportDIB::DefaultHandleValue(); #if defined(OS_MACOSX) if (params.create_transport_dib) { @@ -305,7 +309,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( local_handle); // Create a remote handle for the GPU process to map the SHM. if (!shared_memory->ShareToProcess(0 /* pid, not needed */, - &surface_handle)) { + &shm_handle)) { return; } } @@ -314,15 +318,15 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( view->AcceleratedSurfaceSetIOSurface(params.window, params.width, params.height, - surface_id); + surface_handle); } #else // defined(UI_COMPOSITOR_IMAGE_TRANSPORT) view->AcceleratedSurfaceNew( - params.width, params.height, &surface_id, &surface_handle); + params.width, params.height, &surface_handle, &shm_handle); #endif delayed_send.Cancel(); Send(new AcceleratedSurfaceMsg_NewACK( - params.route_id, surface_id, surface_handle)); + params.route_id, surface_handle, shm_handle)); } #endif @@ -336,8 +340,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( host_id_, new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( - params.client_id, params.render_view_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + params.surface_id); if (!view) return; @@ -356,8 +360,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( host_id_, new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); - RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( - params.client_id, params.render_view_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + params.surface_id); if (!view) return; @@ -371,8 +375,8 @@ void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { - RenderWidgetHostView* view = GetRenderWidgetHostViewFromID( - params.client_id, params.render_view_id); + RenderWidgetHostView* view = GetRenderWidgetHostViewFromSurfaceID( + params.surface_id); if (!view) return; view->AcceleratedSurfaceRelease(params.identifier); diff --git a/content/browser/gpu/gpu_process_host_ui_shim.h b/content/browser/gpu/gpu_process_host_ui_shim.h index 119a802..8b5a5f8 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.h +++ b/content/browser/gpu/gpu_process_host_ui_shim.h @@ -83,8 +83,7 @@ class GpuProcessHostUIShim void OnLogMessage(int level, const std::string& header, const std::string& message); #if defined(TOOLKIT_USES_GTK) || defined(OS_WIN) - void OnResizeView(int32 client_id, - int32 render_view_id, + void OnResizeView(int32 surface_id, int32 route_id, gfx::Size size); #endif diff --git a/content/browser/gpu/gpu_surface_tracker.cc b/content/browser/gpu/gpu_surface_tracker.cc new file mode 100644 index 0000000..280f48f --- /dev/null +++ b/content/browser/gpu/gpu_surface_tracker.cc @@ -0,0 +1,75 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/gpu/gpu_surface_tracker.h" + +#include "base/logging.h" + +GpuSurfaceTracker::GpuSurfaceTracker() + : next_surface_id_(1) { +} + +GpuSurfaceTracker::~GpuSurfaceTracker() { +} + +GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { + return Singleton<GpuSurfaceTracker>::get(); +} + +int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id, + int render_widget_id) { + base::AutoLock lock(lock_); + SurfaceInfo info = { renderer_id, render_widget_id, gfx::kNullPluginWindow }; + int surface_id = next_surface_id_++; + surface_map_[surface_id] = info; + return surface_id; +} + +int GpuSurfaceTracker::LookupSurfaceForRenderer(int renderer_id, + int render_widget_id) { + base::AutoLock lock(lock_); + for (SurfaceMap::iterator it = surface_map_.begin(); it != surface_map_.end(); + ++it) { + const SurfaceInfo& info = it->second; + if (info.renderer_id == renderer_id && + info.render_widget_id == render_widget_id) { + return it->first; + } + } + return 0; +} + +void GpuSurfaceTracker::RemoveSurface(int surface_id) { + base::AutoLock lock(lock_); + DCHECK(surface_map_.find(surface_id) != surface_map_.end()); + surface_map_.erase(surface_id); +} + +bool GpuSurfaceTracker::GetRenderWidgetIDForSurface(int surface_id, + int* renderer_id, + int* render_widget_id) { + base::AutoLock lock(lock_); + SurfaceMap::iterator it = surface_map_.find(surface_id); + if (it == surface_map_.end()) + return false; + const SurfaceInfo& info = it->second; + *renderer_id = info.renderer_id; + *render_widget_id = info.render_widget_id; + return true; +} + +void GpuSurfaceTracker::SetSurfaceHandle(int surface_id, + gfx::PluginWindowHandle handle) { + base::AutoLock lock(lock_); + DCHECK(surface_map_.find(surface_id) != surface_map_.end()); + SurfaceInfo& info = surface_map_[surface_id]; + info.handle = handle; +} + +gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) { + base::AutoLock lock(lock_); + DCHECK(surface_map_.find(surface_id) != surface_map_.end()); + return surface_map_[surface_id].handle; +} + diff --git a/content/browser/gpu/gpu_surface_tracker.h b/content/browser/gpu/gpu_surface_tracker.h new file mode 100644 index 0000000..17fa13a --- /dev/null +++ b/content/browser/gpu/gpu_surface_tracker.h @@ -0,0 +1,81 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ +#define CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ + +#include <map> + +#include "base/basictypes.h" +#include "base/memory/singleton.h" +#include "base/synchronization/lock.h" +#include "ui/gfx/native_widget_types.h" + +// This class is responsible for managing rendering surfaces exposed to the +// GPU process. Every surface gets registered to this class, and gets an ID. +// All calls to and from the GPU process, with the exception of +// CreateViewCommandBuffer, refer to the rendering surface by its ID. +// This class is thread safe. +// +// Note: The ID can exist before the actual native handle for the surface is +// created, for example to allow giving a reference to it to a renderer, so that +// it is unamibiguously identified. +class GpuSurfaceTracker { + public: + // Gets the global instance of the surface tracker. + static GpuSurfaceTracker* Get() { return GetInstance(); } + + // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer + // process ID, |render_widget_id| is the RenderWidgetHost route id within that + // renderer. Returns the surface ID. + int AddSurfaceForRenderer(int renderer_id, int render_widget_id); + + // Looks up a surface for a given RenderWidgetHost. Returns the surface + // ID, or 0 if not found. + // Note: This is an O(N) lookup. + int LookupSurfaceForRenderer(int renderer_id, int render_widget_id); + + // Removes a given existing surface. + void RemoveSurface(int surface_id); + + // Gets the renderer process ID and RenderWidgetHost route id for a given + // surface, returning true if the surface is found (and corresponds to a + // RenderWidgetHost), or false if not. + bool GetRenderWidgetIDForSurface(int surface_id, + int* renderer_id, + int* render_widget_id); + + // Sets the native handle for the given surface. + // Note: This is an O(log N) lookup. + void SetSurfaceHandle(int surface_id, gfx::PluginWindowHandle handle); + + // Gets the native handle for the given surface. + // Note: This is an O(log N) lookup. + gfx::PluginWindowHandle GetSurfaceHandle(int surface_id); + + // Gets the global instance of the surface tracker. Identical to Get(), but + // named that way for the implementation of Singleton. + static GpuSurfaceTracker* GetInstance(); + + private: + struct SurfaceInfo { + int renderer_id; + int render_widget_id; + gfx::PluginWindowHandle handle; + }; + typedef std::map<int, SurfaceInfo> SurfaceMap; + + friend struct DefaultSingletonTraits<GpuSurfaceTracker>; + + GpuSurfaceTracker(); + ~GpuSurfaceTracker(); + + base::Lock lock_; + SurfaceMap surface_map_; + int next_surface_id_; + + DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); +}; + +#endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ diff --git a/content/browser/renderer_host/accelerated_surface_container_linux.h b/content/browser/renderer_host/accelerated_surface_container_linux.h index 1cb8ea1..3083fe3 100644 --- a/content/browser/renderer_host/accelerated_surface_container_linux.h +++ b/content/browser/renderer_host/accelerated_surface_container_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,9 +21,9 @@ class AcceleratedSurfaceContainerLinux { virtual void Release() = 0; // Initialize the surface container, and returns an ID for it. - // The |surface_id| given to this function may be modified, and the modified - // value should be used to identify the object. - virtual bool Initialize(uint64* surface_id) = 0; + // The |surface_handle| given to this function may be modified, and the + // modified value should be used to identify the object. + virtual bool Initialize(uint64* surface_handle) = 0; // Some implementations of this class use shared memory, this is the handle // to the shared buffer, which is part of the surface container. diff --git a/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc b/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc index 7c94582..e6936de 100644 --- a/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc +++ b/content/browser/renderer_host/accelerated_surface_container_linux_cc.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -37,7 +37,7 @@ class AcceleratedSurfaceContainerLinuxCC virtual void AddRef() { ui::TextureCC::AddRef(); } virtual void Release() { ui::TextureCC::Release(); } - virtual bool Initialize(uint64* surface_id) OVERRIDE { + virtual bool Initialize(uint64* surface_handle) OVERRIDE { ui::SharedResourcesCC* instance = ui::SharedResourcesCC::GetInstance(); DCHECK(instance); image_transport_client_.reset( @@ -45,7 +45,7 @@ class AcceleratedSurfaceContainerLinuxCC if (!image_transport_client_.get()) return false; - texture_id_ = image_transport_client_->Initialize(surface_id); + texture_id_ = image_transport_client_->Initialize(surface_handle); if (!texture_id_) { image_transport_client_.reset(); return false; diff --git a/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc b/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc index 4f773cd..78d1169 100644 --- a/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc +++ b/content/browser/renderer_host/accelerated_surface_container_linux_gl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,7 @@ class AcceleratedSurfaceContainerLinuxGL virtual void AddRef() { ui::TextureGL::AddRef(); } virtual void Release() { ui::TextureGL::Release(); } - virtual bool Initialize(uint64* surface_id) OVERRIDE { + virtual bool Initialize(uint64* surface_handle) OVERRIDE { ui::SharedResourcesGL* instance = ui::SharedResourcesGL::GetInstance(); DCHECK(instance); image_transport_client_.reset( @@ -31,7 +31,7 @@ class AcceleratedSurfaceContainerLinuxGL if (!image_transport_client_.get()) return false; - texture_id_ = image_transport_client_->Initialize(surface_id); + texture_id_ = image_transport_client_->Initialize(surface_handle); if (!texture_id_) { image_transport_client_.reset(); return false; diff --git a/content/browser/renderer_host/accelerated_surface_container_mac.cc b/content/browser/renderer_host/accelerated_surface_container_mac.cc index 86875f3..10b8292 100644 --- a/content/browser/renderer_host/accelerated_surface_container_mac.cc +++ b/content/browser/renderer_host/accelerated_surface_container_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,7 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( bool opaque) : manager_(manager), opaque_(opaque), - surface_id_(0), + surface_handle_(0), width_(0), height_(0), texture_(0), @@ -219,15 +219,15 @@ bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const { return visible_ && was_painted_to_ && !clip_rect_.IsEmpty(); } -void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) { - set_was_painted_to_common(surface_id); +void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_handle) { + set_was_painted_to_common(surface_handle); update_rect_ = gfx::Rect(); } void AcceleratedSurfaceContainerMac::set_was_painted_to( - uint64 surface_id, + uint64 surface_handle, const gfx::Rect& update_rect) { - set_was_painted_to_common(surface_id); + set_was_painted_to_common(surface_handle); update_rect_ = update_rect_.Union(update_rect); } @@ -240,18 +240,18 @@ void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { } void AcceleratedSurfaceContainerMac::set_was_painted_to_common( - uint64 surface_id) { - if (surface_id && (!surface_ || surface_id != surface_id_)) { + uint64 surface_handle) { + if (surface_handle && (!surface_ || surface_handle != surface_handle_)) { // Keep the surface that was most recently painted to around. if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) { CFTypeRef surface = io_surface_support->IOSurfaceLookup( - static_cast<uint32>(surface_id)); + static_cast<uint32>(surface_handle)); // Can fail if IOSurface with that ID was already released by the // gpu process or the plugin process. We will get a |set_was_painted_to()| // message with a new surface soon in that case. if (surface) { surface_.reset(surface); - surface_id_ = surface_id; + surface_handle_ = surface_handle; surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_); surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_); EnqueueTextureForDeletion(); diff --git a/content/browser/renderer_host/accelerated_surface_container_mac.h b/content/browser/renderer_host/accelerated_surface_container_mac.h index 1bbf730..fab05ce 100644 --- a/content/browser/renderer_host/accelerated_surface_container_mac.h +++ b/content/browser/renderer_host/accelerated_surface_container_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,8 +82,8 @@ class AcceleratedSurfaceContainerMac { bool ShouldBeVisible() const; // Notifies the the container that its surface was painted to. - void set_was_painted_to(uint64 surface_id); - void set_was_painted_to(uint64 surface_id, + void set_was_painted_to(uint64 surface_handle); + void set_was_painted_to(uint64 surface_handle, const gfx::Rect& update_rect); // Notifies the container that its surface is invalid. @@ -92,7 +92,7 @@ class AcceleratedSurfaceContainerMac { // Enqueue our texture for later deletion. void EnqueueTextureForDeletion(); - void set_was_painted_to_common(uint64 surface_id); + void set_was_painted_to_common(uint64 surface_handle); // The manager of this accelerated surface container. AcceleratedSurfaceContainerManagerMac* manager_; @@ -106,8 +106,8 @@ class AcceleratedSurfaceContainerMac { // IOSurfaceRef type when building on 10.5. base::mac::ScopedCFTypeRef<CFTypeRef> surface_; - // The id of |surface_|, or 0 if |surface_| is NULL. - uint64 surface_id_; + // The handle of |surface_|, or 0 if |surface_| is NULL. + uint64 surface_handle_; // The width and height of the io surface. During resizing, this is different // from |width_| and |height_|. diff --git a/content/browser/renderer_host/accelerated_surface_container_manager_mac.cc b/content/browser/renderer_host/accelerated_surface_container_manager_mac.cc index b31a483..eb2757c 100644 --- a/content/browser/renderer_host/accelerated_surface_container_manager_mac.cc +++ b/content/browser/renderer_host/accelerated_surface_container_manager_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -138,23 +138,23 @@ void AcceleratedSurfaceContainerManagerMac::ForceTextureReload() { } void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo( - gfx::PluginWindowHandle id, uint64 surface_id) { + gfx::PluginWindowHandle id, uint64 surface_handle) { base::AutoLock lock(lock_); AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); if (container) - container->set_was_painted_to(surface_id); + container->set_was_painted_to(surface_handle); } void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo( gfx::PluginWindowHandle id, - uint64 surface_id, + uint64 surface_handle, const gfx::Rect& update_rect) { base::AutoLock lock(lock_); AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); if (container) - container->set_was_painted_to(surface_id, update_rect); + container->set_was_painted_to(surface_handle, update_rect); } void AcceleratedSurfaceContainerManagerMac::SetRootSurfaceInvalid() { diff --git a/content/browser/renderer_host/accelerated_surface_container_manager_mac.h b/content/browser/renderer_host/accelerated_surface_container_manager_mac.h index d342971..a113053 100644 --- a/content/browser/renderer_host/accelerated_surface_container_manager_mac.h +++ b/content/browser/renderer_host/accelerated_surface_container_manager_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,9 +82,10 @@ class AcceleratedSurfaceContainerManagerMac { void ForceTextureReload(); // Notifies a surface that it has been painted to. - void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id, uint64 surface_id); void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id, - uint64 surface_id, + uint64 surface_handle); + void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id, + uint64 surface_handle, const gfx::Rect& update_rect); // Notifies the root container that its surface is invalid. diff --git a/content/browser/renderer_host/gpu_message_filter.cc b/content/browser/renderer_host/gpu_message_filter.cc index 0533829..14b3b50 100644 --- a/content/browser/renderer_host/gpu_message_filter.cc +++ b/content/browser/renderer_host/gpu_message_filter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "base/bind.h" #include "content/browser/gpu/gpu_process_host.h" +#include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/renderer_host/render_widget_helper.h" #include "content/common/gpu/gpu_messages.h" @@ -74,16 +75,26 @@ void GpuMessageFilter::OnEstablishGpuChannel( } void GpuMessageFilter::OnCreateViewCommandBuffer( - int32 render_view_id, + int32 surface_id, const GPUCreateCommandBufferConfig& init_params, IPC::Message* reply) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); + GpuSurfaceTracker* surface_tracker = GpuSurfaceTracker::Get(); + gfx::PluginWindowHandle compositing_surface = gfx::kNullPluginWindow; - gfx::PluginWindowHandle compositing_surface = - render_widget_helper_->LookupCompositingSurface(render_view_id); + int renderer_id = 0; + int render_widget_id = 0; + bool result = surface_tracker->GetRenderWidgetIDForSurface( + surface_id, &renderer_id, &render_widget_id); + if (result && renderer_id == render_process_id_) { + compositing_surface = surface_tracker->GetSurfaceHandle(surface_id); + } else { + DLOG(ERROR) << "Renderer " << render_process_id_ + << " tried to access a surface for renderer " << renderer_id; + } + GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); if (!host || compositing_surface == gfx::kNullPluginWindow) { // TODO(apatrick): Eventually, this IPC message will be routed to a // GpuProcessStub with a particular routing ID. The error will be set if @@ -95,7 +106,7 @@ void GpuMessageFilter::OnCreateViewCommandBuffer( host->CreateViewCommandBuffer( compositing_surface, - render_view_id, + surface_id, render_process_id_, init_params, base::Bind(&GpuMessageFilter::CreateCommandBufferCallback, diff --git a/content/browser/renderer_host/gpu_message_filter.h b/content/browser/renderer_host/gpu_message_filter.h index 7d5b91e..afd5b4e 100644 --- a/content/browser/renderer_host/gpu_message_filter.h +++ b/content/browser/renderer_host/gpu_message_filter.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -43,7 +43,7 @@ class GpuMessageFilter : public content::BrowserMessageFilter, void OnEstablishGpuChannel(content::CauseForGpuLaunch, IPC::Message* reply); void OnCreateViewCommandBuffer( - int32 render_view_id, + int32 surface_id, const GPUCreateCommandBufferConfig& init_params, IPC::Message* reply); // Helper callbacks for the message handlers. diff --git a/content/browser/renderer_host/image_transport_client.cc b/content/browser/renderer_host/image_transport_client.cc index 16439fb..bec2d71 100644 --- a/content/browser/renderer_host/image_transport_client.cc +++ b/content/browser/renderer_host/image_transport_client.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,11 +55,11 @@ class ImageTransportClientEGL : public ImageTransportClient { } } - virtual unsigned int Initialize(uint64* surface_id) { + virtual unsigned int Initialize(uint64* surface_handle) { scoped_ptr<gfx::ScopedMakeCurrent> bind(resources_->GetScopedMakeCurrent()); image_ = eglCreateImageKHR( gfx::GLSurfaceEGL::GetHardwareDisplay(), EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, reinterpret_cast<void*>(*surface_id), NULL); + EGL_NATIVE_PIXMAP_KHR, reinterpret_cast<void*>(*surface_handle), NULL); if (!image_) return 0; GLuint texture = CreateTexture(); @@ -100,7 +100,7 @@ class ImageTransportClientGLX : public ImageTransportClient { XFreePixmap(dpy, pixmap_); } - virtual unsigned int Initialize(uint64* surface_id) { + virtual unsigned int Initialize(uint64* surface_handle) { TRACE_EVENT0("renderer_host", "ImageTransportClientGLX::Initialize"); Display* dpy = static_cast<Display*>(resources_->GetDisplay()); @@ -112,7 +112,7 @@ class ImageTransportClientGLX : public ImageTransportClient { // We receive a window here rather than a pixmap directly because drivers // require (or required) that the pixmap used to create the GL texture be // created in the same process as the texture. - pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_id); + pixmap_ = XCompositeNameWindowPixmap(dpy, *surface_handle); const int pixmapAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, @@ -233,19 +233,20 @@ class ImageTransportClientOSMesa : public ImageTransportClient { virtual ~ImageTransportClientOSMesa() { } - virtual unsigned int Initialize(uint64* surface_id) { - // We expect to make the id here, so don't want the other end giving us one - DCHECK_EQ(*surface_id, static_cast<uint64>(0)); + virtual unsigned int Initialize(uint64* surface_handle) { + // We expect to make the handle here, so don't want the other end giving us + // one. + DCHECK_EQ(*surface_handle, static_cast<uint64>(0)); // It's possible that this ID gneration could clash with IDs from other // AcceleratedSurfaceContainerTouch* objects, however we should never have // ids active from more than one type at the same time, so we have free // reign of the id namespace. - *surface_id = next_id_++; + *surface_handle = next_handle_++; shared_mem_.reset( TransportDIB::Create(size_.GetArea() * 4, // GL_RGBA=4 B/px - *surface_id)); + *surface_handle)); if (!shared_mem_.get()) return 0; @@ -270,9 +271,9 @@ class ImageTransportClientOSMesa : public ImageTransportClient { gfx::Size size_; scoped_ptr<TransportDIB> shared_mem_; GLuint texture_; - static uint32 next_id_; + static uint32 next_handle_; }; -uint32 ImageTransportClientOSMesa::next_id_ = 0; +uint32 ImageTransportClientOSMesa::next_handle_ = 0; #endif // !USE_WAYLAND diff --git a/content/browser/renderer_host/image_transport_client.h b/content/browser/renderer_host/image_transport_client.h index afa5e8b..4981a31 100644 --- a/content/browser/renderer_host/image_transport_client.h +++ b/content/browser/renderer_host/image_transport_client.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,7 @@ class ImageTransportClient { // Initializes the client with the surface id. This returns the GL texture id, // or 0 if error. - virtual unsigned int Initialize(uint64* surface_id) = 0; + virtual unsigned int Initialize(uint64* surface_handle) = 0; // Gets the surface data into the texture. virtual void Acquire() = 0; diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc index 989414e..2eafb5f 100644 --- a/content/browser/renderer_host/mock_render_process_host.cc +++ b/content/browser/renderer_host/mock_render_process_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -125,11 +125,6 @@ TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { return transport_dib_; } -void MockRenderProcessHost::SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) { -} - int MockRenderProcessHost::GetID() const { return id_; } diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h index 4a41c43..183af21 100644 --- a/content/browser/renderer_host/mock_render_process_host.h +++ b/content/browser/renderer_host/mock_render_process_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,9 +49,6 @@ class MockRenderProcessHost : public content::RenderProcessHost { virtual void DumpHandles() OVERRIDE; virtual base::ProcessHandle GetHandle() OVERRIDE; virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; - virtual void SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) OVERRIDE; virtual int GetID() const OVERRIDE; virtual bool HasConnection() const OVERRIDE; virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 612e793..6429524 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -397,11 +397,14 @@ bool RenderMessageFilter::OffTheRecord() const { void RenderMessageFilter::OnMsgCreateWindow( const ViewHostMsg_CreateWindow_Params& params, - int* route_id, int64* cloned_session_storage_namespace_id) { + int* route_id, + int* surface_id, + int64* cloned_session_storage_namespace_id) { if (!content::GetContentClient()->browser()->CanCreateWindow( GURL(params.opener_security_origin), params.window_container_type, resource_context_, render_process_id_)) { *route_id = MSG_ROUTING_NONE; + *surface_id = 0; return; } @@ -410,18 +413,23 @@ void RenderMessageFilter::OnMsgCreateWindow( params.session_storage_namespace_id); render_widget_helper_->CreateNewWindow(params, peer_handle(), - route_id); + route_id, + surface_id); } void RenderMessageFilter::OnMsgCreateWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id) { - render_widget_helper_->CreateNewWidget(opener_id, popup_type, route_id); + int* route_id, + int* surface_id) { + render_widget_helper_->CreateNewWidget( + opener_id, popup_type, route_id, surface_id); } void RenderMessageFilter::OnMsgCreateFullscreenWidget(int opener_id, - int* route_id) { - render_widget_helper_->CreateNewFullscreenWidget(opener_id, route_id); + int* route_id, + int* surface_id) { + render_widget_helper_->CreateNewFullscreenWidget( + opener_id, route_id, surface_id); } void RenderMessageFilter::OnSetCookie(const IPC::Message& message, diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index 319e9b9..f0519fd 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -101,11 +101,15 @@ class RenderMessageFilter : public content::BrowserMessageFilter { void OnMsgCreateWindow(const ViewHostMsg_CreateWindow_Params& params, int* route_id, + int* surface_id, int64* cloned_session_storage_namespace_id); void OnMsgCreateWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id); - void OnMsgCreateFullscreenWidget(int opener_id, int* route_id); + int* route_id, + int* surface_id); + void OnMsgCreateFullscreenWidget(int opener_id, + int* route_id, + int* surface_id); void OnSetCookie(const IPC::Message& message, const GURL& url, const GURL& first_party_for_cookies, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index fc18b2e..60a5a0d 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -833,12 +833,6 @@ void RenderProcessHostImpl::ClearTransportDIBCache() { cached_dibs_.clear(); } -void RenderProcessHostImpl::SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) { - widget_helper_->SetCompositingSurface(render_widget_id, compositing_surface); -} - bool RenderProcessHostImpl::Send(IPC::Message* msg) { if (!channel_.get()) { if (!is_initialized_) { diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index d700aa3..10f4372 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,9 +68,6 @@ class CONTENT_EXPORT RenderProcessHostImpl virtual void DumpHandles() OVERRIDE; virtual base::ProcessHandle GetHandle() OVERRIDE; virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; - virtual void SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) OVERRIDE; virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; virtual int GetID() const OVERRIDE; virtual bool HasConnection() const OVERRIDE; diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index b0082c2..1badf4a 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -19,6 +19,7 @@ #include "base/values.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/cross_site_request_manager.h" +#include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/host_zoom_map.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/power_save_blocker.h" @@ -177,8 +178,8 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name, renderer_initialized_ = true; - process()->SetCompositingSurface(routing_id(), - GetCompositingSurface()); + GpuSurfaceTracker::Get()->SetSurfaceHandle( + surface_id(), GetCompositingSurface()); // Ensure the RenderView starts with a next_page_id larger than any existing // page ID it might be asked to render. @@ -192,6 +193,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name, delegate_->GetRendererPrefs(process()->GetBrowserContext()); params.web_preferences = delegate_->GetWebkitPrefs(); params.view_id = routing_id(); + params.surface_id = surface_id(); params.session_storage_namespace_id = session_storage_namespace_->id(); params.frame_name = frame_name; params.next_page_id = next_page_id; diff --git a/content/browser/renderer_host/render_widget_helper.cc b/content/browser/renderer_host/render_widget_helper.cc index 4803956..2124af5 100644 --- a/content/browser/renderer_host/render_widget_helper.cc +++ b/content/browser/renderer_host/render_widget_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "base/bind_helpers.h" #include "base/eintr_wrapper.h" #include "base/threading/thread.h" +#include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -212,8 +213,11 @@ void RenderWidgetHelper::OnCrossSiteSwapOutACK( void RenderWidgetHelper::CreateNewWindow( const ViewHostMsg_CreateWindow_Params& params, base::ProcessHandle render_process, - int* route_id) { + int* route_id, + int* surface_id) { *route_id = GetNextRoutingID(); + *surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( + render_process_id_, *route_id); // Block resource requests until the view is created, since the HWND might be // needed if a response ends up creating a plugin. resource_dispatcher_host_->BlockRequestsForRoute( @@ -221,8 +225,8 @@ void RenderWidgetHelper::CreateNewWindow( BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( - &RenderWidgetHelper::OnCreateWindowOnUI, this, params, *route_id)); + base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, + this, params, *route_id)); } void RenderWidgetHelper::OnCreateWindowOnUI( @@ -245,8 +249,11 @@ void RenderWidgetHelper::OnCreateWindowOnIO(int route_id) { void RenderWidgetHelper::CreateNewWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id) { + int* route_id, + int* surface_id) { *route_id = GetNextRoutingID(); + *surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( + render_process_id_, *route_id); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( @@ -255,8 +262,11 @@ void RenderWidgetHelper::CreateNewWidget(int opener_id, } void RenderWidgetHelper::CreateNewFullscreenWidget(int opener_id, - int* route_id) { + int* route_id, + int* surface_id) { *route_id = GetNextRoutingID(); + *surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( + render_process_id_, *route_id); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( @@ -334,24 +344,3 @@ void RenderWidgetHelper::ClearAllocatedDIBs() { allocated_dibs_.clear(); } #endif - -void RenderWidgetHelper::SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) { - base::AutoLock locked(view_compositing_surface_map_lock_); - if (compositing_surface != gfx::kNullPluginWindow) - view_compositing_surface_map_[render_widget_id] = compositing_surface; - else - view_compositing_surface_map_.erase(render_widget_id); -} - -gfx::PluginWindowHandle RenderWidgetHelper::LookupCompositingSurface( - int render_widget_id) { - base::AutoLock locked(view_compositing_surface_map_lock_); - ViewCompositingSurfaceMap::iterator it = - view_compositing_surface_map_.find(render_widget_id); - if (it == view_compositing_surface_map_.end()) - return gfx::kNullPluginWindow; - - return it->second; -} diff --git a/content/browser/renderer_host/render_widget_helper.h b/content/browser/renderer_host/render_widget_helper.h index 766566a..f53e445 100644 --- a/content/browser/renderer_host/render_widget_helper.h +++ b/content/browser/renderer_host/render_widget_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -119,11 +119,6 @@ class RenderWidgetHelper TransportDIB* MapTransportDIB(TransportDIB::Id dib_id); #endif - // Set a mapping from a RenderWidgetHost to a compositing surface. Pass a null - // handle to remove the mapping. - void SetCompositingSurface(int render_widget_id, - gfx::PluginWindowHandle compositing_surface); - // IO THREAD ONLY ----------------------------------------------------------- // Called on the IO thread when a UpdateRect message is received. @@ -131,11 +126,13 @@ class RenderWidgetHelper void CreateNewWindow(const ViewHostMsg_CreateWindow_Params& params, base::ProcessHandle render_process, - int* route_id); + int* route_id, + int* surface_id); void CreateNewWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id); - void CreateNewFullscreenWidget(int opener_id, int* route_id); + int* route_id, + int* surface_id); + void CreateNewFullscreenWidget(int opener_id, int* route_id, int* surface_id); #if defined(OS_MACOSX) // Called on the IO thread to handle the allocation of a TransportDIB. If @@ -151,9 +148,6 @@ class RenderWidgetHelper void FreeTransportDIB(TransportDIB::Id dib_id); #endif - // Lookup the compositing surface corresponding to a widget ID. - gfx::PluginWindowHandle LookupCompositingSurface(int render_widget_id); - private: // A class used to proxy a paint message. PaintMsgProxy objects are created // on the IO thread and destroyed on the UI thread. @@ -210,11 +204,6 @@ class RenderWidgetHelper UpdateMsgProxyMap pending_paints_; base::Lock pending_paints_lock_; - // Maps from view ID to compositing surface. - typedef std::map<int, gfx::PluginWindowHandle> ViewCompositingSurfaceMap; - ViewCompositingSurfaceMap view_compositing_surface_map_; - base::Lock view_compositing_surface_map_lock_; - int render_process_id_; // Event used to implement WaitForUpdateMsg. 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())); diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 422beda..3bb7e30 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -160,6 +160,7 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, content::RenderProcessHost* process() const { return process_; } int routing_id() const { return routing_id_; } + int surface_id() const { return surface_id_; } bool renderer_accessible() { return renderer_accessible_; } bool empty() const { return current_size_.IsEmpty(); } @@ -654,6 +655,9 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, // The ID of the corresponding object in the Renderer Instance. int routing_id_; + // The ID of the surface corresponding to this render widget. + int surface_id_; + // Indicates whether a page is loading or not. bool is_loading_; diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index 1b9a894..9feb70e 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -261,7 +261,7 @@ class RenderWidgetHostTest : public testing::Test { void SetUp() { browser_context_.reset(new TestBrowserContext()); process_ = new RenderWidgetHostProcess(browser_context_.get()); - host_.reset(new MockRenderWidgetHost(process_, 1)); + host_.reset(new MockRenderWidgetHost(process_, MSG_ROUTING_NONE)); view_.reset(new TestView(host_.get())); host_->SetView(view_.get()); host_->Init(); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 26bd057..9c3750c 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -346,7 +346,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) { #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) - current_surface_ = params.surface_id; + current_surface_ = params.surface_handle; UpdateExternalTexture(); if (!window_->layer()->GetCompositor()) { @@ -355,7 +355,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); } else { gfx::Size surface_size = - accelerated_surface_containers_[params.surface_id]->GetSize(); + accelerated_surface_containers_[params.surface_handle]->GetSize(); window_->SchedulePaintInRect(gfx::Rect(surface_size)); // Add sending an ACK to the list of things to do OnCompositingEnded @@ -375,7 +375,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, int gpu_host_id) { #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) - current_surface_ = params.surface_id; + current_surface_ = params.surface_handle; UpdateExternalTexture(); if (!window_->layer()->GetCompositor()) { @@ -384,7 +384,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); } else { gfx::Size surface_size = - accelerated_surface_containers_[params.surface_id]->GetSize(); + accelerated_surface_containers_[params.surface_handle]->GetSize(); // Co-ordinates come in OpenGL co-ordinate space. // We need to convert to layer space. @@ -411,28 +411,29 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( void RenderWidgetHostViewAura::AcceleratedSurfaceNew( int32 width, int32 height, - uint64* surface_id, - TransportDIB::Handle* surface_handle) { + uint64* surface_handle, + TransportDIB::Handle* shm_handle) { scoped_refptr<AcceleratedSurfaceContainerLinux> surface( AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); - if (!surface->Initialize(surface_id)) { + if (!surface->Initialize(surface_handle)) { LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; return; } - *surface_handle = surface->Handle(); + *shm_handle = surface->Handle(); - accelerated_surface_containers_[*surface_id] = surface; + accelerated_surface_containers_[*surface_handle] = surface; } -void RenderWidgetHostViewAura::AcceleratedSurfaceRelease(uint64 surface_id) { - if (current_surface_ == surface_id) { +void RenderWidgetHostViewAura::AcceleratedSurfaceRelease( + uint64 surface_handle) { + if (current_surface_ == surface_handle) { current_surface_ = gfx::kNullPluginWindow; // Don't call UpdateExternalTexture: it's possible that a new surface with // the same ID will be re-created right away, in which case we don't want to // flip back and forth. Instead wait until we got the accelerated // compositing deactivation. } - accelerated_surface_containers_.erase(surface_id); + accelerated_surface_containers_.erase(surface_handle); } #endif diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 071ed59..1e9585f 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -884,7 +884,7 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( last_frame_was_accelerated_ = (params.window == plugin_container_manager_.root_container_handle()); plugin_container_manager_.SetSurfaceWasPaintedTo(params.window, - params.surface_id); + params.surface_handle); // The surface is hidden until its first paint, to not show garbage. if (plugin_container_manager_.SurfaceShouldBeVisible(params.window)) @@ -910,7 +910,7 @@ void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( plugin_container_manager_.root_container_handle()); plugin_container_manager_.SetSurfaceWasPaintedTo( params.window, - params.surface_id, + params.surface_handle, gfx::Rect(params.x, params.y, params.width, params.height)); // The surface is hidden until its first paint, to not show garbage. diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 7fcbe3a..87866b2 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -2082,7 +2082,7 @@ void RenderWidgetHostViewWin::OnAcceleratedCompositingStateChange() { void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) { - if (params.surface_id) { + if (params.surface_handle) { if (!accelerated_surface_.get() && compositor_host_window_) { accelerated_surface_.reset(new AcceleratedSurface); } @@ -2097,7 +2097,7 @@ void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( accelerated_surface_->AsyncPresentAndAcknowledge( compositor_host_window_, params.size, - params.surface_id, + params.surface_handle, base::Bind(PostTaskOnIOThread, FROM_HERE, acknowledge_task)); diff --git a/content/browser/renderer_host/text_input_client_mac_unittest.mm b/content/browser/renderer_host/text_input_client_mac_unittest.mm index c306acd..7de8a09 100644 --- a/content/browser/renderer_host/text_input_client_mac_unittest.mm +++ b/content/browser/renderer_host/text_input_client_mac_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -30,7 +30,8 @@ class TextInputClientMacTest : public testing::Test { : message_loop_(MessageLoop::TYPE_UI), browser_context_(), process_factory_(), - widget_(process_factory_.CreateRenderProcessHost(&browser_context_), 1), + widget_(process_factory_.CreateRenderProcessHost(&browser_context_), + MSG_ROUTING_NONE), thread_("TextInputClientMacTestThread") {} // Accessor for the TextInputClientMac instance. diff --git a/content/browser/tab_contents/tab_contents_delegate_unittest.cc b/content/browser/tab_contents/tab_contents_delegate_unittest.cc index 421270f..b2183f48 100644 --- a/content/browser/tab_contents/tab_contents_delegate_unittest.cc +++ b/content/browser/tab_contents/tab_contents_delegate_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,9 +22,9 @@ TEST(WebContentsDelegateTest, UnregisterInDestructor) { TestBrowserContext browser_context; scoped_ptr<TabContents> contents_a( - new TabContents(&browser_context, NULL, 0, NULL, NULL)); + new TabContents(&browser_context, NULL, MSG_ROUTING_NONE, NULL, NULL)); scoped_ptr<TabContents> contents_b( - new TabContents(&browser_context, NULL, 0, NULL, NULL)); + new TabContents(&browser_context, NULL, MSG_ROUTING_NONE, NULL, NULL)); EXPECT_TRUE(contents_a->GetDelegate() == NULL); EXPECT_TRUE(contents_b->GetDelegate() == NULL); diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index 69b2aca..b9d4e05 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -177,7 +177,7 @@ void GpuChannel::OnDestroy() { void GpuChannel::CreateViewCommandBuffer( gfx::PluginWindowHandle window, - int32 render_view_id, + int32 surface_id, const GPUCreateCommandBufferConfig& init_params, int32* route_id) { *route_id = MSG_ROUTING_NONE; @@ -199,8 +199,7 @@ void GpuChannel::CreateViewCommandBuffer( init_params.attribs, init_params.gpu_preference, *route_id, - client_id_, - render_view_id, + surface_id, watchdog_, software_)); router_.AddRoute(*route_id, stub.get()); @@ -329,7 +328,7 @@ void GpuChannel::OnCreateOffscreenCommandBuffer( init_params.attribs, init_params.gpu_preference, route_id, - 0, 0, watchdog_, + 0, watchdog_, software_)); router_.AddRoute(route_id, stub.get()); stubs_.AddWithID(stub.release(), route_id); diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index 1e7ab78..7fc6baf 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -84,7 +84,7 @@ class GpuChannel : public IPC::Channel::Listener, void CreateViewCommandBuffer( gfx::PluginWindowHandle window, - int32 render_view_id, + int32 surface_id, const GPUCreateCommandBufferConfig& init_params, int32* route_id); diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index 880d741..9c12d1a 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -116,16 +116,16 @@ void GpuChannelManager::OnCloseChannel( void GpuChannelManager::OnCreateViewCommandBuffer( gfx::PluginWindowHandle window, - int32 render_view_id, + int32 surface_id, int32 client_id, const GPUCreateCommandBufferConfig& init_params) { - DCHECK(render_view_id); + DCHECK(surface_id); int32 route_id = MSG_ROUTING_NONE; GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); if (iter != gpu_channels_.end()) { iter->second->CreateViewCommandBuffer( - window, render_view_id, init_params, &route_id); + window, surface_id, init_params, &route_id); } Send(new GpuHostMsg_CommandBufferCreated(route_id)); diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 7df674c..ff485a7 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -30,8 +30,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( const std::vector<int32>& attribs, gfx::GpuPreference gpu_preference, int32 route_id, - int32 client_id, - int32 render_view_id, + int32 surface_id, GpuWatchdog* watchdog, bool software) : channel_(channel), @@ -44,8 +43,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( route_id_(route_id), software_(software), last_flush_count_(0), - client_id_(client_id), - render_view_id_(render_view_id), + surface_id_(surface_id), parent_stub_for_initialization_(), parent_texture_for_initialization_(0), watchdog_(watchdog) { @@ -62,8 +60,7 @@ GpuCommandBufferStub::~GpuCommandBufferStub() { Destroy(); GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); - gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer( - handle_, client_id_, render_view_id_)); + gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id_)); } bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { @@ -195,9 +192,7 @@ void GpuCommandBufferStub::OnInitialize( surface_ = ImageTransportSurface::CreateSurface( channel_->gpu_channel_manager(), - render_view_id_, - client_id_, - route_id_, + this, handle_); } else { surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_, diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 8796181..8f4e84a 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -49,8 +49,7 @@ class GpuCommandBufferStub const std::vector<int32>& attribs, gfx::GpuPreference gpu_preference, int32 route_id, - int32 client_id, - int32 render_view_id, + int32 surface_id, GpuWatchdog* watchdog, bool software); @@ -74,11 +73,8 @@ class GpuCommandBufferStub gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } - // Identifies the renderer process. - int32 client_id() const { return client_id_; } - - // Identifies a particular renderer belonging to the same renderer process. - int32 render_view_id() const { return render_view_id_; } + // Identifies the target surface. + int32 surface_id() const { return surface_id_; } // Identifies the various GpuCommandBufferStubs in the GPU process belonging // to the same renderer process. @@ -146,10 +142,8 @@ class GpuCommandBufferStub bool software_; uint32 last_flush_count_; - // The following two fields are used on Mac OS X to identify the window - // for the rendering results on the browser side. - int32 client_id_; - int32 render_view_id_; + // Identifies the window for the rendering results on the browser side. + int32 surface_id_; scoped_ptr<gpu::CommandBufferService> command_buffer_; scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index d41f9c3..f41437b 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -34,11 +34,10 @@ IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceNew_Params) - IPC_STRUCT_MEMBER(int32, client_id) - IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(int32, surface_id) IPC_STRUCT_MEMBER(int32, width) IPC_STRUCT_MEMBER(int32, height) - IPC_STRUCT_MEMBER(uint64, surface_id) + IPC_STRUCT_MEMBER(uint64, surface_handle) IPC_STRUCT_MEMBER(int32, route_id) #if defined(OS_MACOSX) IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) @@ -47,9 +46,8 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceNew_Params) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) - IPC_STRUCT_MEMBER(int32, client_id) - IPC_STRUCT_MEMBER(int32, render_view_id) - IPC_STRUCT_MEMBER(uint64, surface_id) + IPC_STRUCT_MEMBER(int32, surface_id) + IPC_STRUCT_MEMBER(uint64, surface_handle) IPC_STRUCT_MEMBER(int32, route_id) #if defined(OS_WIN) IPC_STRUCT_MEMBER(gfx::Size, size) @@ -59,9 +57,8 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params) - IPC_STRUCT_MEMBER(int32, client_id) - IPC_STRUCT_MEMBER(int32, render_view_id) - IPC_STRUCT_MEMBER(uint64, surface_id) + IPC_STRUCT_MEMBER(int32, surface_id) + IPC_STRUCT_MEMBER(uint64, surface_handle) IPC_STRUCT_MEMBER(int32, route_id) IPC_STRUCT_MEMBER(int, x) IPC_STRUCT_MEMBER(int, y) @@ -73,8 +70,7 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params) - IPC_STRUCT_MEMBER(int32, client_id) - IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(int32, surface_id) IPC_STRUCT_MEMBER(uint64, identifier) IPC_STRUCT_MEMBER(int32, route_id) #if defined(OS_MACOSX) @@ -148,7 +144,7 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, // to a native view. A corresponding GpuCommandBufferStub is created. IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer, gfx::PluginWindowHandle, /* compositing_surface */ - int32, /* render_view_id */ + int32, /* surface_id */ int32, /* client_id */ GPUCreateCommandBufferConfig /* init_params */) @@ -162,7 +158,7 @@ IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_ResizeViewACK) // Tells the GPU process that it's safe to start rendering to the surface. IPC_MESSAGE_ROUTED2(AcceleratedSurfaceMsg_NewACK, - uint64 /* surface_id */, + uint64 /* surface_handle */, TransportDIB::Handle /* shared memory buffer */) // Tells the GPU process that the browser process handled the swap @@ -198,7 +194,7 @@ IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel, // A renderer sends this to the browser process when it wants to // create a GL context associated with the given view_id. IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_CreateViewCommandBuffer, - int32, /* render_view_id */ + int32, /* surface_id */ GPUCreateCommandBufferConfig, /* init_params */ int32 /* route_id */) @@ -212,10 +208,8 @@ IPC_MESSAGE_CONTROL1(GpuHostMsg_CommandBufferCreated, // Request from GPU to free the browser resources associated with the // command buffer. -IPC_MESSAGE_CONTROL3(GpuHostMsg_DestroyCommandBuffer, - gfx::PluginWindowHandle, /* view */ - int32, /* render_view_id */ - int32 /* client_id */) +IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyCommandBuffer, + int32 /* surface_id */) // Response from GPU to a GpuMsg_CollectGraphicsInfo. IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected, @@ -229,9 +223,8 @@ IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage, // Resize the window that is being drawn into. It's important that this // resize be synchronized with the swapping of the front and back buffers. -IPC_MESSAGE_CONTROL4(GpuHostMsg_ResizeView, - int32 /* client_id */, - int32 /* render_view_id */, +IPC_MESSAGE_CONTROL3(GpuHostMsg_ResizeView, + int32 /* surface_id */, int32 /* route_id */, gfx::Size /* size */) diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc index 12b05e5..ff85e90 100644 --- a/content/common/gpu/image_transport_surface.cc +++ b/content/common/gpu/image_transport_surface.cc @@ -22,15 +22,11 @@ ImageTransportSurface::~ImageTransportSurface() { ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) : surface_(surface), manager_(manager), - render_view_id_(render_view_id), - client_id_(client_id), - command_buffer_id_(command_buffer_id), + stub_(stub->AsWeakPtr()), handle_(handle) { route_id_ = manager_->GenerateRouteID(); manager_->AddRoute(route_id_, this); @@ -72,16 +68,14 @@ bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) { void ImageTransportHelper::SendAcceleratedSurfaceRelease( GpuHostMsg_AcceleratedSurfaceRelease_Params params) { - params.client_id = client_id_; - params.render_view_id = render_view_id_; + params.surface_id = stub_->surface_id(); params.route_id = route_id_; manager_->Send(new GpuHostMsg_AcceleratedSurfaceRelease(params)); } void ImageTransportHelper::SendAcceleratedSurfaceNew( GpuHostMsg_AcceleratedSurfaceNew_Params params) { - params.client_id = client_id_; - params.render_view_id = render_view_id_; + params.surface_id = stub_->surface_id(); params.route_id = route_id_; #if defined(OS_MACOSX) params.window = handle_; @@ -91,8 +85,7 @@ void ImageTransportHelper::SendAcceleratedSurfaceNew( void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) { - params.client_id = client_id_; - params.render_view_id = render_view_id_; + params.surface_id = stub_->surface_id(); params.route_id = route_id_; #if defined(OS_MACOSX) params.window = handle_; @@ -102,8 +95,7 @@ void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( void ImageTransportHelper::SendAcceleratedSurfacePostSubBuffer( GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params) { - params.client_id = client_id_; - params.render_view_id = render_view_id_; + params.surface_id = stub_->surface_id(); params.route_id = route_id_; #if defined(OS_MACOSX) params.window = handle_; @@ -112,8 +104,7 @@ void ImageTransportHelper::SendAcceleratedSurfacePostSubBuffer( } void ImageTransportHelper::SendResizeView(const gfx::Size& size) { - manager_->Send(new GpuHostMsg_ResizeView(client_id_, - render_view_id_, + manager_->Send(new GpuHostMsg_ResizeView(stub_->surface_id(), route_id_, size)); } @@ -142,9 +133,9 @@ void ImageTransportHelper::OnPostSubBufferACK() { } void ImageTransportHelper::OnNewSurfaceACK( - uint64 surface_id, + uint64 surface_handle, TransportDIB::Handle shm_handle) { - surface_->OnNewSurfaceACK(surface_id, shm_handle); + surface_->OnNewSurfaceACK(surface_handle, shm_handle); } void ImageTransportHelper::OnResizeViewACK() { @@ -169,16 +160,9 @@ void ImageTransportHelper::Resize(gfx::Size size) { } void ImageTransportHelper::SetSwapInterval() { - GpuChannel* channel = manager_->LookupChannel(client_id_); - if (!channel) + if (!stub_.get()) return; - - GpuCommandBufferStub* stub = - channel->LookupCommandBuffer(command_buffer_id_); - if (!stub) - return; - - stub->SetSwapInterval(); + stub_->SetSwapInterval(); } bool ImageTransportHelper::MakeCurrent() { @@ -189,42 +173,24 @@ bool ImageTransportHelper::MakeCurrent() { } gpu::GpuScheduler* ImageTransportHelper::Scheduler() { - GpuChannel* channel = manager_->LookupChannel(client_id_); - if (!channel) - return NULL; - - GpuCommandBufferStub* stub = - channel->LookupCommandBuffer(command_buffer_id_); - if (!stub) + if (!stub_.get()) return NULL; - - return stub->scheduler(); + return stub_->scheduler(); } gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() { - GpuChannel* channel = manager_->LookupChannel(client_id_); - if (!channel) - return NULL; - - GpuCommandBufferStub* stub = - channel->LookupCommandBuffer(command_buffer_id_); - if (!stub) + if (!stub_.get()) return NULL; - - return stub->decoder(); + return stub_->decoder(); } PassThroughImageTransportSurface::PassThroughImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::GLSurface* surface) : GLSurfaceAdapter(surface) { helper_.reset(new ImageTransportHelper(this, manager, - render_view_id, - client_id, - command_buffer_id, + stub, gfx::kNullPluginWindow)); } @@ -242,7 +208,7 @@ void PassThroughImageTransportSurface::Destroy() { } void PassThroughImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) { + uint64 surface_handle, TransportDIB::Handle shm_handle) { } bool PassThroughImageTransportSurface::SwapBuffers() { @@ -251,7 +217,7 @@ bool PassThroughImageTransportSurface::SwapBuffers() { // Round trip to the browser UI thread, for throttling, by sending a dummy // SwapBuffers message. GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = 0; + params.surface_handle = 0; #if defined(OS_WIN) params.size = GetSize(); #endif @@ -268,7 +234,7 @@ bool PassThroughImageTransportSurface::PostSubBuffer( // Round trip to the browser UI thread, for throttling, by sending a dummy // PostSubBuffer message. GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; - params.surface_id = 0; + params.surface_handle = 0; params.x = x; params.y = y; params.width = width; diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h index 8801ba2..107a530 100644 --- a/content/common/gpu/image_transport_surface.h +++ b/content/common/gpu/image_transport_surface.h @@ -12,6 +12,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_message.h" #include "ui/gfx/gl/gl_surface.h" @@ -20,6 +21,7 @@ #include "ui/gfx/surface/transport_dib.h" class GpuChannelManager; +class GpuCommandBufferStub; struct GpuHostMsg_AcceleratedSurfaceNew_Params; struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; @@ -66,9 +68,7 @@ class ImageTransportSurface { // Creates the appropriate surface depending on the GL implementation. static scoped_refptr<gfx::GLSurface> CreateSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle); private: DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface); @@ -79,9 +79,7 @@ class ImageTransportHelper : public IPC::Channel::Listener { // Takes weak pointers to objects that outlive the helper. ImageTransportHelper(ImageTransportSurface* surface, GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle); virtual ~ImageTransportHelper(); @@ -116,7 +114,7 @@ class ImageTransportHelper : public IPC::Channel::Listener { gpu::gles2::GLES2Decoder* Decoder(); // IPC::Message handlers. - void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle surface_handle); + void OnNewSurfaceACK(uint64 surface_handle, TransportDIB::Handle shm_handle); void OnBuffersSwappedACK(); void OnPostSubBufferACK(); void OnResizeViewACK(); @@ -131,9 +129,7 @@ class ImageTransportHelper : public IPC::Channel::Listener { ImageTransportSurface* surface_; GpuChannelManager* manager_; - int32 render_view_id_; - int32 client_id_; - int32 command_buffer_id_; + base::WeakPtr<GpuCommandBufferStub> stub_; int32 route_id_; gfx::PluginWindowHandle handle_; @@ -147,9 +143,7 @@ class PassThroughImageTransportSurface public ImageTransportSurface { public: PassThroughImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::GLSurface* surface); virtual ~PassThroughImageTransportSurface(); @@ -161,7 +155,7 @@ class PassThroughImageTransportSurface // ImageTransportSurface implementation. virtual void OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; + uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; virtual void OnResizeViewACK() OVERRIDE; diff --git a/content/common/gpu/image_transport_surface_linux.cc b/content/common/gpu/image_transport_surface_linux.cc index 405de37..6d95ff2 100644 --- a/content/common/gpu/image_transport_surface_linux.cc +++ b/content/common/gpu/image_transport_surface_linux.cc @@ -61,9 +61,7 @@ class EGLImageTransportSurface public base::SupportsWeakPtr<EGLImageTransportSurface> { public: EGLImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id); + GpuCommandBufferStub* stub); // gfx::GLSurface implementation virtual bool Initialize() OVERRIDE; @@ -80,7 +78,7 @@ class EGLImageTransportSurface protected: // ImageTransportSurface implementation virtual void OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; + uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; virtual void OnResizeViewACK() OVERRIDE; @@ -112,9 +110,7 @@ class GLXImageTransportSurface public base::SupportsWeakPtr<GLXImageTransportSurface> { public: GLXImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id); + GpuCommandBufferStub* stub); // gfx::GLSurface implementation: virtual bool Initialize() OVERRIDE; @@ -129,7 +125,7 @@ class GLXImageTransportSurface protected: // ImageTransportSurface implementation: virtual void OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; + uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; virtual void OnResizeViewACK() OVERRIDE; @@ -168,9 +164,7 @@ class OSMesaImageTransportSurface : public ImageTransportSurface, public gfx::GLSurfaceOSMesa { public: OSMesaImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id); + GpuCommandBufferStub* stub); // gfx::GLSurface implementation: virtual bool Initialize() OVERRIDE; @@ -184,7 +178,7 @@ class OSMesaImageTransportSurface : public ImageTransportSurface, protected: // ImageTransportSurface implementation: virtual void OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; + uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; virtual void OnResizeViewACK() OVERRIDE; @@ -244,17 +238,13 @@ EGLAcceleratedSurface::~EGLAcceleratedSurface() { EGLImageTransportSurface::EGLImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id) - : gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)), - fbo_id_(0), - made_current_(false) { + GpuCommandBufferStub* stub) + : gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)), + fbo_id_(0), + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, - render_view_id, - client_id, - command_buffer_id, + stub, gfx::kNullPluginWindow)); } @@ -353,7 +343,7 @@ void EGLImageTransportSurface::OnResize(gfx::Size size) { GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size.width(); params.height = size.height(); - params.surface_id = back_surface_->pixmap(); + params.surface_handle = back_surface_->pixmap(); helper_->SendAcceleratedSurfaceNew(params); helper_->SetScheduled(false); @@ -381,7 +371,7 @@ bool EGLImageTransportSurface::SwapBuffers() { void EGLImageTransportSurface::SendBuffersSwapped() { GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = front_surface_->pixmap(); + params.surface_handle = front_surface_->pixmap(); helper_->SendAcceleratedSurfaceBuffersSwapped(params); helper_->SetScheduled(false); } @@ -404,8 +394,8 @@ gfx::Size EGLImageTransportSurface::GetSize() { } void EGLImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { - DCHECK_EQ(back_surface_->pixmap(), surface_id); + uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { + DCHECK_EQ(back_surface_->pixmap(), surface_handle); helper_->SetScheduled(true); } @@ -423,20 +413,16 @@ void EGLImageTransportSurface::OnResizeViewACK() { GLXImageTransportSurface::GLXImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id) - : gfx::NativeViewGLSurfaceGLX(), - dummy_parent_(0), - size_(1, 1), - bound_(false), - needs_resize_(false), - made_current_(false) { + GpuCommandBufferStub* stub) + : gfx::NativeViewGLSurfaceGLX(), + dummy_parent_(0), + size_(1, 1), + bound_(false), + needs_resize_(false), + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, - render_view_id, - client_id, - command_buffer_id, + stub, gfx::kNullPluginWindow)); } @@ -546,7 +532,7 @@ bool GLXImageTransportSurface::SwapBuffers() { GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size_.width(); params.height = size_.height(); - params.surface_id = window_; + params.surface_handle = window_; helper_->SendAcceleratedSurfaceNew(params); bound_ = true; needs_resize_ = false; @@ -556,7 +542,7 @@ bool GLXImageTransportSurface::SwapBuffers() { void GLXImageTransportSurface::SendBuffersSwapped() { GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = window_; + params.surface_handle = window_; helper_->SendAcceleratedSurfaceBuffersSwapped(params); helper_->SetScheduled(false); } @@ -572,7 +558,7 @@ bool GLXImageTransportSurface::PostSubBuffer( GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size_.width(); params.height = size_.height(); - params.surface_id = window_; + params.surface_handle = window_; helper_->SendAcceleratedSurfaceNew(params); bound_ = true; needs_resize_ = false; @@ -583,7 +569,7 @@ bool GLXImageTransportSurface::PostSubBuffer( void GLXImageTransportSurface::SendPostSubBuffer( int x, int y, int width, int height) { GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; - params.surface_id = window_; + params.surface_handle = window_; params.x = x; params.y = y; params.width = width; @@ -627,7 +613,7 @@ bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { } void GLXImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { + uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { } void GLXImageTransportSurface::OnBuffersSwappedACK() { @@ -644,16 +630,12 @@ void GLXImageTransportSurface::OnResizeViewACK() { OSMesaImageTransportSurface::OSMesaImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id) - : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), - size_(gfx::Size(1, 1)) { + GpuCommandBufferStub* stub) + : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), + size_(gfx::Size(1, 1)) { helper_.reset(new ImageTransportHelper(this, manager, - render_view_id, - client_id, - command_buffer_id, + stub, gfx::kNullPluginWindow)); } @@ -705,16 +687,16 @@ void OSMesaImageTransportSurface::OnResize(gfx::Size size) { GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size_.width(); params.height = size_.height(); - params.surface_id = 0; // id comes from the browser with the shared mem + params.surface_handle = 0; // id comes from the browser with the shared mem helper_->SendAcceleratedSurfaceNew(params); helper_->SetScheduled(false); } void OSMesaImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) { - shared_id_ = surface_id; - shared_mem_.reset(TransportDIB::Map(surface_handle)); + uint64 surface_handle, TransportDIB::Handle shm_handle) { + shared_id_ = surface_handle; + shared_mem_.reset(TransportDIB::Map(shm_handle)); DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); helper_->SetScheduled(true); @@ -732,7 +714,7 @@ bool OSMesaImageTransportSurface::SwapBuffers() { memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = shared_id_; + params.surface_handle = shared_id_; helper_->SendAcceleratedSurfaceBuffersSwapped(params); helper_->SetScheduled(false); @@ -757,7 +739,7 @@ bool OSMesaImageTransportSurface::PostSubBuffer( } GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; - params.surface_id = shared_id_; + params.surface_handle = shared_id_; params.x = x; params.y = y; params.width = width; @@ -793,30 +775,19 @@ gfx::Size OSMesaImageTransportSurface::GetSize() { // static scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) { scoped_refptr<gfx::GLSurface> surface; #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) switch (gfx::GetGLImplementation()) { case gfx::kGLImplementationDesktopGL: - surface = new GLXImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id); + surface = new GLXImageTransportSurface(manager, stub); break; case gfx::kGLImplementationEGLGLES2: - surface = new EGLImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id); + surface = new EGLImageTransportSurface(manager, stub); break; case gfx::kGLImplementationOSMesaGL: - surface = new OSMesaImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id); + surface = new OSMesaImageTransportSurface(manager, stub); break; default: NOTREACHED(); @@ -827,11 +798,7 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( if (!surface.get()) return NULL; - surface = new PassThroughImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id, - surface.get()); + surface = new PassThroughImageTransportSurface(manager, stub, surface.get()); #endif if (surface->Initialize()) return surface; diff --git a/content/common/gpu/image_transport_surface_mac.cc b/content/common/gpu/image_transport_surface_mac.cc index 47662db..3e1eb6c 100644 --- a/content/common/gpu/image_transport_surface_mac.cc +++ b/content/common/gpu/image_transport_surface_mac.cc @@ -24,9 +24,7 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, public ImageTransportSurface { public: IOSurfaceImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle); // GLSurface implementation @@ -42,7 +40,7 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, protected: // ImageTransportSurface implementation - virtual void OnNewSurfaceACK(uint64 surface_id, + virtual void OnNewSurfaceACK(uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; @@ -58,7 +56,7 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; // The id of |io_surface_| or 0 if that's NULL. - uint64 io_surface_id_; + uint64 io_surface_handle_; // Weak pointer to the context that this was last made current to. gfx::GLContext* context_; @@ -79,9 +77,7 @@ class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, public ImageTransportSurface { public: TransportDIBImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle); // GLSurface implementation @@ -99,7 +95,7 @@ class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, // ImageTransportSurface implementation virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; - virtual void OnNewSurfaceACK(uint64 surface_id, + virtual void OnNewSurfaceACK(uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; @@ -114,7 +110,7 @@ class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, gfx::Size size_; - static uint32 next_id_; + static uint32 next_handle_; // Whether or not we've successfully made the surface current once. bool made_current_; @@ -124,7 +120,7 @@ class TransportDIBImageTransportSurface : public gfx::NoOpGLSurfaceCGL, DISALLOW_COPY_AND_ASSIGN(TransportDIBImageTransportSurface); }; -uint32 TransportDIBImageTransportSurface::next_id_ = 1; +uint32 TransportDIBImageTransportSurface::next_handle_ = 1; void AddBooleanValue(CFMutableDictionaryRef dictionary, const CFStringRef key, @@ -143,23 +139,15 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary, IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) - : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), - fbo_id_(0), - texture_id_(0), - io_surface_id_(0), - context_(NULL), - made_current_(false) { - helper_.reset(new ImageTransportHelper(this, - manager, - render_view_id, - client_id, - command_buffer_id, - handle)); - + : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), + fbo_id_(0), + texture_id_(0), + io_surface_handle_(0), + context_(NULL), + made_current_(false) { + helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); } IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { @@ -226,7 +214,7 @@ bool IOSurfaceImageTransportSurface::SwapBuffers() { glFlush(); GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = io_surface_id_; + params.surface_handle = io_surface_handle_; helper_->SendAcceleratedSurfaceBuffersSwapped(params); helper_->SetScheduled(false); @@ -238,7 +226,7 @@ bool IOSurfaceImageTransportSurface::PostSubBuffer( glFlush(); GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; - params.surface_id = io_surface_id_; + params.surface_handle = io_surface_handle_; params.x = x; params.y = y; params.width = width; @@ -270,9 +258,9 @@ void IOSurfaceImageTransportSurface::OnPostSubBufferACK() { } void IOSurfaceImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, + uint64 surface_handle, TransportDIB::Handle /* shm_handle */) { - DCHECK_EQ(io_surface_id_, surface_id); + DCHECK_EQ(io_surface_handle_, surface_handle); helper_->SetScheduled(true); } @@ -353,7 +341,7 @@ void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { io_surface_.get(), plane); - io_surface_id_ = io_surface_support->IOSurfaceGetID(io_surface_); + io_surface_handle_ = io_surface_support->IOSurfaceGetID(io_surface_); glFlush(); glBindTexture(target, previous_texture_id); @@ -362,7 +350,7 @@ void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size_.width(); params.height = size_.height(); - params.surface_id = io_surface_id_; + params.surface_handle = io_surface_handle_; params.create_transport_dib = false; helper_->SendAcceleratedSurfaceNew(params); @@ -371,20 +359,13 @@ void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { TransportDIBImageTransportSurface::TransportDIBImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) : gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), fbo_id_(0), render_buffer_id_(0), made_current_(false) { - helper_.reset(new ImageTransportHelper(this, - manager, - render_view_id, - client_id, - command_buffer_id, - handle)); + helper_.reset(new ImageTransportHelper(this, manager, stub, handle)); } @@ -460,7 +441,7 @@ bool TransportDIBImageTransportSurface::SwapBuffers() { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = next_id_; + params.surface_handle = next_handle_; helper_->SendAcceleratedSurfaceBuffersSwapped(params); helper_->SetScheduled(false); @@ -497,7 +478,7 @@ bool TransportDIBImageTransportSurface::PostSubBuffer( glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, previous_fbo_id); GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; - params.surface_id = next_id_; + params.surface_handle = next_handle_; params.x = x; params.y = y; params.width = width; @@ -529,7 +510,7 @@ void TransportDIBImageTransportSurface::OnPostSubBufferACK() { } void TransportDIBImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, + uint64 surface_handle, TransportDIB::Handle shm_handle) { helper_->SetScheduled(true); @@ -570,7 +551,7 @@ void TransportDIBImageTransportSurface::OnResize(gfx::Size size) { GpuHostMsg_AcceleratedSurfaceNew_Params params; params.width = size_.width(); params.height = size_.height(); - params.surface_id = next_id_++; + params.surface_handle = next_handle_++; params.create_transport_dib = true; helper_->SendAcceleratedSurfaceNew(params); @@ -582,9 +563,7 @@ void TransportDIBImageTransportSurface::OnResize(gfx::Size size) { // static scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) { scoped_refptr<gfx::GLSurface> surface; IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); @@ -593,17 +572,9 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( case gfx::kGLImplementationDesktopGL: case gfx::kGLImplementationAppleGL: if (!io_surface_support) { - surface = new TransportDIBImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id, - handle); + surface = new TransportDIBImageTransportSurface(manager, stub, handle); } else { - surface = new IOSurfaceImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id, - handle); + surface = new IOSurfaceImageTransportSurface(manager, stub, handle); } break; default: diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc index cd5c8b7..9a8e549 100644 --- a/content/common/gpu/image_transport_surface_win.cc +++ b/content/common/gpu/image_transport_surface_win.cc @@ -31,9 +31,7 @@ class PbufferImageTransportSurface public base::SupportsWeakPtr<PbufferImageTransportSurface> { public: PbufferImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id); + GpuCommandBufferStub* stub); // gfx::GLSurface implementation virtual bool Initialize() OVERRIDE; @@ -46,7 +44,7 @@ class PbufferImageTransportSurface protected: // ImageTransportSurface implementation - virtual void OnNewSurfaceACK(uint64 surface_id, + virtual void OnNewSurfaceACK(uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnPostSubBufferACK() OVERRIDE; @@ -70,17 +68,12 @@ class PbufferImageTransportSurface PbufferImageTransportSurface::PbufferImageTransportSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id) - : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, - gfx::Size(1, 1))), - is_visible_(true) { + GpuCommandBufferStub* stub) + : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), + is_visible_(true) { helper_.reset(new ImageTransportHelper(this, manager, - render_view_id, - client_id, - command_buffer_id, + stub, gfx::kNullPluginWindow)); } @@ -149,7 +142,7 @@ std::string PbufferImageTransportSurface::GetExtensions() { void PbufferImageTransportSurface::SendBuffersSwapped() { GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = reinterpret_cast<int64>(GetShareHandle()); + params.surface_handle = reinterpret_cast<int64>(GetShareHandle()); params.size = GetSize(); helper_->SendAcceleratedSurfaceBuffersSwapped(params); @@ -165,7 +158,7 @@ void PbufferImageTransportSurface::OnPostSubBufferACK() { } void PbufferImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, + uint64 surface_handle, TransportDIB::Handle shm_handle) { NOTREACHED(); } @@ -186,9 +179,7 @@ void PbufferImageTransportSurface::OnResize(gfx::Size size) { // static scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( GpuChannelManager* manager, - int32 render_view_id, - int32 client_id, - int32 command_buffer_id, + GpuCommandBufferStub* stub, gfx::PluginWindowHandle handle) { scoped_refptr<gfx::GLSurface> surface; @@ -199,10 +190,7 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( EGL_EXTENSIONS); if (strstr(extensions, "EGL_ANGLE_query_surface_pointer") && strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) { - surface = new PbufferImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id); + surface = new PbufferImageTransportSurface(manager, stub); } } @@ -212,9 +200,7 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( return NULL; surface = new PassThroughImageTransportSurface(manager, - render_view_id, - client_id, - command_buffer_id, + stub, surface.get()); } diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 576a2ae..b523077 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -639,6 +639,9 @@ IPC_STRUCT_BEGIN(ViewMsg_New_Params) // The ID of the view to be created. IPC_STRUCT_MEMBER(int32, view_id) + // The ID of the rendering surface. + IPC_STRUCT_MEMBER(int32, surface_id) + // The session storage namespace ID this view should use. IPC_STRUCT_MEMBER(int64, session_storage_namespace_id) @@ -1191,24 +1194,27 @@ IPC_MESSAGE_CONTROL1(ViewMsg_TempCrashWithData, // Sent by the renderer when it is creating a new window. The browser creates // a tab for it and responds with a ViewMsg_CreatingNew_ACK. If route_id is // MSG_ROUTING_NONE, the view couldn't be created. -IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_CreateWindow, +IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_CreateWindow, ViewHostMsg_CreateWindow_Params, int /* route_id */, + int32 /* surface_id */, int64 /* cloned_session_storage_namespace_id */) // Similar to ViewHostMsg_CreateWindow, except used for sub-widgets, like // <select> dropdowns. This message is sent to the TabContents that // contains the widget being created. -IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateWidget, +IPC_SYNC_MESSAGE_CONTROL2_2(ViewHostMsg_CreateWidget, int /* opener_id */, WebKit::WebPopupType /* popup type */, - int /* route_id */) + int /* route_id */, + int32 /* surface_id */) // Similar to ViewHostMsg_CreateWidget except the widget is a full screen // window. -IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_CreateFullscreenWidget, +IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_CreateFullscreenWidget, int /* opener_id */, - int /* route_id */) + int /* route_id */, + int32 /* surface_id */) // Get all savable resource links from current webpage, include main // frame and sub-frame. diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 1232c4c..5d1956b 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -308,6 +308,8 @@ 'browser/gpu/gpu_process_host.h', 'browser/gpu/gpu_process_host_ui_shim.cc', 'browser/gpu/gpu_process_host_ui_shim.h', + 'browser/gpu/gpu_surface_tracker.cc', + 'browser/gpu/gpu_surface_tracker.h', 'browser/host_zoom_map.cc', 'browser/host_zoom_map.h', 'browser/in_process_webkit/browser_webkitplatformsupport_impl.cc', diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h index 68ed032..81a3636 100644 --- a/content/public/browser/render_process_host.h +++ b/content/public/browser/render_process_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -122,14 +122,6 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender, // still owns the returned DIB. virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) = 0; - // RenderWidgetHost / compositing surface mapping functions ------------------ - - // Set a mapping from a RenderWidgetHost to a compositing surface. Pass a null - // handle to remove the mapping. - virtual void SetCompositingSurface( - int render_widget_id, - gfx::PluginWindowHandle compositing_surface) = 0; - // Returns the user browser context associated with this renderer process. virtual content::BrowserContext* GetBrowserContext() const = 0; diff --git a/content/renderer/gpu/gpu_channel_host.cc b/content/renderer/gpu/gpu_channel_host.cc index 5bedc69..96c652b 100644 --- a/content/renderer/gpu/gpu_channel_host.cc +++ b/content/renderer/gpu/gpu_channel_host.cc @@ -182,7 +182,7 @@ bool GpuChannelHost::Send(IPC::Message* message) { } CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( - int render_view_id, + int32 surface_id, CommandBufferProxy* share_group, const std::string& allowed_extensions, const std::vector<int32>& attribs, @@ -205,7 +205,7 @@ CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( int32 route_id; if (!ChildThread::current()->Send( new GpuHostMsg_CreateViewCommandBuffer( - render_view_id, + surface_id, init_params, &route_id))) { return NULL; diff --git a/content/renderer/gpu/gpu_channel_host.h b/content/renderer/gpu/gpu_channel_host.h index c69e6b7..554fe19 100644 --- a/content/renderer/gpu/gpu_channel_host.h +++ b/content/renderer/gpu/gpu_channel_host.h @@ -84,7 +84,7 @@ class GpuChannelHost : public IPC::Message::Sender, // Create and connect to a command buffer in the GPU process. CommandBufferProxy* CreateViewCommandBuffer( - int render_view_id, + int32 surface_id, CommandBufferProxy* share_group, const std::string& allowed_extensions, const std::vector<int32>& attribs, diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 3000028..5630a32 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -79,7 +79,7 @@ RendererGLContext::~RendererGLContext() { RendererGLContext* RendererGLContext::CreateViewContext( GpuChannelHost* channel, - int render_view_id, + int32 surface_id, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -89,7 +89,7 @@ RendererGLContext* RendererGLContext::CreateViewContext( scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); if (!context->Initialize( true, - render_view_id, + surface_id, gfx::Size(), share_group, allowed_extensions, @@ -289,7 +289,7 @@ RendererGLContext::RendererGLContext(GpuChannelHost* channel) } bool RendererGLContext::Initialize(bool onscreen, - int render_view_id, + int32 surface_id, const gfx::Size& size, RendererGLContext* share_group, const char* allowed_extensions, @@ -348,7 +348,7 @@ bool RendererGLContext::Initialize(bool onscreen, TRACE_EVENT0("gpu", "RendererGLContext::Initialize::CreateViewCommandBuffer"); command_buffer_ = channel_->CreateViewCommandBuffer( - render_view_id, + surface_id, share_group ? share_group->command_buffer_ : NULL, allowed_extensions, attribs, diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index b5ae425..b3a8f74 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -103,7 +103,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, // more cross-platform. static RendererGLContext* CreateViewContext( GpuChannelHost* channel, - int render_view_id, + int32 surface_id, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -182,7 +182,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, explicit RendererGLContext(GpuChannelHost* channel); bool Initialize(bool onscreen, - int render_view_id, + int32 surface_id, const gfx::Size& size, RendererGLContext* share_group, const char* allowed_extensions, diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index 51886d1..5611945 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -146,7 +146,7 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_view); if (!render_view) return false; - render_view_routing_id_ = render_view->routing_id(); + surface_id_ = render_view->surface_id(); web_view_ = web_view; } return true; @@ -202,7 +202,7 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { if (render_directly_to_web_view_) { context_ = RendererGLContext::CreateViewContext( host_, - render_view_routing_id_, + surface_id_, share_group, preferred_extensions, attribs, diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h index d3f498b..0137b38 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -491,7 +491,7 @@ class WebGraphicsContext3DCommandBufferImpl // State needed by MaybeInitializeGL. GpuChannelHost* host_; GURL active_url_; - int32 render_view_routing_id_; + int32 surface_id_; bool render_directly_to_web_view_; diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 6dd026c..4d9e828 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -759,6 +759,7 @@ void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) { params.web_preferences, new SharedRenderViewCounter(0), params.view_id, + params.surface_id, params.session_storage_namespace_id, params.frame_name, params.next_page_id); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 8d5d6e5..8692f3b 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -337,6 +337,7 @@ RenderViewImpl::RenderViewImpl( const WebPreferences& webkit_prefs, SharedRenderViewCounter* counter, int32 routing_id, + int32 surface_id, int64 session_storage_namespace_id, const string16& frame_name, int32 next_page_id) @@ -375,6 +376,7 @@ RenderViewImpl::RenderViewImpl( #endif ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { routing_id_ = routing_id; + surface_id_ = surface_id; if (opener_id != MSG_ROUTING_NONE) opener_id_ = opener_id; @@ -514,6 +516,7 @@ RenderViewImpl* RenderViewImpl::Create( const WebPreferences& webkit_prefs, SharedRenderViewCounter* counter, int32 routing_id, + int32 surface_id, int64 session_storage_namespace_id, const string16& frame_name, int32 next_page_id) { @@ -525,6 +528,7 @@ RenderViewImpl* RenderViewImpl::Create( webkit_prefs, counter, routing_id, + surface_id, session_storage_namespace_id, frame_name, next_page_id); // adds reference @@ -1344,12 +1348,14 @@ WebView* RenderViewImpl::createView( params.target_url = request.url(); int32 routing_id = MSG_ROUTING_NONE; + int32 surface_id = 0; int64 cloned_session_storage_namespace_id; bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); RenderThread::Get()->Send( new ViewHostMsg_CreateWindow(params, &routing_id, + &surface_id, &cloned_session_storage_namespace_id)); if (routing_id == MSG_ROUTING_NONE) return NULL; @@ -1361,6 +1367,7 @@ WebView* RenderViewImpl::createView( webkit_preferences_, shared_popup_counter_, routing_id, + surface_id, cloned_session_storage_namespace_id, frame_name, 1); diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index be94611..1dc8c77 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -176,6 +176,7 @@ class RenderViewImpl : public RenderWidget, const WebPreferences& webkit_prefs, SharedRenderViewCounter* counter, int32 routing_id, + int32 surface_id, int64 session_storage_namespace_id, const string16& frame_name, int32 next_page_id); @@ -692,6 +693,7 @@ class RenderViewImpl : public RenderWidget, const WebPreferences& webkit_prefs, SharedRenderViewCounter* counter, int32 routing_id, + int32 surface_id, int64 session_storage_namespace_id, const string16& frame_name, int32 next_page_id); diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 6840d8b..ff139dd 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -70,6 +70,7 @@ using content::RenderThread; RenderWidget::RenderWidget(WebKit::WebPopupType popup_type) : routing_id_(MSG_ROUTING_NONE), + surface_id_(0), webwidget_(NULL), opener_id_(MSG_ROUTING_NONE), host_window_(0), @@ -141,7 +142,8 @@ WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { void RenderWidget::Init(int32 opener_id) { DoInit(opener_id, RenderWidget::CreateWebWidget(this), - new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); + new ViewHostMsg_CreateWidget(opener_id, popup_type_, + &routing_id_, &surface_id_)); } void RenderWidget::DoInit(int32 opener_id, diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index d9c9535..5c11923 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,6 +91,10 @@ class CONTENT_EXPORT RenderWidget return routing_id_; } + int32 surface_id() const { + return surface_id_; + } + // May return NULL when the window is closing. WebKit::WebWidget* webwidget() const { return webwidget_; } @@ -338,6 +342,8 @@ class CONTENT_EXPORT RenderWidget // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. int32 routing_id_; + int32 surface_id_; + // We are responsible for destroying this object via its Close method. WebKit::WebWidget* webwidget_; diff --git a/content/renderer/render_widget_fullscreen.cc b/content/renderer/render_widget_fullscreen.cc index 1e38683..f71b780 100644 --- a/content/renderer/render_widget_fullscreen.cc +++ b/content/renderer/render_widget_fullscreen.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,7 +29,8 @@ void RenderWidgetFullscreen::Init(int32 opener_id) { RenderWidget::DoInit( opener_id, CreateWebWidget(), - new ViewHostMsg_CreateFullscreenWidget(opener_id, &routing_id_)); + new ViewHostMsg_CreateFullscreenWidget( + opener_id, &routing_id_, &surface_id_)); } void RenderWidgetFullscreen::show(WebKit::WebNavigationPolicy) { diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 11f4fc1..919cccc 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -355,7 +355,7 @@ void RenderWidgetFullscreenPepper::CreateContext() { }; context_ = RendererGLContext::CreateViewContext( host, - routing_id(), + surface_id(), NULL, "GL_OES_packed_depth_stencil GL_OES_depth24", attribs, diff --git a/content/test/mock_render_thread.cc b/content/test/mock_render_thread.cc index 70de43e..0dc5ca0 100644 --- a/content/test/mock_render_thread.cc +++ b/content/test/mock_render_thread.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,7 +13,7 @@ namespace content { MockRenderThread::MockRenderThread() - : routing_id_(0), opener_id_(0) { + : routing_id_(0), surface_id_(0), opener_id_(0) { } MockRenderThread::~MockRenderThread() { @@ -169,9 +169,11 @@ void MockRenderThread::SendCloseMessage() { // The Widget expects to be returned valid route_id. void MockRenderThread::OnMsgCreateWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id) { + int* route_id, + int* surface_id) { opener_id_ = opener_id; *route_id = routing_id_; + *surface_id = surface_id_; } bool MockRenderThread::OnMessageReceived(const IPC::Message& msg) { diff --git a/content/test/mock_render_thread.h b/content/test/mock_render_thread.h index 3d87ed0..0c083a7 100644 --- a/content/test/mock_render_thread.h +++ b/content/test/mock_render_thread.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -78,6 +78,10 @@ class MockRenderThread : public content::RenderThread { routing_id_ = id; } + void set_surface_id(int32 id) { + surface_id_ = id; + } + int32 opener_id() const { return opener_id_; } @@ -99,7 +103,8 @@ class MockRenderThread : public content::RenderThread { // The Widget expects to be returned valid route_id. void OnMsgCreateWidget(int opener_id, WebKit::WebPopupType popup_type, - int* route_id); + int* route_id, + int* surface_id); #if defined(OS_WIN) void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, @@ -111,6 +116,9 @@ class MockRenderThread : public content::RenderThread { // Routing id what will be assigned to the Widget. int32 routing_id_; + // Surface id what will be assigned to the Widget. + int32 surface_id_; + // Opener id reported by the Widget. int32 opener_id_; diff --git a/content/test/render_view_test.cc b/content/test/render_view_test.cc index 6ae13fc..a44eb6a 100644 --- a/content/test/render_view_test.cc +++ b/content/test/render_view_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -46,6 +46,7 @@ using WebKit::WebURLRequest; namespace { const int32 kOpenerId = 7; const int32 kRouteId = 5; +const int32 kSurfaceId = 42; #if defined(USE_AURA) && defined(USE_X11) // Converts MockKeyboard::Modifiers to ui::EventFlags. @@ -130,6 +131,7 @@ void RenderViewTest::SetUp() { if (!render_thread_.get()) render_thread_.reset(new MockRenderThread()); render_thread_->set_routing_id(kRouteId); + render_thread_->set_surface_id(kSurfaceId); command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); params_.reset(new content::MainFunctionParams(*command_line_)); @@ -151,6 +153,7 @@ void RenderViewTest::SetUp() { WebPreferences(), new SharedRenderViewCounter(0), kRouteId, + kSurfaceId, kInvalidSessionStorageNamespaceId, string16(), 1); |