diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 17:30:34 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 17:30:34 +0000 |
commit | 7e4eb9b807d18c1a24ae4c57ce6d421433499ef0 (patch) | |
tree | bb8be7d61e3ff55bfcc9b363aee9077a52d2cf47 /webkit/glue | |
parent | 3f82de6e5ce07ebdb8490fb9cbffb6a0a02ae7a7 (diff) | |
download | chromium_src-7e4eb9b807d18c1a24ae4c57ce6d421433499ef0.zip chromium_src-7e4eb9b807d18c1a24ae4c57ce6d421433499ef0.tar.gz chromium_src-7e4eb9b807d18c1a24ae4c57ce6d421433499ef0.tar.bz2 |
Add visibility tracking to the temporary Core Animation plugin timer
Disables the redraw timer for Core Animation plugins that aren't visibile; even though the timer isn't intended to be a long-term solution, this is a simple optimization for the short term.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1159003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42351 0039d316-1c4b-4281-b951-d872f2087c98
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) { |