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

Unified Diff: ui/gl/cgl_util.cc

Issue 157063002: Add helpers for CGL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: & cleanup Created 6 years, 10 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
« ui/gl/cgl_util.h ('K') | « ui/gl/cgl_util.h ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/cgl_util.cc
diff --git a/ui/gl/cgl_util.cc b/ui/gl/cgl_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f18b53784e97ea9e6cd3114b2cc86659af27131
--- /dev/null
+++ b/ui/gl/cgl_util.cc
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "ui/gl/cgl_util.h"
+
+namespace gfx {
+
+ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context)
+ : previous_context_(CGLGetCurrentContext(), base::scoped_policy::RETAIN) {
Mark Mentovai 2014/02/07 19:53:41 4-space indent.
ccameron 2014/02/07 20:58:04 Done.
+ CGLError error = CGLSetCurrentContext(context);
+ DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
Mark Mentovai 2014/02/07 19:53:41 Do you deal with CGLError often? Do you CHECK on t
ccameron 2014/02/07 20:58:04 They're used pretty often, but not CHECKed too oft
+}
+
+ScopedCGLSetCurrentContext::~ScopedCGLSetCurrentContext() {
+ CGLError error = CGLSetCurrentContext(previous_context_);
+ DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
+}
+
+} // namespace gfx
« ui/gl/cgl_util.h ('K') | « ui/gl/cgl_util.h ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698