Commit 6ede010a authored by thakis@chromium.org's avatar thakis@chromium.org

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
parent a0949a47
......@@ -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) {
......
......@@ -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();
......
......@@ -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())
......
......@@ -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*>
......
......@@ -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];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment