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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "ui/gl/scoped_cgl.h" 6 #include "ui/gl/scoped_cgl.h"
7 7
8 namespace gfx { 8 namespace gfx {
9 9
10 ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context) 10 ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context) {
11 : previous_context_(CGLGetCurrentContext(), base::scoped_policy::RETAIN) { 11 CGLContextObj previous_context = CGLGetCurrentContext();
12 // It is possible for the previous context to have a zero reference count,
13 // because making a context current does not increment the reference count.
14 // In that case, do not restore the previous context.
15 if (previous_context && CGLGetContextRetainCount(previous_context)) {
16 previous_context_.reset(previous_context, base::scoped_policy::RETAIN);
17 }
12 CGLError error = CGLSetCurrentContext(context); 18 CGLError error = CGLSetCurrentContext(context);
13 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail"; 19 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
14 } 20 }
15 21
16 ScopedCGLSetCurrentContext::~ScopedCGLSetCurrentContext() { 22 ScopedCGLSetCurrentContext::~ScopedCGLSetCurrentContext() {
17 CGLError error = CGLSetCurrentContext(previous_context_); 23 CGLError error = CGLSetCurrentContext(previous_context_);
18 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail"; 24 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
19 } 25 }
20 26
21 } // namespace gfx 27 } // namespace gfx
OLDNEW
« 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