summaryrefslogtreecommitdiffstats
path: root/content/plugin
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 04:42:21 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 04:42:21 +0000
commitdc51d1ccc18135493f01464e38ed462825ae8e35 (patch)
tree2da87df4b40a6b8d413c7c94af91b1900952b9e0 /content/plugin
parent11a7c5374fc1a712ca52d012fffc26fc10dd3d93 (diff)
downloadchromium_src-dc51d1ccc18135493f01464e38ed462825ae8e35.zip
chromium_src-dc51d1ccc18135493f01464e38ed462825ae8e35.tar.gz
chromium_src-dc51d1ccc18135493f01464e38ed462825ae8e35.tar.bz2
Render Core Animation plugins through WebKit's compositor rather than
directly to the screen in the browser process. The new composited code path is now the default, though the old code path has been left in place under a command line flag while we gain confidence. Issue 105344 has been filed about removing the old code path. The new code path does not currently support 10.5. The consequence is that plugins using the InvalidatingCoreAnimation rendering model will not work on this version of Mac OS. Pepper 3D is not affected; it now uses a different rendering path. Changed the type of IOSurfaces' IDs from uint64 to uint32 in a few places throughout the code to match the IOSurfaceID typedef in the system header. This was necessary in order to simplify integration with Chrome's OpenGL code. There is a known problem in the new code path with garbage occasionally being drawn to the plugin's area during live resizing of Core Animation plugins. Issue 105346 has been filed to track this. It is unclear whether the additional complexity of the fix that is likely needed is worth it. Tested manually with the following content, with and without the --disable-composited-core-animation-plugins flag: - YouTube (does not trigger this code path) - Google+ Hangouts - http://unity3d.com/gallery/demos/live-demos (Unity 3D) - http://www.erain.com/labs/molehill/ (Stage 3D in Flash 11) - http://www.nissan-stagejuk3d.com/ (Stage 3D in Flash 11, live resizing; web site is flaky, sometimes fails to start) BUG=38967 TEST=manual testing with above test cases Review URL: http://codereview.chromium.org/8678037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/plugin')
-rw-r--r--content/plugin/webplugin_accelerated_surface_proxy_mac.cc86
-rw-r--r--content/plugin/webplugin_accelerated_surface_proxy_mac.h15
-rw-r--r--content/plugin/webplugin_proxy.cc20
-rw-r--r--content/plugin/webplugin_proxy.h21
4 files changed, 111 insertions, 31 deletions
diff --git a/content/plugin/webplugin_accelerated_surface_proxy_mac.cc b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
index 9573a27..65749f0 100644
--- a/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
+++ b/content/plugin/webplugin_accelerated_surface_proxy_mac.cc
@@ -7,30 +7,53 @@
#include "content/plugin/webplugin_accelerated_surface_proxy_mac.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "content/plugin/webplugin_proxy.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/gfx/surface/accelerated_surface_mac.h"
+#include "ui/gfx/surface/io_surface_support_mac.h"
#include "ui/gfx/surface/transport_dib.h"
-WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy(
+WebPluginAcceleratedSurfaceProxy* WebPluginAcceleratedSurfaceProxy::Create(
WebPluginProxy* plugin_proxy,
- gfx::GpuPreference gpu_preference)
- : plugin_proxy_(plugin_proxy),
- window_handle_(NULL) {
- surface_ = new AcceleratedSurface;
- // It's possible for OpenGL to fail to initialze (e.g., if an incompatible
+ gfx::GpuPreference gpu_preference) {
+ bool composited = !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableCompositedCoreAnimationPlugins);
+
+ // Require IOSurface support for drawing Core Animation plugins.
+ if (composited && !IOSurfaceSupport::Initialize())
+ return NULL;
+
+ AcceleratedSurface* surface = new AcceleratedSurface;
+ // It's possible for OpenGL to fail to initialize (e.g., if an incompatible
// mode is forced via flags), so handle that gracefully.
- if (!surface_->Initialize(NULL, true, gpu_preference)) {
- delete surface_;
- surface_ = NULL;
- return;
+ if (!surface->Initialize(NULL, true, gpu_preference)) {
+ delete surface;
+ surface = NULL;
+ if (composited)
+ return NULL;
+ }
+
+ if (!composited && surface) {
+ // Only used for 10.5 support, but harmless on 10.6+.
+ surface->SetTransportDIBAllocAndFree(
+ base::Bind(&WebPluginProxy::AllocSurfaceDIB,
+ base::Unretained(plugin_proxy)),
+ base::Bind(&WebPluginProxy::FreeSurfaceDIB,
+ base::Unretained(plugin_proxy)));
}
- // Only used for 10.5 support, but harmless on 10.6+.
- surface_->SetTransportDIBAllocAndFree(
- base::Bind(&WebPluginProxy::AllocSurfaceDIB,
- base::Unretained(plugin_proxy)),
- base::Bind(&WebPluginProxy::FreeSurfaceDIB,
- base::Unretained(plugin_proxy)));
+ return new WebPluginAcceleratedSurfaceProxy(
+ plugin_proxy, surface, composited);
+}
+
+WebPluginAcceleratedSurfaceProxy::WebPluginAcceleratedSurfaceProxy(
+ WebPluginProxy* plugin_proxy,
+ AcceleratedSurface* surface,
+ bool composited)
+ : plugin_proxy_(plugin_proxy),
+ surface_(surface),
+ composited_(composited) {
}
WebPluginAcceleratedSurfaceProxy::~WebPluginAcceleratedSurfaceProxy() {
@@ -46,17 +69,28 @@ void WebPluginAcceleratedSurfaceProxy::SetWindowHandle(
window_handle_ = window;
}
+bool WebPluginAcceleratedSurfaceProxy::IsComposited() {
+ return composited_;
+}
+
void WebPluginAcceleratedSurfaceProxy::SetSize(const gfx::Size& size) {
if (!surface_)
return;
- uint64 io_surface_id = surface_->SetSurfaceSize(size);
- if (io_surface_id) {
- plugin_proxy_->SetAcceleratedSurface(window_handle_, size, io_surface_id);
+ if (composited_) {
+ uint32 io_surface_id = surface_->SetSurfaceSize(size);
+ // If allocation fails for some reason, still inform the plugin proxy.
+ plugin_proxy_->AcceleratedPluginAllocatedIOSurface(
+ size.width(), size.height(), io_surface_id);
} else {
- TransportDIB::Handle transport_dib = surface_->SetTransportDIBSize(size);
- if (TransportDIB::is_valid_handle(transport_dib)) {
- plugin_proxy_->SetAcceleratedDIB(window_handle_, size, transport_dib);
+ uint32 io_surface_id = surface_->SetSurfaceSize(size);
+ if (io_surface_id) {
+ plugin_proxy_->SetAcceleratedSurface(window_handle_, size, io_surface_id);
+ } else {
+ TransportDIB::Handle transport_dib = surface_->SetTransportDIBSize(size);
+ if (TransportDIB::is_valid_handle(transport_dib)) {
+ plugin_proxy_->SetAcceleratedDIB(window_handle_, size, transport_dib);
+ }
}
}
}
@@ -78,6 +112,10 @@ void WebPluginAcceleratedSurfaceProxy::EndDrawing() {
return;
surface_->SwapBuffers();
- plugin_proxy_->AcceleratedFrameBuffersDidSwap(
- window_handle_, surface_->GetSurfaceId());
+ if (composited_) {
+ plugin_proxy_->AcceleratedPluginSwappedIOSurface();
+ } else {
+ plugin_proxy_->AcceleratedFrameBuffersDidSwap(
+ window_handle_, surface_->GetSurfaceId());
+ }
}
diff --git a/content/plugin/webplugin_accelerated_surface_proxy_mac.h b/content/plugin/webplugin_accelerated_surface_proxy_mac.h
index f0290ba..6abf39f 100644
--- a/content/plugin/webplugin_accelerated_surface_proxy_mac.h
+++ b/content/plugin/webplugin_accelerated_surface_proxy_mac.h
@@ -19,22 +19,31 @@ class WebPluginAcceleratedSurfaceProxy
: public webkit::npapi::WebPluginAcceleratedSurface {
public:
// Creates a new WebPluginAcceleratedSurfaceProxy that uses plugin_proxy
- // to proxy calls. plugin_proxy must outlive this object.
- WebPluginAcceleratedSurfaceProxy(WebPluginProxy* plugin_proxy,
- gfx::GpuPreference gpu_preference);
+ // to proxy calls. plugin_proxy must outlive this object. Returns NULL if
+ // initialization fails.
+ static WebPluginAcceleratedSurfaceProxy* Create(
+ WebPluginProxy* plugin_proxy,
+ gfx::GpuPreference gpu_preference);
+
virtual ~WebPluginAcceleratedSurfaceProxy();
// WebPluginAcceleratedSurface implementation.
virtual void SetWindowHandle(gfx::PluginWindowHandle window) OVERRIDE;
+ virtual bool IsComposited() OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual CGLContextObj context() OVERRIDE;
virtual void StartDrawing() OVERRIDE;
virtual void EndDrawing() OVERRIDE;
private:
+ WebPluginAcceleratedSurfaceProxy(WebPluginProxy* plugin_proxy,
+ AcceleratedSurface* surface,
+ bool composited);
+
WebPluginProxy* plugin_proxy_; // Weak ref.
gfx::PluginWindowHandle window_handle_;
AcceleratedSurface* surface_;
+ bool composited_;
DISALLOW_COPY_AND_ASSIGN(WebPluginAcceleratedSurfaceProxy);
};
diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc
index bd4a36d..5b0ac6d 100644
--- a/content/plugin/webplugin_proxy.cc
+++ b/content/plugin/webplugin_proxy.cc
@@ -674,8 +674,8 @@ void WebPluginProxy::BindFakePluginWindowHandle(bool opaque) {
WebPluginAcceleratedSurface* WebPluginProxy::GetAcceleratedSurface(
gfx::GpuPreference gpu_preference) {
if (!accelerated_surface_.get())
- accelerated_surface_.reset(new WebPluginAcceleratedSurfaceProxy(
- this, gpu_preference));
+ accelerated_surface_.reset(
+ WebPluginAcceleratedSurfaceProxy::Create(this, gpu_preference));
return accelerated_surface_.get();
}
@@ -710,6 +710,22 @@ void WebPluginProxy::AllocSurfaceDIB(const size_t size,
void WebPluginProxy::FreeSurfaceDIB(TransportDIB::Id dib_id) {
Send(new PluginHostMsg_FreeTransportDIB(route_id_, dib_id));
}
+
+void WebPluginProxy::AcceleratedPluginEnabledRendering() {
+ Send(new PluginHostMsg_AcceleratedPluginEnabledRendering(route_id_));
+}
+
+void WebPluginProxy::AcceleratedPluginAllocatedIOSurface(int32 width,
+ int32 height,
+ uint32 surface_id) {
+ Send(new PluginHostMsg_AcceleratedPluginAllocatedIOSurface(
+ route_id_, width, height, surface_id));
+}
+
+void WebPluginProxy::AcceleratedPluginSwappedIOSurface() {
+ Send(new PluginHostMsg_AcceleratedPluginSwappedIOSurface(
+ route_id_));
+}
#endif
void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) {
diff --git a/content/plugin/webplugin_proxy.h b/content/plugin/webplugin_proxy.h
index ddd32fa..2c44c94 100644
--- a/content/plugin/webplugin_proxy.h
+++ b/content/plugin/webplugin_proxy.h
@@ -136,11 +136,14 @@ class WebPluginProxy : public webkit::npapi::WebPlugin {
virtual void StartIme() OVERRIDE;
- virtual void BindFakePluginWindowHandle(bool opaque) OVERRIDE;
-
virtual webkit::npapi::WebPluginAcceleratedSurface*
GetAcceleratedSurface(gfx::GpuPreference gpu_preference) OVERRIDE;
+ //----------------------------------------------------------------------
+ // Legacy Core Animation plugin implementation rendering directly to screen.
+
+ virtual void BindFakePluginWindowHandle(bool opaque) OVERRIDE;
+
// Tell the browser (via the renderer) to invalidate because the
// accelerated buffers have changed.
virtual void AcceleratedFrameBuffersDidSwap(
@@ -168,6 +171,20 @@ class WebPluginProxy : public webkit::npapi::WebPlugin {
virtual void AllocSurfaceDIB(const size_t size,
TransportDIB::Handle* dib_handle);
virtual void FreeSurfaceDIB(TransportDIB::Id dib_id);
+
+ //----------------------------------------------------------------------
+ // New accelerated plugin implementation which renders via the compositor.
+
+ // Tells the renderer, and from there the GPU process, that the plugin
+ // is using accelerated rather than software rendering.
+ virtual void AcceleratedPluginEnabledRendering() OVERRIDE;
+
+ // Tells the renderer, and from there the GPU process, that the plugin
+ // allocated the given IOSurface to be used as its backing store.
+ virtual void AcceleratedPluginAllocatedIOSurface(int32 width,
+ int32 height,
+ uint32 surface_id) OVERRIDE;
+ virtual void AcceleratedPluginSwappedIOSurface() OVERRIDE;
#endif
virtual void URLRedirectResponse(bool allow, int resource_id) OVERRIDE;