summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 16:09:11 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 16:09:11 +0000
commit33f39d5985daafddf49ad68be2e1c4c03baad06c (patch)
tree132400ebc1fa5caed7a882f9ef65103b891103c6 /chrome/plugin
parent0fb510a055aebb59c6c228f9a8202c6f6d9a39d6 (diff)
downloadchromium_src-33f39d5985daafddf49ad68be2e1c4c03baad06c.zip
chromium_src-33f39d5985daafddf49ad68be2e1c4c03baad06c.tar.gz
chromium_src-33f39d5985daafddf49ad68be2e1c4c03baad06c.tar.bz2
Mac Plugin context handling cleanup
Fixes a number of things about how the shared buffer context is handled for plugins on the Mac: - Explicitly send paint events to QuickDraw plugins. This was being done before only because of a missing break in a switch statement, but we do actually want to send them since that's the only way those plugins know when we have invalidated part of their content (e.g., on first paint, or because the window focus changed). Also moves the window-scraping to after the paint event, instead of before, so we get the latest bits (and moves that code to a new method for clarity). - Remove context save/restore from HandleInputEvent, since CoreGraphics plugins are not allowed to paint outside of handling a paint event. - Add safety checks to context save/restore in WindowlessPaint and WebPluginProxy's paint, to correctly handle resizes that happen during paint handling (using a new member variable that is independent of event model). Also renames cg_context_ for clarity. BUG=none TEST=QuickDraw plugins (e.g., QuickTime) should no longer have a flicker of painting artifacts when they are first drawn. Review URL: http://codereview.chromium.org/668113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/webplugin_proxy.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index 469d92f..95f6545 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -395,6 +395,13 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
windowless_canvas_->restore();
#elif defined(OS_MACOSX)
CGContextSaveGState(windowless_context_);
+ // It is possible for windowless_context_ to change during plugin painting
+ // (since the plugin can make a synchronous call during paint event handling),
+ // in which case we don't want to try to restore it later. Not an owning ref
+ // since owning the ref without owning the shared backing memory doesn't make
+ // sense, so this should only be used for pointer comparisons.
+ CGContextRef saved_context_weak = windowless_context_.get();
+
if (!background_context_.get()) {
CGContextSetFillColorWithColor(windowless_context_,
CGColorGetConstantColor(kCGColorBlack));
@@ -411,7 +418,8 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
}
CGContextClipToRect(windowless_context_, rect.ToCGRect());
delegate_->Paint(windowless_context_, rect);
- CGContextRestoreGState(windowless_context_);
+ if (windowless_context_.get() == saved_context_weak)
+ CGContextRestoreGState(windowless_context_);
#endif
}