Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: webkit/glue/plugins/webplugin_delegate_impl_mac.mm

Issue 1745018: Clean up initial CA layer setup for Mac Plugins (Closed)
Patch Set: Tweak initialization order a bit more Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/plugins/webplugin_delegate_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/webplugin_delegate_impl_mac.mm
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 09ee22b65cf8fc310058b3ac815111eb6a019092..c61ed22c354e1b4508ca914c590169443b4a92af 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
« no previous file with comments | « webkit/glue/plugins/webplugin_delegate_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698