diff options
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 2 | ||||
-rw-r--r-- | third_party/npapi/bindings/npapi.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 8 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 25 |
5 files changed, 31 insertions, 11 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 9ff6224..3bf1332 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -112,6 +112,8 @@ void WebPluginProxy::Invalidate() { void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { #if defined(OS_MACOSX) + delegate_->PluginDidInvalidate(); + // Some plugins will send invalidates larger than their own rect when // offscreen, so constrain invalidates to the plugin rect. gfx::Rect plugin_rect = delegate_->GetRect(); diff --git a/third_party/npapi/bindings/npapi.h b/third_party/npapi/bindings/npapi.h index 2f4c755..6878dc8 100644 --- a/third_party/npapi/bindings/npapi.h +++ b/third_party/npapi/bindings/npapi.h @@ -312,7 +312,8 @@ typedef enum { #endif NPDrawingModelCoreGraphics = 1, NPDrawingModelOpenGL = 2, - NPDrawingModelCoreAnimation = 3 + NPDrawingModelCoreAnimation = 3, + NPDrawingModelInvalidatingCoreAnimation = 4 } NPDrawingModel; typedef enum { @@ -447,6 +448,7 @@ typedef enum { , NPNVsupportsCoreGraphicsBool = 2001 , NPNVsupportsOpenGLBool = 2002 , NPNVsupportsCoreAnimationBool = 2003 + , NPNVsupportsInvalidatingCoreAnimationBool = 2004 #ifndef NP_NO_CARBON , NPNVsupportsCarbonBool = 3000 /* TRUE if the browser supports the Carbon event model */ #endif diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index f78efd1..02e4af9 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -778,8 +778,11 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { rv = NPERR_NO_ERROR; break; } - case NPNVsupportsCoreAnimationBool: { + case NPNVsupportsCoreAnimationBool: + case NPNVsupportsInvalidatingCoreAnimationBool: { // 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. NPBool* supports_model = reinterpret_cast<NPBool*>(value); *supports_model = SupportsSharingAcceleratedSurfaces() ? true : false; rv = NPERR_NO_ERROR; @@ -852,7 +855,8 @@ NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { if (model == NPDrawingModelCoreGraphics) { plugin->set_drawing_model(static_cast<NPDrawingModel>(model)); return NPERR_NO_ERROR; - } else if (model == NPDrawingModelCoreAnimation && + } else if ((model == NPDrawingModelCoreAnimation || + model == NPDrawingModelInvalidatingCoreAnimation) && SupportsSharingAcceleratedSurfaces()) { plugin->set_drawing_model(static_cast<NPDrawingModel>(model)); return NPERR_NO_ERROR; diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index e624e6f..a173b45 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -140,6 +140,9 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { void UpdateGeometryAndContext(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, gfx::NativeDrawingContext context); + // Informs the delegate that the plugin called NPN_Invalidate*. Used as a + // trigger for Core Animation drawing. + void PluginDidInvalidate(); // Returns the delegate currently processing events. static WebPluginDelegateImpl* GetActiveDelegate(); // Informs the plugin that the window it is in has gained or lost focus. diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index ee40ceb..9664534 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -333,7 +333,8 @@ bool WebPluginDelegateImpl::PlatformInitialize() { } #endif - switch (instance()->drawing_model()) { + NPDrawingModel drawing_model = instance()->drawing_model(); + switch (drawing_model) { #ifndef NP_NO_QUICKDRAW case NPDrawingModelQuickDraw: if (instance()->event_model() != NPEventModelCarbon) @@ -353,7 +354,8 @@ bool WebPluginDelegateImpl::PlatformInitialize() { #endif window_.type = NPWindowTypeDrawable; break; - case NPDrawingModelCoreAnimation: { + case NPDrawingModelCoreAnimation: + case NPDrawingModelInvalidatingCoreAnimation: { if (instance()->event_model() != NPEventModelCocoa) return false; window_.type = NPWindowTypeDrawable; @@ -364,8 +366,10 @@ bool WebPluginDelegateImpl::PlatformInitialize() { NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer, reinterpret_cast<void*>(&layer)); if (!err) { - // Create the timer; it will be started when we get a window handle. - redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); + if (drawing_model == NPDrawingModelCoreAnimation) { + // Create the timer; it will be started when we get a window handle. + redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); + } layer_ = layer; surface_ = new AcceleratedSurface; surface_->Initialize(NULL, true); @@ -390,7 +394,8 @@ bool WebPluginDelegateImpl::PlatformInitialize() { // Let the WebPlugin know that we are windowless (unless this is a // Core Animation plugin, in which case BindFakePluginWindowHandle will take // care of setting up the appropriate window handle). - if (instance()->drawing_model() != NPDrawingModelCoreAnimation) + if (drawing_model != NPDrawingModelCoreAnimation || + drawing_model != NPDrawingModelInvalidatingCoreAnimation) plugin_->SetWindow(NULL); #ifndef NP_NO_CARBON @@ -791,6 +796,11 @@ void WebPluginDelegateImpl::WindowedSetWindow() { #pragma mark - #pragma mark Mac Extensions +void WebPluginDelegateImpl::PluginDidInvalidate() { + if (instance()->drawing_model() == NPDrawingModelInvalidatingCoreAnimation) + DrawLayerInSurface(); +} + WebPluginDelegateImpl* WebPluginDelegateImpl::GetActiveDelegate() { return g_active_delegate; } @@ -999,9 +1009,8 @@ void WebPluginDelegateImpl::DrawLayerInSurface() { // then tell the browser host view so it can adjust its bookkeeping and CALayer // appropriately. void WebPluginDelegateImpl::UpdateAcceleratedSurface() { - // Will only have a window handle when using the CoreAnimation drawing model. - if (!windowed_handle() || - instance()->drawing_model() != NPDrawingModelCoreAnimation) + // Will only have a window handle when using a Core Animation drawing model. + if (!windowed_handle() || !layer_) return; [layer_ setFrame:CGRectMake(0, 0, |