Shorten audio_modem test_support target to just "test_support".
[chromium-blink-merge.git] / ui / gl / scoped_make_current.cc
blobc89724a7f2b03da556741985c877980a244c8620
1 // Copyright (c) 2012 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 "ui/gl/scoped_make_current.h"
7 #include "base/logging.h"
8 #include "ui/gl/gl_context.h"
9 #include "ui/gl/gl_surface.h"
11 namespace ui {
13 ScopedMakeCurrent::ScopedMakeCurrent(gfx::GLContext* context,
14 gfx::GLSurface* surface)
15 : previous_context_(gfx::GLContext::GetCurrent()),
16 previous_surface_(gfx::GLSurface::GetCurrent()),
17 context_(context),
18 surface_(surface),
19 succeeded_(false) {
20 DCHECK(context);
21 DCHECK(surface);
22 succeeded_ = context->MakeCurrent(surface);
25 ScopedMakeCurrent::~ScopedMakeCurrent() {
26 if (previous_context_.get()) {
27 DCHECK(previous_surface_.get());
28 previous_context_->MakeCurrent(previous_surface_.get());
29 } else {
30 context_->ReleaseCurrent(surface_.get());
34 bool ScopedMakeCurrent::Succeeded() const {
35 return succeeded_;
38 } // namespace ui