Add ICU message format support
[chromium-blink-merge.git] / ui / gl / scoped_cgl.cc
blob18eb9808de1dcef969ad43dedd7509954c6549fd
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
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "ui/gl/scoped_cgl.h"
8 namespace gfx {
10 ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context) {
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);
18 CGLError error = CGLSetCurrentContext(context);
19 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
22 ScopedCGLSetCurrentContext::~ScopedCGLSetCurrentContext() {
23 CGLError error = CGLSetCurrentContext(previous_context_);
24 DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
27 } // namespace gfx