diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 35 |
2 files changed, 25 insertions, 13 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index e72bb825..e87522c 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -377,6 +377,9 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Informs the browser about the updated accelerated drawing surface. void UpdateAcceleratedSurface(); + // Updates anything that depends on plugin visibility. + void PluginVisibilityChanged(); + // Uses a CARenderer to draw the plug-in's layer in our OpenGL surface. void DrawLayerInSurface(); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 08995ee..b789dda9 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -283,10 +283,8 @@ void WebPluginDelegateImpl::PlatformInitialize() { [renderer_ setLayer:layer_]; UpdateAcceleratedSurface(); redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); - redraw_timer_->Start( - base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), - this, - &WebPluginDelegateImpl::DrawLayerInSurface); + // This will start the timer, but only if we are visible. + PluginVisibilityChanged(); } break; } @@ -416,13 +414,10 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry( if (window_rect == window_rect_ && old_clip_was_empty == new_clip_is_empty) return; -#ifndef NP_NO_CARBON // If visibility has changed, switch our idle event rate. - if (instance()->event_model() == NPEventModelCarbon && - old_clip_was_empty != new_clip_is_empty) { - UpdateIdleEventRate(); + if (old_clip_was_empty != new_clip_is_empty) { + PluginVisibilityChanged(); } -#endif SetPluginRect(window_rect); WindowlessSetWindow(true); @@ -639,10 +634,7 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) { // off screen (i.e., cached_clip_rect_ is empty), then container visibility // doesn't change anything. if (!cached_clip_rect_.IsEmpty()) { -#ifndef NP_NO_CARBON - if (instance() && instance()->event_model() == NPEventModelCarbon) - UpdateIdleEventRate(); -#endif + PluginVisibilityChanged(); WindowlessSetWindow(true); } } @@ -714,6 +706,23 @@ void WebPluginDelegateImpl::PluginScreenLocationChanged() { #endif } +void WebPluginDelegateImpl::PluginVisibilityChanged() { +#ifndef NP_NO_CARBON + if (instance()->event_model() == NPEventModelCarbon) + UpdateIdleEventRate(); +#endif + if (instance()->drawing_model() == NPDrawingModelCoreAnimation) { + bool plugin_visible = container_is_visible_ && !clip_rect_.IsEmpty(); + if (plugin_visible && !redraw_timer_->IsRunning()) { + redraw_timer_->Start( + base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), + this, &WebPluginDelegateImpl::DrawLayerInSurface); + } else if (!plugin_visible) { + redraw_timer_->Stop(); + } + } +} + #ifndef NP_NO_CARBON void WebPluginDelegateImpl::UpdateDummyWindowBounds( const gfx::Point& plugin_origin) { |