9fef3851c1ab17501f73cdddf5b4050c28131bdc
[platform/framework/web/crosswalk.git] / src / ui / gl / scoped_cgl.cc
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.
4
5 #include "base/logging.h"
6 #include "ui/gl/scoped_cgl.h"
7
8 namespace gfx {
9
10 ScopedCGLSetCurrentContext::ScopedCGLSetCurrentContext(CGLContextObj context)
11     : previous_context_(CGLGetCurrentContext(), base::scoped_policy::RETAIN) {
12   CGLError error = CGLSetCurrentContext(context);
13   DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
14 }
15
16 ScopedCGLSetCurrentContext::~ScopedCGLSetCurrentContext() {
17   CGLError error = CGLSetCurrentContext(previous_context_);
18   DCHECK_EQ(error, kCGLNoError) << "CGLSetCurrentContext should never fail";
19 }
20
21 }  // namespace gfx