diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.h | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view.h | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.h | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.mm | 19 | ||||
-rw-r--r-- | chrome/browser/renderer_host/test/test_render_view_host.cc | 7 | ||||
-rw-r--r-- | chrome/browser/renderer_host/test/test_render_view_host.h | 4 | ||||
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 34 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 13 | ||||
-rw-r--r-- | chrome/plugin/command_buffer_stub.cc | 31 | ||||
-rw-r--r-- | chrome/plugin/command_buffer_stub.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 21 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 7 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 41 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 7 |
15 files changed, 194 insertions, 18 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index c8ac130..dcb348c 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -150,6 +150,8 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) { OnDestroyFakePluginWindowHandle) IPC_MESSAGE_HANDLER(ViewHostMsg_GPUPluginSetIOSurface, OnGPUPluginSetIOSurface) + IPC_MESSAGE_HANDLER(ViewHostMsg_GPUPluginSetTransportDIB, + OnGPUPluginSetTransportDIB) IPC_MESSAGE_HANDLER(ViewHostMsg_GPUPluginBuffersSwapped, OnGPUPluginBuffersSwapped) #endif @@ -914,6 +916,16 @@ void RenderWidgetHost::OnGPUPluginSetIOSurface(gfx::PluginWindowHandle window, } } +void RenderWidgetHost::OnGPUPluginSetTransportDIB( + gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) { + if (view_) { + view_->GPUPluginSetTransportDIB(window, width, height, transport_dib); + } +} + void RenderWidgetHost::OnGPUPluginBuffersSwapped( gfx::PluginWindowHandle window) { if (view_) { diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 146be7f..e96eae7 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -452,6 +452,10 @@ class RenderWidgetHost : public IPC::Channel::Listener, int32 width, int32 height, uint64 mach_port); + void OnGPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib); void OnGPUPluginBuffersSwapped(gfx::PluginWindowHandle window); #endif diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index 8febbb0..f6f8788 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -11,6 +11,7 @@ #include "app/gfx/native_widget_types.h" #include "base/shared_memory.h" +#include "chrome/common/transport_dib.h" #include "third_party/skia/include/core/SkBitmap.h" #include "webkit/glue/webplugin.h" @@ -187,6 +188,10 @@ class RenderWidgetHostView { int32 width, int32 height, uint64 io_surface_identifier) = 0; + virtual void GPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) = 0; virtual void GPUPluginBuffersSwapped(gfx::PluginWindowHandle window) = 0; // Draws the current GPU plugin instances into the given context. virtual void DrawGPUPluginInstances(CGLContextObj context) = 0; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index 332263e..db0c381 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -124,6 +124,10 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { int32 width, int32 height, uint64 io_surface_identifier); + virtual void GPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib); virtual void GPUPluginBuffersSwapped(gfx::PluginWindowHandle window); // Draws the current GPU plugin instances into the given context. virtual void DrawGPUPluginInstances(CGLContextObj context); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index d9cb616a..b413c54 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -503,10 +503,6 @@ void RenderWidgetHostViewMac::KillSelf() { gfx::PluginWindowHandle RenderWidgetHostViewMac::AllocateFakePluginWindowHandle() { - // We currently only support the GPU plugin on 10.6 and later. - if (!IOSurfaceSupport::Initialize()) - return 0; - // If we don't already have a GPUPluginLayer allocated for our view, // set one up now. if (gpu_plugin_layer_.get() == nil) { @@ -544,10 +540,21 @@ void RenderWidgetHostViewMac::GPUPluginSetIOSurface( int32 width, int32 height, uint64 io_surface_identifier) { - plugin_container_manager_.SetSizeAndBackingStore(window, + plugin_container_manager_.SetSizeAndIOSurface(window, + width, + height, + io_surface_identifier); +} + +void RenderWidgetHostViewMac::GPUPluginSetTransportDIB( + gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) { + plugin_container_manager_.SetSizeAndTransportDIB(window, width, height, - io_surface_identifier); + transport_dib); } void RenderWidgetHostViewMac::GPUPluginBuffersSwapped( diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc index 1c71d05..91b7b914 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.cc +++ b/chrome/browser/renderer_host/test/test_render_view_host.cc @@ -108,6 +108,13 @@ void TestRenderWidgetHostView::GPUPluginSetIOSurface( uint64 io_surface_identifier) { } +void TestRenderWidgetHostView::GPUPluginSetTransportDIB( + gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) { +} + void TestRenderWidgetHostView::GPUPluginBuffersSwapped( gfx::PluginWindowHandle window) { } diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h index 063b7dd..fbeb388 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.h +++ b/chrome/browser/renderer_host/test/test_render_view_host.h @@ -85,6 +85,10 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { int32 width, int32 height, uint64 io_surface_identifier); + virtual void GPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib); virtual void GPUPluginBuffersSwapped(gfx::PluginWindowHandle window); virtual void DrawGPUPluginInstances(CGLContextObj context); #endif diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 66df30b..f83bfca 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -403,6 +403,17 @@ IPC_BEGIN_MESSAGES(PluginHost) IPC_MESSAGE_ROUTED1(PluginHostMsg_UpdateGeometry_ACK, int /* ack_key */) + // This message, used in Mac OS X 10.5 and earlier, is sent from the + // plug-in process to the renderer process to indicate that the GPU + // plug-in allocated a new TransportDIB that holds the GPU's rendered + // image. This information is then forwarded to the browser process via + // a similar message. + IPC_MESSAGE_ROUTED4(PluginHostMsg_GPUPluginSetTransportDIB, + gfx::PluginWindowHandle /* window */, + int32 /* width */, + int32 /* height */, + TransportDIB::Handle /* handle to the TransportDIB */) + // This message, used only on 10.6 and later, is sent from the // plug-in process to the renderer process to indicate that the GPU // plugin allocated a new IOSurface object of the given width and @@ -418,11 +429,24 @@ IPC_BEGIN_MESSAGES(PluginHost) int32 /* height */, uint64 /* identifier for IOSurface */) - // This message, currently used only on 10.6 and later, notifies the - // renderer process (and from there the browser process) that the - // GPU plugin swapped the buffers associated with the given - // "window", which should cause the browser to redraw the various - // GPU plugins' contents. + + // On the Mac, shared memory can't be allocated in the sandbox, so + // the TransportDIB used by the GPU process for rendering has to be allocated + // and managed by the browser. This is a synchronous message, use with care. + IPC_SYNC_MESSAGE_ROUTED1_1(PluginHostMsg_AllocTransportDIB, + size_t /* requested memory size */, + TransportDIB::Handle /* output: DIB handle */) + + // Since the browser keeps handles to the allocated transport DIBs, this + // message is sent to tell the browser that it may release them when the + // renderer is finished with them. + IPC_MESSAGE_ROUTED1(PluginHostMsg_FreeTransportDIB, + TransportDIB::Id /* DIB id */) + + // This message notifies the renderer process (and from there the + // browser process) that the GPU plugin swapped the buffers associated + // with the given "window", which should cause the browser to redraw + // the various GPU plugins' contents. IPC_MESSAGE_ROUTED1(PluginHostMsg_GPUPluginBuffersSwapped, gfx::PluginWindowHandle /* window */) #endif diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 490989f..8b4020b 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1859,7 +1859,18 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_ROUTED1(ViewHostMsg_DestroyFakePluginWindowHandle, gfx::PluginWindowHandle /* id */) - // This message is sent from the renderer to the browser on behalf + // This message, used on Mac OS X 10.5 and earlier (no IOSurface support), + // is sent from the renderer to the browser on behalf of the GPU plugin + // to indicate that a new backing store was allocated for that GPU plugin + // instance. + IPC_MESSAGE_ROUTED4(ViewHostMsg_GPUPluginSetTransportDIB, + gfx::PluginWindowHandle /* window */, + int32 /* width */, + int32 /* height */, + TransportDIB::Handle /* handle for the DIB */) + + // This message, used on Mac OS X 10.6 and later (where IOSurface is + // supported), is sent from the renderer to the browser on behalf // of the GPU plugin to indicate that a new backing store was // allocated for that GPU plugin instance. // diff --git a/chrome/plugin/command_buffer_stub.cc b/chrome/plugin/command_buffer_stub.cc index e6f4b76..103bde3 100644 --- a/chrome/plugin/command_buffer_stub.cc +++ b/chrome/plugin/command_buffer_stub.cc @@ -86,6 +86,9 @@ void CommandBufferStub::OnInitialize(int32 size, processor_->SetSwapBuffersCallback( NewCallback(this, &CommandBufferStub::SwapBuffersCallback)); + processor_->SetTransportDIBAllocAndFree( + NewCallback(this, &CommandBufferStub::AllocTransportDIB), + NewCallback(this, &CommandBufferStub::FreeTransportDIB)); #endif buffer.shared_memory->ShareToProcess(peer_handle, ring_buffer); } else { @@ -149,13 +152,27 @@ void CommandBufferStub::OnGetTransferBuffer( #if defined(OS_MACOSX) void CommandBufferStub::OnSetWindowSize(int32 width, int32 height) { - uint64 new_backing_store = processor_->SetWindowSize(width, height); + // Try using the IOSurface version first. + uint64 new_backing_store = processor_->SetWindowSizeForIOSurface(width, + height); if (new_backing_store) { Send(new PluginHostMsg_GPUPluginSetIOSurface(plugin_host_route_id_, window_, width, height, new_backing_store)); + } else { + // If |new_backing_store| is 0, it might mean that the IOSurface APIs are + // not available. In this case, see if TransportDIBs are supported. + TransportDIB::Handle transport_dib = + processor_->SetWindowSizeForTransportDIB(width, height); + if (TransportDIB::is_valid(transport_dib)) { + Send(new PluginHostMsg_GPUPluginSetTransportDIB(plugin_host_route_id_, + window_, + width, + height, + transport_dib)); + } } } @@ -163,4 +180,16 @@ void CommandBufferStub::SwapBuffersCallback() { Send(new PluginHostMsg_GPUPluginBuffersSwapped(plugin_host_route_id_, window_)); } + +void CommandBufferStub::AllocTransportDIB(const size_t size, + TransportDIB::Handle* dib_handle) { + Send(new PluginHostMsg_AllocTransportDIB(plugin_host_route_id_, + size, + dib_handle)); +} + +void CommandBufferStub::FreeTransportDIB(TransportDIB::Id dib_id) { + Send(new PluginHostMsg_FreeTransportDIB(plugin_host_route_id_, + dib_id)); +} #endif diff --git a/chrome/plugin/command_buffer_stub.h b/chrome/plugin/command_buffer_stub.h index f0d8ac0..219aadb 100644 --- a/chrome/plugin/command_buffer_stub.h +++ b/chrome/plugin/command_buffer_stub.h @@ -9,6 +9,7 @@ #include "app/gfx/native_widget_types.h" #include "base/ref_counted.h" +#include "chrome/common/transport_dib.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/service/gpu_processor.h" @@ -52,6 +53,8 @@ class CommandBufferStub : public IPC::Channel::Listener, #if defined(OS_MACOSX) void OnSetWindowSize(int32 width, int32 height); void SwapBuffersCallback(); + void AllocTransportDIB(const size_t size, TransportDIB::Handle* dib_handle); + void FreeTransportDIB(TransportDIB::Id dib_id); #endif scoped_refptr<PluginChannel> channel_; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 2398d4c..17161e9 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -4531,6 +4531,27 @@ void RenderView::GPUPluginSetIOSurface(gfx::PluginWindowHandle window, routing_id(), window, width, height, io_surface_identifier)); } +void RenderView::GPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) { + Send(new ViewHostMsg_GPUPluginSetTransportDIB( + routing_id(), window, width, height, transport_dib)); +} + +TransportDIB::Handle RenderView::GPUPluginAllocTransportDIB(size_t size) { + TransportDIB::Handle dib_handle; + // Assume this is a synchronous RPC. + if (Send(new ViewHostMsg_AllocTransportDIB(size, &dib_handle))) + return dib_handle; + // Return an invalid handle if Send() fails. + return TransportDIB::DefaultHandleValue(); +} + +void RenderView::GPUPluginFreeTransportDIB(TransportDIB::Id dib_id) { + Send(new ViewHostMsg_FreeTransportDIB(dib_id)); +} + void RenderView::GPUPluginBuffersSwapped(gfx::PluginWindowHandle window) { Send(new ViewHostMsg_GPUPluginBuffersSwapped(routing_id(), window)); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index b6be66c..85cd503 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -29,6 +29,7 @@ #include "chrome/common/page_zoom.h" #include "chrome/common/render_messages.h" #include "chrome/common/renderer_preferences.h" +#include "chrome/common/transport_dib.h" #include "chrome/common/view_types.h" #include "chrome/renderer/automation/dom_automation_controller.h" #include "chrome/renderer/dom_ui_bindings.h" @@ -472,6 +473,12 @@ class RenderView : public RenderWidget, int32 width, int32 height, uint64 io_surface_identifier); + TransportDIB::Handle GPUPluginAllocTransportDIB(size_t size); + void GPUPluginFreeTransportDIB(TransportDIB::Id dib_id); + void GPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib); void GPUPluginBuffersSwapped(gfx::PluginWindowHandle window); #endif diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 178f07f..a743a3f 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -4,12 +4,12 @@ #include "chrome/renderer/webplugin_delegate_proxy.h" -#include <algorithm> - #if defined(OS_LINUX) #include <gtk/gtk.h> #endif +#include <algorithm> + #include "app/gfx/blit.h" #include "app/gfx/canvas.h" #include "app/gfx/native_widget_types.h" @@ -398,9 +398,16 @@ void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(PluginHostMsg_UpdateGeometry_ACK, OnUpdateGeometry_ACK) - // Used only on 10.6 and later + // Used only on 10.6 and later. IPC_MESSAGE_HANDLER(PluginHostMsg_GPUPluginSetIOSurface, OnGPUPluginSetIOSurface) + // Used on 10.5 and earlier. + IPC_MESSAGE_HANDLER(PluginHostMsg_GPUPluginSetTransportDIB, + OnGPUPluginSetTransportDIB) + IPC_MESSAGE_HANDLER(PluginHostMsg_AllocTransportDIB, + OnGPUPluginAllocTransportDIB) + IPC_MESSAGE_HANDLER(PluginHostMsg_FreeTransportDIB, + OnGPUPluginFreeTransportDIB) IPC_MESSAGE_HANDLER(PluginHostMsg_GPUPluginBuffersSwapped, OnGPUPluginBuffersSwapped) #endif @@ -503,8 +510,7 @@ void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect, // scripts the plugin to start playing while it's in the middle of handling // an update geometry message, videos don't play. See urls in bug 20260. msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); - } - else + } else // NO_LINT #endif { msg = new PluginMsg_UpdateGeometry(instance_id_, param); @@ -1325,6 +1331,31 @@ void WebPluginDelegateProxy::OnGPUPluginSetIOSurface( io_surface_identifier); } +void WebPluginDelegateProxy::OnGPUPluginSetTransportDIB( + gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib) { + if (render_view_) + render_view_->GPUPluginSetTransportDIB(window, width, height, + transport_dib); +} + +void WebPluginDelegateProxy::OnGPUPluginAllocTransportDIB( + size_t size, + TransportDIB::Handle* dib_handle) { + if (render_view_) + *dib_handle = render_view_->GPUPluginAllocTransportDIB(size); + else + *dib_handle = TransportDIB::DefaultHandleValue(); +} + +void WebPluginDelegateProxy::OnGPUPluginFreeTransportDIB( + TransportDIB::Id dib_id) { + if (render_view_) + render_view_->GPUPluginFreeTransportDIB(dib_id); +} + void WebPluginDelegateProxy::OnGPUPluginBuffersSwapped( gfx::PluginWindowHandle window) { if (render_view_) diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 98eb1ee..18d2704 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -152,6 +152,13 @@ class WebPluginDelegateProxy int32 width, int32 height, uint64 io_surface_identifier); + void OnGPUPluginSetTransportDIB(gfx::PluginWindowHandle window, + int32 width, + int32 height, + TransportDIB::Handle transport_dib); + void OnGPUPluginAllocTransportDIB(size_t size, + TransportDIB::Handle* dib_handle); + void OnGPUPluginFreeTransportDIB(TransportDIB::Id dib_id); void OnGPUPluginBuffersSwapped(gfx::PluginWindowHandle window); #endif |