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"
13 ScopedMakeCurrent::ScopedMakeCurrent(gfx::GLContext
* context
,
14 gfx::GLSurface
* surface
)
15 : previous_context_(gfx::GLContext::GetCurrent()),
16 previous_surface_(gfx::GLSurface::GetCurrent()),
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());
30 context_
->ReleaseCurrent(surface_
.get());
34 bool ScopedMakeCurrent::Succeeded() const {