summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 10:47:00 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 10:47:00 +0000
commit3d089001af1749a46325423854bff82937cb76aa (patch)
tree0a3ad3cdeee662aa6b7b92990ae42a2cdbec4cb3
parent7da454ba1d02be3cd28e7b098886a9b1baedaf71 (diff)
downloadchromium_src-3d089001af1749a46325423854bff82937cb76aa.zip
chromium_src-3d089001af1749a46325423854bff82937cb76aa.tar.gz
chromium_src-3d089001af1749a46325423854bff82937cb76aa.tar.bz2
Never bind two NSOpenGLContexts to an NSView
Binding two NSOpenGLContexts to an NSView will cause corruption and crashes when one of the contexts is destroyed. Call clearDrawable before changing the underlying context of a CompositingIOSurface. Note that the NSView owns the CompositingIOSurface, so there is no risk of "some other" NSOpenGLContext being bound to the NSView. BUG=230883 Review URL: https://chromiumcodereview.appspot.com/14092005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195772 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/compositing_iosurface_mac.h2
-rw-r--r--content/browser/renderer_host/compositing_iosurface_mac.mm12
2 files changed, 11 insertions, 3 deletions
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.h b/content/browser/renderer_host/compositing_iosurface_mac.h
index f5bf62e..b6f734b 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.h
+++ b/content/browser/renderer_host/compositing_iosurface_mac.h
@@ -228,7 +228,7 @@ class CompositingIOSurfaceMac {
// If this IOSurface has moved to a different window, use that window's
// GL context (if multiple visible windows are using the same GL context
// then call to setView call can stall and prevent reaching 60fps).
- void SwitchToContextOnNewWindow(int window_number);
+ void SwitchToContextOnNewWindow(NSView* view, int window_number);
bool IsVendorIntel();
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.mm b/content/browser/renderer_host/compositing_iosurface_mac.mm
index f000456..915868d 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.mm
+++ b/content/browser/renderer_host/compositing_iosurface_mac.mm
@@ -292,7 +292,8 @@ CompositingIOSurfaceMac::CompositingIOSurfaceMac(
StopDisplayLink();
}
-void CompositingIOSurfaceMac::SwitchToContextOnNewWindow(int window_number) {
+void CompositingIOSurfaceMac::SwitchToContextOnNewWindow(
+ NSView* view, int window_number) {
if (window_number == context_->window_number())
return;
@@ -313,6 +314,13 @@ void CompositingIOSurfaceMac::SwitchToContextOnNewWindow(int window_number) {
if (!new_context)
return;
+ // Having two NSOpenGLContexts bound to an NSView concurrently will cause
+ // artifacts and crashes. If |context_| is bound to |view|, then unbind
+ // |context_| before |new_context| gets bound to |view|.
+ // http://crbug.com/230883
+ if ([context_->nsgl_context() view] == view)
+ [context_->nsgl_context() clearDrawable];
+
context_ = new_context;
}
@@ -361,7 +369,7 @@ void CompositingIOSurfaceMac::DrawIOSurface(
float scale_factor,
int window_number,
RenderWidgetHostViewFrameSubscriber* frame_subscriber) {
- SwitchToContextOnNewWindow(window_number);
+ SwitchToContextOnNewWindow(view, window_number);
CGLSetCurrentContext(context_->cgl_context());