diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 16:05:49 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 16:05:49 +0000 |
commit | 6ede010a1f12dacd0eb790f6e94942c09aef9166 (patch) | |
tree | 634881be29bb877a1889170c6936413d001a66dd | |
parent | a0949a47eb937d208779d0894170eaa5c5e07257 (diff) | |
download | chromium_src-6ede010a1f12dacd0eb790f6e94942c09aef9166.zip chromium_src-6ede010a1f12dacd0eb790f6e94942c09aef9166.tar.gz chromium_src-6ede010a1f12dacd0eb790f6e94942c09aef9166.tar.bz2 |
Mac: Re-fix hidden CoreAnimation plugins.
Stuart fixed this in http://codereview.chromium.org/2147002 and I regressed it in http://codereview.chromium.org/3010054
Note that the reduced testcase on the bug is still broken. Since it's broken in Safari too, that's a WebKit problem.
BUG=52914,51748
TEST=See bug
Review URL: http://codereview.chromium.org/3125033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57061 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 74 insertions, 39 deletions
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc index 92727f0..fdba6ea 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc @@ -19,7 +19,9 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( height_(0), texture_(0), texture_needs_upload_(true), - texture_pending_deletion_(0) { + texture_pending_deletion_(0), + visible_(false), + was_painted_to_(false) { } AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { @@ -62,11 +64,8 @@ void AcceleratedSurfaceContainerMac::SetSizeAndTransportDIB( void AcceleratedSurfaceContainerMac::SetGeometry( const webkit_glue::WebPluginGeometry& geom) { - // TODO(kbr): may need to pay attention to cutout rects. - if (geom.visible) - clipRect_ = geom.clip_rect; - else - clipRect_ = gfx::Rect(); + visible_ = geom.visible; + clipRect_ = geom.clip_rect; } void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_mac.h index b7a6883..b0b6051 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.h +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.h @@ -75,6 +75,11 @@ class AcceleratedSurfaceContainerMac { // time the drawing context has changed. void ForceTextureReload() { texture_needs_upload_ = true; } + // Notifies the surface that it was painted to. + void set_was_painted_to() { was_painted_to_ = true; } + + // Returns if the surface should be shown. + bool should_be_visible() const { return visible_ && was_painted_to_; } private: // The manager of this accelerated surface container. AcceleratedSurfaceContainerManagerMac* manager_; @@ -114,6 +119,13 @@ class AcceleratedSurfaceContainerMac { // resized, for example. GLuint texture_pending_deletion_; + // Stores if the plugin has a visible state. + bool visible_; + + // Stores if the plugin's IOSurface has been swapped before. Used to not show + // it before it hasn't been painted to at least once. + bool was_painted_to_; + // Releases the IOSurface reference, if any, retained by this object. void ReleaseIOSurface(); diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc index bbd4418..5a176c6 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc +++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc @@ -105,9 +105,22 @@ void AcceleratedSurfaceContainerManagerMac::ForceTextureReload() { } } +void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo( + gfx::PluginWindowHandle id) { + AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); + if (container) + container->set_was_painted_to(); +} + +bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible( + gfx::PluginWindowHandle id) const { + AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); + return container && container->should_be_visible(); +} + AcceleratedSurfaceContainerMac* AcceleratedSurfaceContainerManagerMac::MapIDToContainer( - gfx::PluginWindowHandle id) { + gfx::PluginWindowHandle id) const { PluginWindowToContainerMap::const_iterator i = plugin_window_to_container_map_.find(id); if (i != plugin_window_to_container_map_.end()) diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h index 1ba50a8..cd4c1b9 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h +++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h @@ -65,11 +65,17 @@ class AcceleratedSurfaceContainerManagerMac { // Should be called any time the drawing context has changed. void ForceTextureReload(); + // Notifies a surface that it has been painted to. + void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id); + + // Returns if a given surface should be shown. + bool SurfaceShouldBeVisible(gfx::PluginWindowHandle id) const; private: uint32 current_id_; // Maps a "fake" plugin window handle to the corresponding container. - AcceleratedSurfaceContainerMac* MapIDToContainer(gfx::PluginWindowHandle id); + AcceleratedSurfaceContainerMac* + MapIDToContainer(gfx::PluginWindowHandle id) const; // A map that associates plugin window handles with their containers. typedef std::map<gfx::PluginWindowHandle, AcceleratedSurfaceContainerMac*> diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 3f1c15a..4a634b2 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -427,39 +427,41 @@ void RenderWidgetHostViewMac::MovePluginWindows( const std::vector<webkit_glue::WebPluginGeometry>& moves) { // Handle movement of accelerated plugins, which are the only "windowed" // plugins that exist on the Mac. - if (moves.size() > 0) { - for (std::vector<webkit_glue::WebPluginGeometry>::const_iterator iter = - moves.begin(); - iter != moves.end(); - ++iter) { - webkit_glue::WebPluginGeometry geom = *iter; - // Ignore bogus moves which claim to move the plugin to (0, 0) - // with width and height (0, 0) - if (geom.window_rect.x() == 0 && - geom.window_rect.y() == 0 && - geom.window_rect.IsEmpty()) { - continue; - } - - gfx::Rect rect = geom.window_rect; - if (geom.visible) { - rect.set_x(rect.x() + geom.clip_rect.x()); - rect.set_y(rect.y() + geom.clip_rect.y()); - rect.set_width(geom.clip_rect.width()); - rect.set_height(geom.clip_rect.height()); - } + for (std::vector<webkit_glue::WebPluginGeometry>::const_iterator iter = + moves.begin(); + iter != moves.end(); + ++iter) { + webkit_glue::WebPluginGeometry geom = *iter; + // Ignore bogus moves which claim to move the plugin to (0, 0) + // with width and height (0, 0) + if (geom.window_rect.x() == 0 && + geom.window_rect.y() == 0 && + geom.window_rect.IsEmpty()) { + continue; + } - PluginViewMap::iterator it = plugin_views_.find(geom.window); - DCHECK(plugin_views_.end() != it); - if (plugin_views_.end() == it) { - continue; - } - NSRect new_rect([cocoa_view_ RectToNSRect:rect]); - [it->second setFrame:new_rect]; - [it->second setNeedsDisplay:YES]; + gfx::Rect rect = geom.window_rect; + if (geom.visible) { + rect.set_x(rect.x() + geom.clip_rect.x()); + rect.set_y(rect.y() + geom.clip_rect.y()); + rect.set_width(geom.clip_rect.width()); + rect.set_height(geom.clip_rect.height()); + } - plugin_container_manager_.SetPluginContainerGeometry(geom); + PluginViewMap::iterator it = plugin_views_.find(geom.window); + DCHECK(plugin_views_.end() != it); + if (plugin_views_.end() == it) { + continue; } + NSRect new_rect([cocoa_view_ RectToNSRect:rect]); + [it->second setFrame:new_rect]; + [it->second setNeedsDisplay:YES]; + + plugin_container_manager_.SetPluginContainerGeometry(geom); + + BOOL visible = + plugin_container_manager_.SurfaceShouldBeVisible(geom.window); + [it->second setHidden:!visible]; } } @@ -835,9 +837,12 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( } DCHECK([it->second isKindOfClass:[AcceleratedPluginView class]]); + plugin_container_manager_.SetSurfaceWasPaintedTo(window); AcceleratedPluginView* view = static_cast<AcceleratedPluginView*>(it->second); - [view setHidden:NO]; + // The surface is hidden until its first paint, to not show gargabe. + if (plugin_container_manager_.SurfaceShouldBeVisible(window)) + [view setHidden:NO]; [view setSurfaceWasSwapped:YES]; } |