diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 14:24:40 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 14:24:40 +0000 |
commit | 3d09c41344ee937ac4d3d24a13b83ecd01590e02 (patch) | |
tree | b8a83762c8ea40d3fe09958d005fc9b58ef3e6b0 /content/browser/renderer_host/compositing_iosurface_layer_mac.mm | |
parent | dcb5e5b690370d53c77805bb421fb3b2ef6e29ab (diff) | |
download | chromium_src-3d09c41344ee937ac4d3d24a13b83ecd01590e02.zip chromium_src-3d09c41344ee937ac4d3d24a13b83ecd01590e02.tar.gz chromium_src-3d09c41344ee937ac4d3d24a13b83ecd01590e02.tar.bz2 |
Use base::ScopedTypeRef for CGL types.
Use gfx::ScopedCGLSetCurrentContext for setting the current
context in the browser process. When calling CGLSetCurrentContext,
the pre-existing code inconsitently did either of restoring the
context, setting the context to NULL, or leaving the context set.
This makes the behavior consistent. It also makes error checking
pervasive.
BUG=245900
Review URL: https://codereview.chromium.org/147493011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/compositing_iosurface_layer_mac.mm')
-rw-r--r-- | content/browser/renderer_host/compositing_iosurface_layer_mac.mm | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm index b05ffe2..38752b4 100644 --- a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm +++ b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm @@ -102,10 +102,26 @@ // This makes the window content not lag behind the resize (at the cost of // blocking on the browser's main thread). if (cached_view->render_widget_host_) { - cached_view->about_to_validate_and_paint_ = true; - (void)cached_view->render_widget_host_->GetBackingStore(true); - cached_view->about_to_validate_and_paint_ = false; - CGLSetCurrentContext(glContext); + // Note that GetBackingStore can potentially spawn a nested run loop, which + // may change the current GL context, or, because the GL contexts are + // shared, may change the currently-bound FBO. Ensure that, when the run + // loop returns, the original GL context remain current, and the original + // FBO remain bound. + // TODO(ccameron): This is far too fragile a mechanism to rely on. Find + // a way to avoid doing this. + GLuint previous_framebuffer = 0; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, + reinterpret_cast<GLint*>(&previous_framebuffer)); + { + gfx::ScopedCGLSetCurrentContext scoped_set_current_context(NULL); + cached_view->about_to_validate_and_paint_ = true; + (void)cached_view->render_widget_host_->GetBackingStore(true); + cached_view->about_to_validate_and_paint_ = false; + } + CHECK_EQ(CGLGetCurrentContext(), glContext) + << "original GL context failed to re-bind after nested run loop, " + << "browser crash is imminent."; + glBindFramebuffer(GL_FRAMEBUFFER, previous_framebuffer); } // If a transition to software mode has occurred, this layer should be |