summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:56:42 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:56:42 +0000
commit4736973b985277ca6a77f4cfc45482937cef90e4 (patch)
treee2a9852c7a107ba85799c37d12545ce10000c940 /webkit/glue/plugins
parent546b044cd3922985803c1609faa9ccb27418e27d (diff)
downloadchromium_src-4736973b985277ca6a77f4cfc45482937cef90e4.zip
chromium_src-4736973b985277ca6a77f4cfc45482937cef90e4.tar.gz
chromium_src-4736973b985277ca6a77f4cfc45482937cef90e4.tar.bz2
Clean up initial CA layer setup for Mac Plugins
UpdateAcceleratedSurface and DrawLayerInSurface don't make sense before windowed_handle has been set, so tweak the way we handle initialization of CA plugins. BUG=none TEST=CA plugins should still work Review URL: http://codereview.chromium.org/1745018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h5
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm22
2 files changed, 17 insertions, 10 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index f57755e..6cf7c7b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -180,10 +180,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
#if defined(OS_MACOSX)
// Allow setting a "fake" window handle to associate this plug-in with
// an IOSurface in the browser. Used for accelerated drawing surfaces.
- void set_windowed_handle(gfx::PluginWindowHandle handle) {
- windowed_handle_ = handle;
- UpdateAcceleratedSurface();
- }
+ void set_windowed_handle(gfx::PluginWindowHandle handle);
#endif
private:
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 09ee22b..c61ed22 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -372,17 +372,15 @@ 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>);
layer_ = layer;
- plugin_->BindFakePluginWindowHandle(false);
surface_ = new AcceleratedSurface;
surface_->Initialize(NULL, true);
renderer_ = [[CARenderer rendererWithCGLContext:surface_->context()
options:NULL] retain];
[renderer_ setLayer:layer_];
- UpdateAcceleratedSurface();
- redraw_timer_.reset(new base::RepeatingTimer<WebPluginDelegateImpl>);
- // This will start the timer, but only if we are visible.
- PluginVisibilityChanged();
+ plugin_->BindFakePluginWindowHandle(false);
}
break;
}
@@ -979,7 +977,7 @@ void WebPluginDelegateImpl::PluginVisibilityChanged() {
#endif
if (instance()->drawing_model() == NPDrawingModelCoreAnimation) {
bool plugin_visible = container_is_visible_ && !clip_rect_.IsEmpty();
- if (plugin_visible && !redraw_timer_->IsRunning()) {
+ if (plugin_visible && !redraw_timer_->IsRunning() && windowed_handle()) {
redraw_timer_->Start(
base::TimeDelta::FromMilliseconds(kCoreAnimationRedrawPeriodMs),
this, &WebPluginDelegateImpl::DrawLayerInSurface);
@@ -993,6 +991,10 @@ void WebPluginDelegateImpl::PluginVisibilityChanged() {
#pragma mark Core Animation Support
void WebPluginDelegateImpl::DrawLayerInSurface() {
+ // If we haven't plumbed up the surface yet, don't try to draw.
+ if (!windowed_handle())
+ return;
+
surface_->MakeCurrent();
surface_->Clear(window_rect_);
@@ -1029,6 +1031,14 @@ void WebPluginDelegateImpl::UpdateAcceleratedSurface() {
}
}
+void WebPluginDelegateImpl::set_windowed_handle(
+ gfx::PluginWindowHandle handle) {
+ windowed_handle_ = handle;
+ UpdateAcceleratedSurface();
+ // Kick off the drawing timer, if necessary.
+ PluginVisibilityChanged();
+}
+
#pragma mark -
#pragma mark Carbon Event support