Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: ui/gl/scoped_cgl.cc

Issue 224723021: Do not retain zombie CGL contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/scoped_cgl.cc
diff --git a/ui/gl/scoped_cgl.cc b/ui/gl/scoped_cgl.cc
index 9fef3851c1ab17501f73cdddf5b4050c28131bdc..18eb9808de1dcef969ad43dedd7509954c6549fd 100644
--- a/ui/gl/scoped_cgl.cc
+++ b/ui/gl/scoped_cgl.cc
@@ -7,8 +7,14 @@
namespace gfx {
-ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context)
- : previous_context_(CGLGetCurrentContext(), base::scoped_policy::RETAIN) {
+ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context) {
+ CGLContextObj previous_context = CGLGetCurrentContext();
+ // It is possible for the previous context to have a zero reference count,
+ // because making a context current does not increment the reference count.
+ // In that case, do not restore the previous context.
+ if (previous_context && CGLGetContextRetainCount(previous_context)) {
+ previous_context_.reset(previous_context, base::scoped_policy::RETAIN);
+ }
CGLError error = CGLSetCurrentContext(context);
DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698