diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 23:55:56 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 23:55:56 +0000 |
commit | bc4a343d38e945209a2aa02572af3e71c89cae42 (patch) | |
tree | 6312f02d108f26184e8d6ef193117e538cf5f134 /content/common | |
parent | 4c136c6a49b15a2e5824682d858a21d8becb4259 (diff) | |
download | chromium_src-bc4a343d38e945209a2aa02572af3e71c89cae42.zip chromium_src-bc4a343d38e945209a2aa02572af3e71c89cae42.tar.gz chromium_src-bc4a343d38e945209a2aa02572af3e71c89cae42.tar.bz2 |
Revert 111040 - Reland 110355 - Use shared D3D9 texture to transport the compositor's backing buffer to the browser process for presentation.
Implemented ImageTransportSurface for Linux (without texture sharing), XP, Vista and 7. XP. The non-texture sharing Linux and XP paths just present directly to the compositing child window owned by the browser process as before.
PassThroughImageTransportSurface still needs a proper name. I will move it into its own file once that is decided.
I moved AcceleratedSurfaceBuffersSwapped outside of the platform specific ifdefs and made the signature the same on all platforms for greater consistency.
I removed the code related to sharing surfaces between processes and synchronizing resize and swapping out of GpuCommandBufferStub. It is all now in ImageTransportSurface implementations.
Original Review URL: http://codereview.chromium.org/8060045
Review URL: http://codereview.chromium.org/8620006
TBR=apatrick@chromium.org
Review URL: http://codereview.chromium.org/8625003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/gpu/gpu_channel.cc | 8 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel.h | 2 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.cc | 14 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.h | 1 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 88 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 16 | ||||
-rw-r--r-- | content/common/gpu/gpu_messages.h | 55 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface.cc | 94 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface.h | 46 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_linux.cc | 30 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_mac.cc | 10 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_win.cc | 176 |
12 files changed, 153 insertions, 387 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index 27eb490..2f14065 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -209,6 +209,14 @@ void GpuChannel::CreateViewCommandBuffer( #endif // ENABLE_GPU } +void GpuChannel::ViewResized(int32 command_buffer_route_id) { + GpuCommandBufferStub* stub = stubs_.Lookup(command_buffer_route_id); + if (stub == NULL) + return; + + stub->ViewResized(); +} + GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { return stubs_.Lookup(route_id); } diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index bc642ac..782698f 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -88,6 +88,8 @@ class GpuChannel : public IPC::Channel::Listener, const GPUCreateCommandBufferConfig& init_params, int32* route_id); + void ViewResized(int32 command_buffer_route_id); + gfx::GLShareGroup* share_group() const { return share_group_.get(); } GpuCommandBufferStub* LookupCommandBuffer(int32 route_id); diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index 94838fb..850ae2a 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -62,6 +62,9 @@ bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, OnCreateViewCommandBuffer) IPC_MESSAGE_HANDLER(GpuMsg_VisibilityChanged, OnVisibilityChanged) +#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) + IPC_MESSAGE_HANDLER(GpuMsg_ResizeViewACK, OnResizeViewACK); +#endif IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() return handled; @@ -124,7 +127,6 @@ void GpuChannelManager::OnCreateViewCommandBuffer( int32 render_view_id, int32 renderer_id, const GPUCreateCommandBufferConfig& init_params) { - DCHECK(render_view_id); int32 route_id = MSG_ROUTING_NONE; GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); @@ -136,6 +138,16 @@ void GpuChannelManager::OnCreateViewCommandBuffer( Send(new GpuHostMsg_CommandBufferCreated(route_id)); } +void GpuChannelManager::OnResizeViewACK(int32 renderer_id, + int32 command_buffer_route_id) { + GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); + if (iter == gpu_channels_.end()) + return; + scoped_refptr<GpuChannel> channel = iter->second; + + channel->ViewResized(command_buffer_route_id); +} + void GpuChannelManager::LoseAllContexts() { MessageLoop::current()->PostTask( FROM_HERE, diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h index db0db36..a6fff25 100644 --- a/content/common/gpu/gpu_channel_manager.h +++ b/content/common/gpu/gpu_channel_manager.h @@ -77,6 +77,7 @@ class GpuChannelManager : public IPC::Channel::Listener, int32 render_view_id, int32 renderer_id, const GPUCreateCommandBufferConfig& init_params); + void OnResizeViewACK(int32 renderer_id, int32 command_buffer_route_id); void OnLoseAllContexts(); diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 09808c9..16c4405 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -14,11 +14,13 @@ #include "content/common/gpu/gpu_command_buffer_stub.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/gpu/gpu_watchdog.h" -#include "content/common/gpu/image_transport_surface.h" #include "gpu/command_buffer/common/constants.h" -#include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_switches.h" +#if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) +#include "content/common/gpu/image_transport_surface.h" +#endif + GpuCommandBufferStub::GpuCommandBufferStub( GpuChannel* channel, GpuCommandBufferStub* share_group, @@ -122,19 +124,6 @@ bool GpuCommandBufferStub::IsScheduled() { return !scheduler_.get() || scheduler_->IsScheduled(); } -void GpuCommandBufferStub::SetSwapInterval() { -#if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) - // Set up swap interval for onscreen contexts. - if (!surface_->IsOffscreen()) { - decoder_->MakeCurrent(); - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) - context_->SetSwapInterval(0); - else - context_->SetSwapInterval(1); - } -#endif -} - void GpuCommandBufferStub::Destroy() { // The scheduler has raw references to the decoder and the command buffer so // destroy it before those. @@ -196,7 +185,6 @@ void GpuCommandBufferStub::OnInitialize( OnInitializeFailed(reply_message); return; } -#endif surface_ = ImageTransportSurface::CreateSurface( channel_->gpu_channel_manager(), @@ -204,6 +192,9 @@ void GpuCommandBufferStub::OnInitialize( renderer_id_, route_id_, handle_); +#elif defined(OS_WIN) || defined(OS_LINUX) || defined(OS_OPENBSD) + surface_ = gfx::GLSurface::CreateViewGLSurface(software_, handle_); +#endif } else { surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_, gfx::Size(1, 1)); @@ -262,6 +253,16 @@ void GpuCommandBufferStub::OnInitialize( scheduler_->SetScheduledCallback( NewCallback(channel_, &GpuChannel::OnScheduled)); + // On platforms that use an ImageTransportSurface, the surface + // handles co-ordinating the resize with the browser process. The + // surface sets it's own resize callback, so we shouldn't do it here. +#if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) + if (handle_ != gfx::kNullPluginWindow) { + decoder_->SetResizeCallback( + NewCallback(this, &GpuCommandBufferStub::OnResize)); + } +#endif + if (watchdog_) { scheduler_->SetCommandProcessedCallback( NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); @@ -428,6 +429,48 @@ void GpuCommandBufferStub::OnCommandProcessed() { watchdog_->CheckArmed(); } +void GpuCommandBufferStub::OnResize(gfx::Size size) { + if (handle_ == gfx::kNullPluginWindow) + return; + +#if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \ + defined(OS_WIN) + GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); + + // On Windows, Linux, we need to coordinate resizing of onscreen + // contexts with the resizing of the actual OS-level window. We do this by + // sending a resize message to the browser process and descheduling the + // context until the ViewResized message comes back in reply. + // Send the resize message if needed + gpu_channel_manager->Send( + new GpuHostMsg_ResizeView(renderer_id_, + render_view_id_, + route_id_, + size)); + + scheduler_->SetScheduled(false); +#endif +} + +void GpuCommandBufferStub::ViewResized() { +#if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \ + defined(OS_WIN) + DCHECK(handle_ != gfx::kNullPluginWindow); + scheduler_->SetScheduled(true); +#endif + +#if defined(OS_WIN) + // Recreate the view surface to match the window size. Swap chains do not + // automatically resize with window size with D3D. + context_->ReleaseCurrent(surface_.get()); + if (surface_.get()) { + surface_->Destroy(); + surface_->Initialize(); + SetSwapInterval(); + } +#endif +} + void GpuCommandBufferStub::ReportState() { gpu::CommandBuffer::State state = command_buffer_->GetState(); if (state.error == gpu::error::kLostContext && @@ -440,6 +483,19 @@ void GpuCommandBufferStub::ReportState() { } } +void GpuCommandBufferStub::SetSwapInterval() { +#if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) + // Set up swap interval for onscreen contexts. + if (!surface_->IsOffscreen()) { + decoder_->MakeCurrent(); + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) + context_->SetSwapInterval(0); + else + context_->SetSwapInterval(1); + } +#endif +} + void GpuCommandBufferStub::OnCreateVideoDecoder( media::VideoDecodeAccelerator::Profile profile, IPC::Message* reply_message) { diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index f581593..6ece34f 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -65,9 +65,6 @@ class GpuCommandBufferStub // Whether this command buffer can currently handle IPC messages. bool IsScheduled(); - // Set the swap interval according to the command line. - void SetSwapInterval(); - gpu::gles2::GLES2Decoder* decoder() const { return decoder_.get(); } gpu::GpuScheduler* scheduler() const { return scheduler_.get(); } @@ -81,6 +78,8 @@ class GpuCommandBufferStub // to the same renderer process. int32 route_id() const { return route_id_; } + void ViewResized(); + gfx::GpuPreference gpu_preference() { return gpu_preference_; } private: @@ -118,11 +117,22 @@ class GpuCommandBufferStub void OnSetSurfaceVisible(bool visible); +#if defined(OS_MACOSX) + void OnSwapBuffers(); + + // Returns the id of the current surface that is being rendered to + // (or 0 if no such surface has been created). + uint64 GetSurfaceId(); +#endif + void OnCommandProcessed(); void OnParseError(); + void OnResize(gfx::Size size); void ReportState(); + void SetSwapInterval(); + // The lifetime of objects of this class is managed by a GpuChannel. The // GpuChannels destroy all the GpuCommandBufferStubs that they own when they // are destroyed. So a raw pointer is safe. diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index 8c99041..906a195 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -33,29 +33,50 @@ IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig) IPC_STRUCT_MEMBER(gfx::GpuPreference, gpu_preference) IPC_STRUCT_END() +#if defined(OS_MACOSX) IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceNew_Params) IPC_STRUCT_MEMBER(int32, renderer_id) IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) IPC_STRUCT_MEMBER(int32, width) IPC_STRUCT_MEMBER(int32, height) IPC_STRUCT_MEMBER(uint64, surface_id) - IPC_STRUCT_MEMBER(int32, route_id) -#if defined(OS_MACOSX) - IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) IPC_STRUCT_MEMBER(bool, create_transport_dib) -#endif + IPC_STRUCT_MEMBER(int32, route_id) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) IPC_STRUCT_MEMBER(int32, renderer_id) IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) IPC_STRUCT_MEMBER(uint64, surface_id) IPC_STRUCT_MEMBER(int32, route_id) -#if defined(OS_WIN) - IPC_STRUCT_MEMBER(gfx::Size, size) -#elif defined(OS_MACOSX) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params) + IPC_STRUCT_MEMBER(int32, renderer_id) + IPC_STRUCT_MEMBER(int32, render_view_id) IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) + IPC_STRUCT_MEMBER(uint64, identifier) + IPC_STRUCT_MEMBER(int32, route_id) +IPC_STRUCT_END() #endif + +#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) +IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceNew_Params) + IPC_STRUCT_MEMBER(int32, renderer_id) + IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(int32, width) + IPC_STRUCT_MEMBER(int32, height) + IPC_STRUCT_MEMBER(uint64, surface_id) + IPC_STRUCT_MEMBER(int32, route_id) +IPC_STRUCT_END() + +IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) + IPC_STRUCT_MEMBER(int32, renderer_id) + IPC_STRUCT_MEMBER(int32, render_view_id) + IPC_STRUCT_MEMBER(uint64, surface_id) + IPC_STRUCT_MEMBER(int32, route_id) IPC_STRUCT_END() IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params) @@ -63,10 +84,8 @@ IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceRelease_Params) IPC_STRUCT_MEMBER(int32, render_view_id) IPC_STRUCT_MEMBER(uint64, identifier) IPC_STRUCT_MEMBER(int32, route_id) -#if defined(OS_MACOSX) - IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, window) -#endif IPC_STRUCT_END() +#endif IPC_STRUCT_TRAITS_BEGIN(content::DxDiagNode) IPC_STRUCT_TRAITS_MEMBER(values) @@ -141,10 +160,16 @@ IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer, // information. IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo) +#if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \ + defined(OS_WIN) // Tells the GPU process that the browser process has finished resizing the // view. -IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_ResizeViewACK) +IPC_MESSAGE_CONTROL2(GpuMsg_ResizeViewACK, + int32 /* renderer_id */, + int32 /* command_buffer_id */) +#endif +#if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) // Tells the GPU process that it's safe to start rendering to the surface. IPC_MESSAGE_ROUTED2(AcceleratedSurfaceMsg_NewACK, uint64 /* surface_id */, @@ -153,6 +178,7 @@ IPC_MESSAGE_ROUTED2(AcceleratedSurfaceMsg_NewACK, // Tells the GPU process that the browser process handled the swap // buffers request with the given number. IPC_MESSAGE_ROUTED0(AcceleratedSurfaceMsg_BuffersSwappedACK) +#endif // Tells the GPU process to remove all contexts. IPC_MESSAGE_CONTROL0(GpuMsg_Clean) @@ -208,14 +234,18 @@ IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage, std::string /* header */, std::string /* message */) +#if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \ + defined(OS_WIN) // 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 /* renderer_id */, int32 /* render_view_id */, - int32 /* route_id */, + int32 /* command_buffer_route_id */, gfx::Size /* size */) +#endif +#if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) // This message is sent from the GPU process to the browser to notify about a // new or resized surface in the GPU. The browser allocates any resources // needed for it on its end and replies with an ACK containing any shared @@ -234,6 +264,7 @@ IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, // is complete. IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceRelease, GpuHostMsg_AcceleratedSurfaceRelease_Params) +#endif //------------------------------------------------------------------------------ // GPU Channel Messages diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc index c9585a0..8d4c076 100644 --- a/content/common/gpu/image_transport_surface.cc +++ b/content/common/gpu/image_transport_surface.cc @@ -13,12 +13,6 @@ #include "content/common/gpu/gpu_messages.h" #include "gpu/command_buffer/service/gpu_scheduler.h" -ImageTransportSurface::ImageTransportSurface() { -} - -ImageTransportSurface::~ImageTransportSurface() { -} - ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface, GpuChannelManager* manager, int32 render_view_id, @@ -61,7 +55,6 @@ bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) { OnBuffersSwappedACK) IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_NewACK, OnNewSurfaceACK) - IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_ResizeViewACK, OnResizeViewACK); IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -97,13 +90,6 @@ void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped( manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); } -void ImageTransportHelper::SendResizeView(const gfx::Size& size) { - manager_->Send(new GpuHostMsg_ResizeView(renderer_id_, - render_view_id_, - route_id_, - size)); -} - void ImageTransportHelper::SetScheduled(bool is_scheduled) { gpu::GpuScheduler* scheduler = Scheduler(); if (!scheduler) @@ -112,13 +98,6 @@ void ImageTransportHelper::SetScheduled(bool is_scheduled) { scheduler->SetScheduled(is_scheduled); } -void ImageTransportHelper::DeferToFence(base::Closure task) { - gpu::GpuScheduler* scheduler = Scheduler(); - DCHECK(scheduler); - - scheduler->DeferToFence(task); -} - void ImageTransportHelper::OnBuffersSwappedACK() { surface_->OnBuffersSwappedACK(); } @@ -129,38 +108,8 @@ void ImageTransportHelper::OnNewSurfaceACK( surface_->OnNewSurfaceACK(surface_id, shm_handle); } -void ImageTransportHelper::OnResizeViewACK() { - surface_->OnResizeViewACK(); -} - void ImageTransportHelper::Resize(gfx::Size size) { - // On windows, the surface is recreated and, in case the newly allocated - // surface happens to have the same address, it should be invalidated on the - // decoder so that future calls to MakeCurrent do not early out on the - // assumption that neither the context or surface have actually changed. -#if defined(OS_WIN) - Decoder()->ReleaseCurrent(); -#endif - surface_->OnResize(size); - -#if defined(OS_WIN) - Decoder()->MakeCurrent(); - SetSwapInterval(); -#endif -} - -void ImageTransportHelper::SetSwapInterval() { - GpuChannel* channel = manager_->LookupChannel(renderer_id_); - if (!channel) - return; - - GpuCommandBufferStub* stub = - channel->LookupCommandBuffer(command_buffer_id_); - if (!stub) - return; - - stub->SetSwapInterval(); } bool ImageTransportHelper::MakeCurrent() { @@ -196,47 +145,4 @@ gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() { return stub->decoder(); } -PassThroughImageTransportSurface::PassThroughImageTransportSurface( - GpuChannelManager* manager, - int32 render_view_id, - int32 renderer_id, - int32 command_buffer_id, - gfx::GLSurface* surface) : GLSurfaceAdapter(surface) { - helper_.reset(new ImageTransportHelper(this, - manager, - render_view_id, - renderer_id, - command_buffer_id, - gfx::kNullPluginWindow)); -} - -PassThroughImageTransportSurface::~PassThroughImageTransportSurface() { -} - -bool PassThroughImageTransportSurface::Initialize() { - // The surface is assumed to have already been initialized. - return helper_->Initialize(); -} - -void PassThroughImageTransportSurface::Destroy() { - helper_->Destroy(); - GLSurfaceAdapter::Destroy(); -} - -void PassThroughImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) { -} - -void PassThroughImageTransportSurface::OnBuffersSwappedACK() { -} - -void PassThroughImageTransportSurface::OnResizeViewACK() { - helper_->SetScheduled(true); -} - -void PassThroughImageTransportSurface::OnResize(gfx::Size size) { - helper_->SendResizeView(size); - helper_->SetScheduled(false); -} - #endif // defined(ENABLE_GPU) diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h index b791c6e..044d8c3 100644 --- a/content/common/gpu/image_transport_surface.h +++ b/content/common/gpu/image_transport_surface.h @@ -8,12 +8,9 @@ #if defined(ENABLE_GPU) -#include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_message.h" -#include "ui/gfx/gl/gl_surface.h" #include "ui/gfx/size.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/surface/transport_dib.h" @@ -51,13 +48,9 @@ class GLES2Decoder; class ImageTransportSurface { public: - ImageTransportSurface(); - virtual ~ImageTransportSurface(); - virtual void OnNewSurfaceACK( uint64 surface_id, TransportDIB::Handle surface_handle) = 0; virtual void OnBuffersSwappedACK() = 0; - virtual void OnResizeViewACK() = 0; virtual void OnResize(gfx::Size size) = 0; // Creates the appropriate surface depending on the GL implementation. @@ -67,8 +60,6 @@ class ImageTransportSurface { int32 renderer_id, int32 command_buffer_id, gfx::PluginWindowHandle handle); - private: - DISALLOW_COPY_AND_ASSIGN(ImageTransportSurface); }; class ImageTransportHelper : public IPC::Channel::Listener { @@ -96,13 +87,10 @@ class ImageTransportHelper : public IPC::Channel::Listener { GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params); void SendAcceleratedSurfaceRelease( GpuHostMsg_AcceleratedSurfaceRelease_Params params); - void SendResizeView(const gfx::Size& size); // Whether or not we should execute more commands. void SetScheduled(bool is_scheduled); - void DeferToFence(base::Closure task); - // Make the surface's context current. bool MakeCurrent(); @@ -113,14 +101,10 @@ class ImageTransportHelper : public IPC::Channel::Listener { // IPC::Message handlers. void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle surface_handle); void OnBuffersSwappedACK(); - void OnResizeViewACK(); // Backbuffer resize callback. void Resize(gfx::Size size); - // Set the default swap interval on the surface. - void SetSwapInterval(); - // Weak pointers that point to objects that outlive this helper. ImageTransportSurface* surface_; GpuChannelManager* manager_; @@ -134,36 +118,6 @@ class ImageTransportHelper : public IPC::Channel::Listener { DISALLOW_COPY_AND_ASSIGN(ImageTransportHelper); }; -// An implementation of ImageTransportSurface that implements GLSurface through -// GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. -class PassThroughImageTransportSurface - : public gfx::GLSurfaceAdapter, - public ImageTransportSurface { - public: - PassThroughImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 renderer_id, - int32 command_buffer_id, - gfx::GLSurface* surface); - virtual ~PassThroughImageTransportSurface(); - - // GLSurface implementation. - virtual bool Initialize(); - virtual void Destroy(); - - // ImageTransportSurface implementation. - virtual void OnNewSurfaceACK( - uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; - virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; - virtual void OnResize(gfx::Size size) OVERRIDE; - - private: - scoped_ptr<ImageTransportHelper> helper_; - - DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); -}; - #endif // defined(ENABLE_GPU) #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_H_ diff --git a/content/common/gpu/image_transport_surface_linux.cc b/content/common/gpu/image_transport_surface_linux.cc index bcb1284..5cc75ba 100644 --- a/content/common/gpu/image_transport_surface_linux.cc +++ b/content/common/gpu/image_transport_surface_linux.cc @@ -77,7 +77,6 @@ class EGLImageTransportSurface : public ImageTransportSurface, virtual void OnNewSurfaceACK( uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; private: @@ -120,7 +119,6 @@ class GLXImageTransportSurface : public ImageTransportSurface, virtual void OnNewSurfaceACK( uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; private: @@ -169,7 +167,6 @@ class OSMesaImageTransportSurface : public ImageTransportSurface, virtual void OnNewSurfaceACK( uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; private: @@ -377,11 +374,6 @@ void EGLImageTransportSurface::OnBuffersSwappedACK() { helper_->SetScheduled(true); } - -void EGLImageTransportSurface::OnResizeViewACK() { - NOTREACHED(); -} - GLXImageTransportSurface::GLXImageTransportSurface( GpuChannelManager* manager, int32 render_view_id, @@ -547,10 +539,6 @@ void GLXImageTransportSurface::OnBuffersSwappedACK() { helper_->SetScheduled(true); } -void GLXImageTransportSurface::OnResizeViewACK() { - NOTREACHED(); -} - OSMesaImageTransportSurface::OSMesaImageTransportSurface( GpuChannelManager* manager, int32 render_view_id, @@ -629,10 +617,6 @@ void OSMesaImageTransportSurface::OnNewSurfaceACK( helper_->SetScheduled(true); } -void OSMesaImageTransportSurface::OnResizeViewACK() { - NOTREACHED(); -} - bool OSMesaImageTransportSurface::SwapBuffers() { DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); @@ -664,9 +648,8 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( int32 render_view_id, int32 renderer_id, int32 command_buffer_id, - gfx::PluginWindowHandle handle) { + gfx::PluginWindowHandle /* handle */) { scoped_refptr<gfx::GLSurface> surface; -#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) switch (gfx::GetGLImplementation()) { case gfx::kGLImplementationDesktopGL: surface = new GLXImageTransportSurface(manager, @@ -690,17 +673,6 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( NOTREACHED(); return NULL; } -#else - surface = gfx::GLSurface::CreateViewGLSurface(false, handle); - if (!surface.get()) - return NULL; - - surface = new PassThroughImageTransportSurface(manager, - render_view_id, - renderer_id, - command_buffer_id, - surface.get()); -#endif if (surface->Initialize()) return surface; else diff --git a/content/common/gpu/image_transport_surface_mac.cc b/content/common/gpu/image_transport_surface_mac.cc index 8449f81..09d3521 100644 --- a/content/common/gpu/image_transport_surface_mac.cc +++ b/content/common/gpu/image_transport_surface_mac.cc @@ -43,7 +43,6 @@ class IOSurfaceImageTransportSurface : public gfx::PbufferGLSurfaceCGL, virtual void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle shm_handle) OVERRIDE; virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; private: @@ -95,7 +94,6 @@ class TransportDIBImageTransportSurface : public gfx::PbufferGLSurfaceCGL, virtual void OnBuffersSwappedACK() OVERRIDE; virtual void OnNewSurfaceACK(uint64 surface_id, TransportDIB::Handle shm_handle) OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; virtual void OnResize(gfx::Size size) OVERRIDE; private: @@ -241,10 +239,6 @@ void IOSurfaceImageTransportSurface::OnNewSurfaceACK( helper_->SetScheduled(true); } -void IOSurfaceImageTransportSurface::OnResizeViewACK() { - NOTREACHED(); -} - void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); @@ -449,10 +443,6 @@ void TransportDIBImageTransportSurface::OnNewSurfaceACK( DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); } -void TransportDIBImageTransportSurface::OnResizeViewACK() { - NOTREACHED(); -} - void TransportDIBImageTransportSurface::OnResize(gfx::Size size) { size_ = size; diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc deleted file mode 100644 index 91040fe..0000000 --- a/content/common/gpu/image_transport_surface_win.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) 2011 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. - -#if defined(ENABLE_GPU) - -#include "content/common/gpu/image_transport_surface.h" - -#include "base/bind.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/win/windows_version.h" -#include "content/common/gpu/gpu_messages.h" -#include "ui/gfx/gl/gl_bindings.h" -#include "ui/gfx/gl/gl_context.h" -#include "ui/gfx/gl/gl_implementation.h" -#include "ui/gfx/gl/gl_surface_egl.h" -#include "ui/gfx/native_widget_types.h" - -namespace { - -// We are backed by an Pbuffer offscreen surface through which ANGLE provides -// a handle to the corresponding render target texture through an extension. -class PbufferImageTransportSurface - : public gfx::GLSurfaceAdapter, - public ImageTransportSurface, - public base::SupportsWeakPtr<PbufferImageTransportSurface> { - public: - PbufferImageTransportSurface(GpuChannelManager* manager, - int32 render_view_id, - int32 renderer_id, - int32 command_buffer_id); - - // GLSurface implementation - virtual bool Initialize(); - virtual void Destroy(); - virtual bool IsOffscreen(); - virtual bool SwapBuffers(); - - protected: - // ImageTransportSurface implementation - virtual void OnNewSurfaceACK(uint64 surface_id, - TransportDIB::Handle shm_handle) OVERRIDE; - virtual void OnBuffersSwappedACK() OVERRIDE; - virtual void OnResizeViewACK() OVERRIDE; - virtual void OnResize(gfx::Size size) OVERRIDE; - - private: - virtual ~PbufferImageTransportSurface(); - void SendBuffersSwapped(); - - scoped_ptr<ImageTransportHelper> helper_; - - DISALLOW_COPY_AND_ASSIGN(PbufferImageTransportSurface); -}; - -PbufferImageTransportSurface::PbufferImageTransportSurface( - GpuChannelManager* manager, - int32 render_view_id, - int32 renderer_id, - int32 command_buffer_id) - : GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, - gfx::Size(1, 1))) { - helper_.reset(new ImageTransportHelper(this, - manager, - render_view_id, - renderer_id, - command_buffer_id, - gfx::kNullPluginWindow)); -} - -PbufferImageTransportSurface::~PbufferImageTransportSurface() { - Destroy(); -} - -bool PbufferImageTransportSurface::Initialize() { - // Only support this path if the GL implementation is ANGLE. - // IO surfaces will not work with, for example, OSMesa software renderer - // GL contexts. - if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) - return false; - - if (!helper_->Initialize()) - return false; - - return GLSurfaceAdapter::Initialize(); -} - -void PbufferImageTransportSurface::Destroy() { - helper_->Destroy(); - GLSurfaceAdapter::Destroy(); -} - -bool PbufferImageTransportSurface::IsOffscreen() { - return false; -} - -bool PbufferImageTransportSurface::SwapBuffers() { - HANDLE surface_handle = GetShareHandle(); - if (!surface_handle) - return false; - - helper_->DeferToFence(base::Bind( - &PbufferImageTransportSurface::SendBuffersSwapped, - AsWeakPtr())); - - return true; -} - -void PbufferImageTransportSurface::SendBuffersSwapped() { - GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; - params.surface_id = reinterpret_cast<int64>(GetShareHandle()); - params.size = GetSize(); - helper_->SendAcceleratedSurfaceBuffersSwapped(params); - - helper_->SetScheduled(false); -} - -void PbufferImageTransportSurface::OnBuffersSwappedACK() { - helper_->SetScheduled(true); -} - -void PbufferImageTransportSurface::OnNewSurfaceACK( - uint64 surface_id, - TransportDIB::Handle shm_handle) { - NOTIMPLEMENTED(); -} - -void PbufferImageTransportSurface::OnResizeViewACK() { - NOTIMPLEMENTED(); -} - -void PbufferImageTransportSurface::OnResize(gfx::Size size) { - Resize(size); -} - -} // namespace anonymous - -// static -scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( - GpuChannelManager* manager, - int32 render_view_id, - int32 renderer_id, - int32 command_buffer_id, - gfx::PluginWindowHandle handle) { - scoped_refptr<gfx::GLSurface> surface; - - base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); - - // TODO(apatrick): Enable this once it has settled in the tree. - if (false && gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && - os_info->version() >= base::win::VERSION_VISTA) { - surface = new PbufferImageTransportSurface(manager, - render_view_id, - renderer_id, - command_buffer_id); - } else { - surface = gfx::GLSurface::CreateViewGLSurface(false, handle); - if (!surface.get()) - return NULL; - - surface = new PassThroughImageTransportSurface(manager, - render_view_id, - renderer_id, - command_buffer_id, - surface.get()); - } - - if (surface->Initialize()) - return surface; - else - return NULL; -} - -#endif // ENABLE_GPU |