diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 21:22:44 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 21:22:44 +0000 |
commit | 327c709e1c8ae25359382ae2d392d73d381d4a4f (patch) | |
tree | 315ce94deb5342e9ae58e631e08f7961a292bd8d /webkit/glue | |
parent | 5453442a6b1f679e45f012ff9dec78f615f37258 (diff) | |
download | chromium_src-327c709e1c8ae25359382ae2d392d73d381d4a4f.zip chromium_src-327c709e1c8ae25359382ae2d392d73d381d4a4f.tar.gz chromium_src-327c709e1c8ae25359382ae2d392d73d381d4a4f.tar.bz2 |
Call UpdateAcceleratedSurface only when necessary for Core Animation plugins
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/828002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 12 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 19 |
2 files changed, 15 insertions, 16 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index d8bb88c..81e6874 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -162,12 +162,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Informs the delegate that the plugin set a Cocoa NSCursor. void SetNSCursor(NSCursor* cursor); - // Informs the browser about the updated accelerated drawing surface. - void UpdateAcceleratedSurface(); - - // Uses a CARenderer to draw the plug-in's layer in our OpenGL surface. - void DrawLayerInSurface(); - #ifndef NP_NO_CARBON // Indicates that it's time to send the plugin a null event. void FireIdleEvent(); @@ -380,6 +374,12 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Updates everything that depends on the plugin's absolute screen location. void PluginScreenLocationChanged(); + // Informs the browser about the updated accelerated drawing surface. + void UpdateAcceleratedSurface(); + + // Uses a CARenderer to draw the plug-in's layer in our OpenGL surface. + void DrawLayerInSurface(); + #ifndef NP_NO_CARBON // Moves our dummy window to match the current screen location of the plugin. void UpdateDummyWindowBounds(const gfx::Point& plugin_origin); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 0a2f963..7ff1182 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -268,8 +268,7 @@ void WebPluginDelegateImpl::PlatformInitialize() { 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. The surface itself will be created when the plug-in - // is sized. + // the IOSurface. CALayer* layer = nil; NPError err = instance()->NPP_GetValue(NPPVpluginCoreAnimationLayer, reinterpret_cast<void*>(&layer)); @@ -278,10 +277,10 @@ void WebPluginDelegateImpl::PlatformInitialize() { plugin_->BindFakePluginWindowHandle(); surface_ = new AcceleratedSurface; surface_->Initialize(); - UpdateAcceleratedSurface(); renderer_ = [[CARenderer rendererWithCGLContext:surface_->context() options:NULL] retain]; [renderer_ setLayer:layer_]; + UpdateAcceleratedSurface(); redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>); redraw_timer_->Start( base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs), @@ -526,8 +525,6 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) { SetWindowHasFocus(initial_window_focus_); } - UpdateAcceleratedSurface(); - DCHECK(err == NPERR_NO_ERROR); } @@ -650,10 +647,9 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) { } } -// Generate an IOSurface for accelerated drawing (but only in the case where a -// window handle has been set). Once the surface has been updated for the -// current size of the plug-in, tell the browser host view so it can adjust its -// bookkeeping and CALayer appropriately. +// 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. void WebPluginDelegateImpl::UpdateAcceleratedSurface() { // Will only have a window handle when using the CoreAnimation drawing model. if (!windowed_handle() || @@ -693,9 +689,12 @@ void WebPluginDelegateImpl::SetNSCursor(NSCursor* cursor) { } void WebPluginDelegateImpl::SetPluginRect(const gfx::Rect& rect) { + bool plugin_size_changed = rect.width() != window_rect_.width() || + rect.height() != window_rect_.height(); window_rect_ = rect; - UpdateAcceleratedSurface(); PluginScreenLocationChanged(); + if (plugin_size_changed) + UpdateAcceleratedSurface(); } void WebPluginDelegateImpl::SetContentAreaOrigin(const gfx::Point& origin) { |