summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/plugin_host.cc21
-rw-r--r--webkit/glue/plugins/webplugin.h17
-rw-r--r--webkit/glue/plugins/webplugin_accelerated_surface_mac.h43
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h10
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm37
-rw-r--r--webkit/glue/webkit_glue.gypi1
6 files changed, 78 insertions, 51 deletions
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index a1a6d5f..b0fe8fa 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -797,16 +797,21 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) {
rv = NPERR_NO_ERROR;
break;
}
- case NPNVsupportsCoreAnimationBool:
- case NPNVsupportsInvalidatingCoreAnimationBool: {
+ case NPNVsupportsCoreAnimationBool: {
// We only support the Core Animation model on 10.6 and higher
// TODO(stuartmorgan): Once existing CA plugins have implemented the
- // invalidating version, remove support for the other version.
+ // invalidating version, remove support for this one.
NPBool* supports_model = reinterpret_cast<NPBool*>(value);
*supports_model = SupportsSharingAcceleratedSurfaces() ? true : false;
rv = NPERR_NO_ERROR;
break;
}
+ case NPNVsupportsInvalidatingCoreAnimationBool: {
+ NPBool* supports_model = reinterpret_cast<NPBool*>(value);
+ *supports_model = true;
+ rv = NPERR_NO_ERROR;
+ break;
+ }
case NPNVsupportsOpenGLBool: {
// This drawing model was never widely supported, and we don't plan to
// support it.
@@ -871,12 +876,10 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) {
#if defined(OS_MACOSX)
case NPPVpluginDrawingModel: {
int model = reinterpret_cast<int>(value);
- if (model == NPDrawingModelCoreGraphics) {
- plugin->set_drawing_model(static_cast<NPDrawingModel>(model));
- return NPERR_NO_ERROR;
- } else if ((model == NPDrawingModelCoreAnimation ||
- model == NPDrawingModelInvalidatingCoreAnimation) &&
- SupportsSharingAcceleratedSurfaces()) {
+ if (model == NPDrawingModelCoreGraphics ||
+ model == NPDrawingModelInvalidatingCoreAnimation ||
+ (model == NPDrawingModelCoreAnimation &&
+ SupportsSharingAcceleratedSurfaces())) {
plugin->set_drawing_model(static_cast<NPDrawingModel>(model));
return NPERR_NO_ERROR;
}
diff --git a/webkit/glue/plugins/webplugin.h b/webkit/glue/plugins/webplugin.h
index 19c6cb0..1a14d545 100644
--- a/webkit/glue/plugins/webplugin.h
+++ b/webkit/glue/plugins/webplugin.h
@@ -29,6 +29,9 @@ namespace webkit_glue {
class WebPluginDelegate;
class WebPluginParentView;
class WebPluginResourceClient;
+#if defined(OS_MACOSX)
+class WebPluginAcceleratedSurface;
+#endif
// Describes the new location for a plugin window.
struct WebPluginGeometry {
@@ -151,19 +154,11 @@ class WebPlugin {
// of plug-in content. The browser generates the handle which is then set on
// the plug-in. |opaque| indicates whether the content should be treated as
// opaque or translucent.
+ // TODO(stuartmorgan): Move this into WebPluginProxy.
virtual void BindFakePluginWindowHandle(bool opaque) {}
- // Tell the browser (via the renderer) to invalidate because the
- // accelerated buffers have changed.
- virtual void AcceleratedFrameBuffersDidSwap(gfx::PluginWindowHandle window) {}
-
- // Tell the renderer and browser to associate the given plugin handle with
- // |accelerated_surface_identifier|. The geometry is used to resize any
- // native "window" (which on the Mac is a CALayer).
- virtual void SetAcceleratedSurface(gfx::PluginWindowHandle window,
- int32 width,
- int32 height,
- uint64 accelerated_surface_identifier) {}
+ // Returns the accelerated surface abstraction for accelerated plugins.
+ virtual WebPluginAcceleratedSurface* GetAcceleratedSurface() { return NULL; }
#endif
// Gets the WebPluginDelegate that implements the interface.
diff --git a/webkit/glue/plugins/webplugin_accelerated_surface_mac.h b/webkit/glue/plugins/webplugin_accelerated_surface_mac.h
new file mode 100644
index 0000000..ba3f8ca
--- /dev/null
+++ b/webkit/glue/plugins/webplugin_accelerated_surface_mac.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2006-2009 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 WEBKIT_GLUE_WEBPLUGIN_ACCELERATED_SURFACE_MAC_H_
+#define WEBKIT_GLUE_WEBPLUGIN_ACCELERATED_SURFACE_MAC_H_
+#pragma once
+
+#include "gfx/native_widget_types.h"
+#include "gfx/size.h"
+
+// Avoid having to include OpenGL headers here.
+typedef struct _CGLContextObject* CGLContextObj;
+
+namespace webkit_glue {
+
+// Interface class for interacting with an accelerated plugin surface, used
+// for the Core Animation flavors of plugin drawing on the Mac.
+class WebPluginAcceleratedSurface {
+ public:
+ virtual ~WebPluginAcceleratedSurface() {}
+
+ // Sets the window handle used throughout the browser to identify this
+ // surface.
+ virtual void SetWindowHandle(gfx::PluginWindowHandle window) = 0;
+
+ // Sets the size of the surface.
+ virtual void SetSize(const gfx::Size& size) = 0;
+
+ // Returns the context used to draw into this surface.
+ virtual CGLContextObj context() = 0;
+
+ // Readies the surface for drawing. Must be called before any drawing session.
+ virtual void StartDrawing() = 0;
+
+ // Ends a drawing session. Changes to the surface may not be reflected until
+ // this is called.
+ virtual void EndDrawing() = 0;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBPLUGIN_ACCELERATED_SURFACE_MAC_H_
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 650d398..55381f9 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -11,6 +11,7 @@
#include <list>
#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
#include "base/task.h"
#include "base/time.h"
#include "base/timer.h"
@@ -20,10 +21,6 @@
#include "webkit/glue/plugins/webplugin_delegate.h"
#include "webkit/glue/webcursor.h"
-#if defined(OS_MACOSX)
-#include "app/surface/accelerated_surface_mac.h"
-#endif
-
#if defined(USE_X11)
#include "app/x11_util.h"
@@ -52,6 +49,9 @@ class QuickDrawDrawingManager;
class CALayer;
class CARenderer;
#endif
+namespace webkit_glue {
+class WebPluginAcceleratedSurface;
+}
#endif
// An implementation of WebPluginDelegate that runs in the plugin process,
@@ -432,7 +432,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
#endif
CALayer* layer_; // Used for CA drawing mode. Weak, retained by plug-in.
- AcceleratedSurface* surface_;
+ webkit_glue::WebPluginAcceleratedSurface* surface_; // Weak ref.
CARenderer* renderer_; // Renders layer_ to surface_.
scoped_ptr<base::RepeatingTimer<WebPluginDelegateImpl> > redraw_timer_;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 614f1d2..e048eaf 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -24,6 +24,7 @@
#include "webkit/glue/plugins/plugin_stream_url.h"
#include "webkit/glue/plugins/plugin_web_event_converter_mac.h"
#include "webkit/glue/plugins/webplugin.h"
+#include "webkit/glue/plugins/webplugin_accelerated_surface_mac.h"
#include "webkit/glue/webkit_glue.h"
#ifndef NP_NO_CARBON
@@ -359,9 +360,9 @@ bool WebPluginDelegateImpl::PlatformInitialize() {
if (instance()->event_model() != NPEventModelCocoa)
return false;
window_.type = NPWindowTypeDrawable;
- // Ask the plug-in for the CALayer it created for rendering content. Have
- // the renderer tell the browser to create a "windowed plugin" to host
- // the IOSurface.
+ // Ask the plug-in for the CALayer it created for rendering content.
+ // Create a surface to host it, and request a "window" handle to identify
+ // the surface.
CALayer* layer = nil;
NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer,
reinterpret_cast<void*>(&layer));
@@ -371,8 +372,8 @@ bool WebPluginDelegateImpl::PlatformInitialize() {
redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>);
}
layer_ = layer;
- surface_ = new AcceleratedSurface;
- surface_->Initialize(NULL, true);
+ surface_ = plugin_->GetAcceleratedSurface();
+
renderer_ = [[CARenderer rendererWithCGLContext:surface_->context()
options:NULL] retain];
[renderer_ setLayer:layer_];
@@ -421,11 +422,6 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() {
[renderer_ release];
renderer_ = nil;
layer_ = nil;
- if (surface_) {
- surface_->Destroy();
- delete surface_;
- surface_ = NULL;
- }
}
void WebPluginDelegateImpl::UpdateGeometryAndContext(
@@ -948,9 +944,7 @@ void WebPluginDelegateImpl::DrawLayerInSurface() {
if (!windowed_handle())
return;
- surface_->MakeCurrent();
-
- surface_->Clear(window_rect_);
+ surface_->StartDrawing();
[renderer_ beginFrameAtTime:CACurrentMediaTime() timeStamp:NULL];
if (CGRectIsEmpty([renderer_ updateBounds])) {
@@ -963,13 +957,10 @@ void WebPluginDelegateImpl::DrawLayerInSurface() {
[renderer_ render];
[renderer_ endFrame];
- surface_->SwapBuffers();
- plugin_->AcceleratedFrameBuffersDidSwap(windowed_handle());
+ surface_->EndDrawing();
}
-// Update the size of the IOSurface to match the current size of the plug-in,
-// then tell the browser host view so it can adjust its bookkeeping and CALayer
-// appropriately.
+// Update the size of the surface to match the current size of the plug-in.
void WebPluginDelegateImpl::UpdateAcceleratedSurface() {
// Will only have a window handle when using a Core Animation drawing model.
if (!windowed_handle() || !layer_)
@@ -978,19 +969,13 @@ void WebPluginDelegateImpl::UpdateAcceleratedSurface() {
[layer_ setFrame:CGRectMake(0, 0,
window_rect_.width(), window_rect_.height())];
[renderer_ setBounds:[layer_ bounds]];
-
- uint64 io_surface_id = surface_->SetSurfaceSize(window_rect_.size());
- if (io_surface_id) {
- plugin_->SetAcceleratedSurface(windowed_handle(),
- window_rect_.width(),
- window_rect_.height(),
- io_surface_id);
- }
+ surface_->SetSize(window_rect_.size());
}
void WebPluginDelegateImpl::set_windowed_handle(
gfx::PluginWindowHandle handle) {
windowed_handle_ = handle;
+ surface_->SetWindowHandle(handle);
UpdateAcceleratedSurface();
// Kick off the drawing timer, if necessary.
PluginVisibilityChanged();
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index f5d03c4..80e53c8 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -288,6 +288,7 @@
'plugins/webplugin.h',
'plugins/webplugin_2d_device_delegate.h',
'plugins/webplugin_3d_device_delegate.h',
+ 'plugins/webplugin_accelerated_surface_mac.h',
'plugins/webplugin_delegate.h',
'plugins/webplugin_delegate_impl.cc',
'plugins/webplugin_delegate_impl.h',