summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/gl/gl_context.cc23
-rw-r--r--ui/gl/gl_context.h22
-rw-r--r--ui/gl/gl_context_android.cc6
-rw-r--r--ui/gl/gl_context_cgl.cc8
-rw-r--r--ui/gl/gl_context_cgl.h2
-rw-r--r--ui/gl/gl_context_egl.cc8
-rw-r--r--ui/gl/gl_context_egl.h2
-rw-r--r--ui/gl/gl_context_glx.cc8
-rw-r--r--ui/gl/gl_context_glx.h2
-rw-r--r--ui/gl/gl_context_nsview.h2
-rw-r--r--ui/gl/gl_context_nsview.mm2
-rw-r--r--ui/gl/gl_context_osmesa.cc8
-rw-r--r--ui/gl/gl_context_osmesa.h2
-rw-r--r--ui/gl/gl_context_stub.cc5
-rw-r--r--ui/gl/gl_context_stub.h2
-rw-r--r--ui/gl/gl_context_wgl.cc8
-rw-r--r--ui/gl/gl_context_wgl.h2
-rw-r--r--ui/gl/gl_gl_api_implementation.cc25
-rw-r--r--ui/gl/gl_surface_egl.cc25
-rw-r--r--ui/gl/gl_surface_osmesa.cc13
20 files changed, 113 insertions, 62 deletions
diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc
index 496ed96..1bc4d12 100644
--- a/ui/gl/gl_context.cc
+++ b/ui/gl/gl_context.cc
@@ -20,6 +20,9 @@ namespace gfx {
namespace {
base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
current_context_ = LAZY_INSTANCE_INITIALIZER;
+
+base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
+ current_real_context_ = LAZY_INSTANCE_INITIALIZER;
} // namespace
GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
@@ -32,7 +35,7 @@ GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
GLContext::~GLContext() {
share_group_->RemoveContext(this);
if (GetCurrent() == this) {
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
}
}
@@ -90,8 +93,12 @@ GLContext* GLContext::GetCurrent() {
return current_context_.Pointer()->Get();
}
-void GLContext::SetCurrent(GLContext* context, GLSurface* surface) {
- current_context_.Pointer()->Set(context);
+GLContext* GLContext::GetRealCurrent() {
+ return current_real_context_.Pointer()->Get();
+}
+
+void GLContext::SetCurrent(GLSurface* surface) {
+ current_context_.Pointer()->Set(surface ? this : NULL);
GLSurface::SetCurrent(surface);
}
@@ -140,4 +147,14 @@ void GLContext::SetRealGLApi() {
SetGLToRealGLApi();
}
+GLContextReal::GLContextReal(GLShareGroup* share_group)
+ : GLContext(share_group) {}
+
+GLContextReal::~GLContextReal() {}
+
+void GLContextReal::SetCurrent(GLSurface* surface) {
+ GLContext::SetCurrent(surface);
+ current_real_context_.Pointer()->Set(surface ? this : NULL);
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_context.h b/ui/gl/gl_context.h
index dc65f64..3eb390f 100644
--- a/ui/gl/gl_context.h
+++ b/ui/gl/gl_context.h
@@ -88,6 +88,7 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
static bool LosesAllContextsOnContextLost();
+ // Returns the last GLContext made current, virtual or real.
static GLContext* GetCurrent();
virtual bool WasAllocatedUsingRobustnessExtension();
@@ -107,16 +108,22 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
// Sets the GL api to the real hardware API (vs the VirtualAPI)
static void SetRealGLApi();
- static void SetCurrent(GLContext* context, GLSurface* surface);
+ virtual void SetCurrent(GLSurface* surface);
// Initialize function pointers to extension functions in the GL
// implementation. Should be called immediately after this context is made
// current.
bool InitializeExtensionBindings();
+ // Returns the last real (non-virtual) GLContext made current.
+ static GLContext* GetRealCurrent();
+
private:
friend class base::RefCounted<GLContext>;
+ // For GetRealCurrent.
+ friend class VirtualGLApi;
+
scoped_refptr<GLShareGroup> share_group_;
scoped_ptr<VirtualGLApi> virtual_gl_api_;
scoped_ptr<GLStateRestorer> state_restorer_;
@@ -124,6 +131,19 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
DISALLOW_COPY_AND_ASSIGN(GLContext);
};
+class GL_EXPORT GLContextReal : public GLContext {
+ public:
+ explicit GLContextReal(GLShareGroup* share_group);
+
+ protected:
+ virtual ~GLContextReal();
+
+ virtual void SetCurrent(GLSurface* surface) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GLContextReal);
+};
+
} // namespace gfx
#endif // UI_GL_GL_CONTEXT_H_
diff --git a/ui/gl/gl_context_android.cc b/ui/gl/gl_context_android.cc
index 88de4fc..552b055 100644
--- a/ui/gl/gl_context_android.cc
+++ b/ui/gl/gl_context_android.cc
@@ -19,7 +19,7 @@ namespace {
// Used to render into an already current context+surface,
// that we do not have ownership of (draw callback).
-class GLNonOwnedContext : public GLContext {
+class GLNonOwnedContext : public GLContextReal {
public:
GLNonOwnedContext(GLShareGroup* share_group);
@@ -44,10 +44,10 @@ class GLNonOwnedContext : public GLContext {
};
GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group)
- : GLContext(share_group) {}
+ : GLContextReal(share_group) {}
bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) {
- SetCurrent(this, surface);
+ SetCurrent(surface);
SetRealGLApi();
return true;
}
diff --git a/ui/gl/gl_context_cgl.cc b/ui/gl/gl_context_cgl.cc
index a4347e9..d826d81 100644
--- a/ui/gl/gl_context_cgl.cc
+++ b/ui/gl/gl_context_cgl.cc
@@ -65,7 +65,7 @@ static CGLPixelFormatObj GetPixelFormat() {
}
GLContextCGL::GLContextCGL(GLShareGroup* share_group)
- : GLContext(share_group),
+ : GLContextReal(share_group),
context_(NULL),
gpu_preference_(PreferIntegratedGpu),
discrete_pixelformat_(NULL),
@@ -186,7 +186,7 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) {
return false;
}
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!InitializeExtensionBindings()) {
ReleaseCurrent(surface);
return false;
@@ -205,7 +205,7 @@ void GLContextCGL::ReleaseCurrent(GLSurface* surface) {
if (!IsCurrent(surface))
return;
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
CGLSetCurrentContext(NULL);
}
@@ -215,7 +215,7 @@ bool GLContextCGL::IsCurrent(GLSurface* surface) {
// If our context is current then our notion of which GLContext is
// current must be correct. On the other hand, third-party code
// using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
+ DCHECK(!native_context_is_current || (GetRealCurrent() == this));
if (!native_context_is_current)
return false;
diff --git a/ui/gl/gl_context_cgl.h b/ui/gl/gl_context_cgl.h
index 94392bb..a83eaaf 100644
--- a/ui/gl/gl_context_cgl.h
+++ b/ui/gl/gl_context_cgl.h
@@ -14,7 +14,7 @@ namespace gfx {
class GLSurface;
// Encapsulates a CGL OpenGL context.
-class GLContextCGL : public GLContext {
+class GLContextCGL : public GLContextReal {
public:
explicit GLContextCGL(GLShareGroup* share_group);
diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc
index ee815bf..7354c7d 100644
--- a/ui/gl/gl_context_egl.cc
+++ b/ui/gl/gl_context_egl.cc
@@ -25,7 +25,7 @@ using ui::GetLastEGLErrorString;
namespace gfx {
GLContextEGL::GLContextEGL(GLShareGroup* share_group)
- : GLContext(share_group),
+ : GLContextReal(share_group),
context_(NULL),
display_(NULL),
config_(NULL),
@@ -112,7 +112,7 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) {
return false;
}
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!InitializeExtensionBindings()) {
ReleaseCurrent(surface);
return false;
@@ -138,7 +138,7 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
if (unbind_fbo_on_makecurrent_)
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
eglMakeCurrent(display_,
EGL_NO_SURFACE,
EGL_NO_SURFACE,
@@ -153,7 +153,7 @@ bool GLContextEGL::IsCurrent(GLSurface* surface) {
// If our context is current then our notion of which GLContext is
// current must be correct. On the other hand, third-party code
// using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
+ DCHECK(!native_context_is_current || (GetRealCurrent() == this));
if (!native_context_is_current)
return false;
diff --git a/ui/gl/gl_context_egl.h b/ui/gl/gl_context_egl.h
index f694ba2..9dd9a72 100644
--- a/ui/gl/gl_context_egl.h
+++ b/ui/gl/gl_context_egl.h
@@ -19,7 +19,7 @@ namespace gfx {
class GLSurface;
// Encapsulates an EGL OpenGL ES context.
-class GLContextEGL : public GLContext {
+class GLContextEGL : public GLContextReal {
public:
explicit GLContextEGL(GLShareGroup* share_group);
diff --git a/ui/gl/gl_context_glx.cc b/ui/gl/gl_context_glx.cc
index c47a10d..aeaf5fc 100644
--- a/ui/gl/gl_context_glx.cc
+++ b/ui/gl/gl_context_glx.cc
@@ -34,7 +34,7 @@ class ScopedPtrXFree {
} // namespace
GLContextGLX::GLContextGLX(GLShareGroup* share_group)
- : GLContext(share_group),
+ : GLContextReal(share_group),
context_(NULL),
display_(NULL) {
}
@@ -123,7 +123,7 @@ bool GLContextGLX::MakeCurrent(GLSurface* surface) {
return false;
}
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!InitializeExtensionBindings()) {
ReleaseCurrent(surface);
Destroy();
@@ -145,7 +145,7 @@ void GLContextGLX::ReleaseCurrent(GLSurface* surface) {
if (!IsCurrent(surface))
return;
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
if (!glXMakeContextCurrent(display_, 0, 0, 0))
LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent";
}
@@ -157,7 +157,7 @@ bool GLContextGLX::IsCurrent(GLSurface* surface) {
// If our context is current then our notion of which GLContext is
// current must be correct. On the other hand, third-party code
// using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
+ DCHECK(!native_context_is_current || (GetRealCurrent() == this));
if (!native_context_is_current)
return false;
diff --git a/ui/gl/gl_context_glx.h b/ui/gl/gl_context_glx.h
index 2847881..f5f9a48 100644
--- a/ui/gl/gl_context_glx.h
+++ b/ui/gl/gl_context_glx.h
@@ -17,7 +17,7 @@ namespace gfx {
class GLSurface;
// Encapsulates a GLX OpenGL context.
-class GL_EXPORT GLContextGLX : public GLContext {
+class GL_EXPORT GLContextGLX : public GLContextReal {
public:
explicit GLContextGLX(GLShareGroup* share_group);
diff --git a/ui/gl/gl_context_nsview.h b/ui/gl/gl_context_nsview.h
index bb2aa78..f4f4df7 100644
--- a/ui/gl/gl_context_nsview.h
+++ b/ui/gl/gl_context_nsview.h
@@ -17,7 +17,7 @@ class GLSurface;
// GLContextNSView encapsulates an NSView-based GLContext. This is paired with
// the GLSurfaceNSView class.
-class GLContextNSView : public GLContext {
+class GLContextNSView : public GLContextReal {
public:
explicit GLContextNSView(GLShareGroup* group);
virtual ~GLContextNSView();
diff --git a/ui/gl/gl_context_nsview.mm b/ui/gl/gl_context_nsview.mm
index 898bf01..464ca3e 100644
--- a/ui/gl/gl_context_nsview.mm
+++ b/ui/gl/gl_context_nsview.mm
@@ -64,7 +64,7 @@ bool GLContextNSView::MakeCurrent(GLSurface* surface) {
[context_ setView:view];
[context_ makeCurrentContext];
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!surface->OnMakeCurrent(this)) {
LOG(ERROR) << "Unable to make gl context current.";
diff --git a/ui/gl/gl_context_osmesa.cc b/ui/gl/gl_context_osmesa.cc
index 22c6c1e..71154ec 100644
--- a/ui/gl/gl_context_osmesa.cc
+++ b/ui/gl/gl_context_osmesa.cc
@@ -14,7 +14,7 @@
namespace gfx {
GLContextOSMesa::GLContextOSMesa(GLShareGroup* share_group)
- : GLContext(share_group),
+ : GLContextReal(share_group),
context_(NULL) {
}
@@ -65,7 +65,7 @@ bool GLContextOSMesa::MakeCurrent(GLSurface* surface) {
// Row 0 is at the top.
OSMesaPixelStore(OSMESA_Y_UP, 0);
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!InitializeExtensionBindings()) {
ReleaseCurrent(surface);
return false;
@@ -84,7 +84,7 @@ void GLContextOSMesa::ReleaseCurrent(GLSurface* surface) {
if (!IsCurrent(surface))
return;
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0);
}
@@ -97,7 +97,7 @@ bool GLContextOSMesa::IsCurrent(GLSurface* surface) {
// If our context is current then our notion of which GLContext is
// current must be correct. On the other hand, third-party code
// using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
+ DCHECK(!native_context_is_current || (GetRealCurrent() == this));
if (!native_context_is_current)
return false;
diff --git a/ui/gl/gl_context_osmesa.h b/ui/gl/gl_context_osmesa.h
index 382e8ce..f78b525 100644
--- a/ui/gl/gl_context_osmesa.h
+++ b/ui/gl/gl_context_osmesa.h
@@ -17,7 +17,7 @@ class GLShareGroup;
class GLSurface;
// Encapsulates an OSMesa OpenGL context that uses software rendering.
-class GLContextOSMesa : public GLContext {
+class GLContextOSMesa : public GLContextReal {
public:
explicit GLContextOSMesa(GLShareGroup* share_group);
diff --git a/ui/gl/gl_context_stub.cc b/ui/gl/gl_context_stub.cc
index 2b72c8f..7c63ff2 100644
--- a/ui/gl/gl_context_stub.cc
+++ b/ui/gl/gl_context_stub.cc
@@ -6,7 +6,7 @@
namespace gfx {
-GLContextStub::GLContextStub() : GLContext(NULL) {}
+GLContextStub::GLContextStub() : GLContextReal(NULL) {}
bool GLContextStub::Initialize(
GLSurface* compatible_surface, GpuPreference gpu_preference) {
@@ -16,12 +16,13 @@ bool GLContextStub::Initialize(
void GLContextStub::Destroy() {}
bool GLContextStub::MakeCurrent(GLSurface* surface) {
- SetCurrent(this, surface);
+ SetCurrent(surface);
SetRealGLApi();
return true;
}
void GLContextStub::ReleaseCurrent(GLSurface* surface) {
+ SetCurrent(NULL);
}
bool GLContextStub::IsCurrent(GLSurface* surface) {
diff --git a/ui/gl/gl_context_stub.h b/ui/gl/gl_context_stub.h
index ba130f6..8fca5b7 100644
--- a/ui/gl/gl_context_stub.h
+++ b/ui/gl/gl_context_stub.h
@@ -10,7 +10,7 @@
namespace gfx {
// A GLContext that does nothing for unit tests.
-class GL_EXPORT GLContextStub : public GLContext {
+class GL_EXPORT GLContextStub : public GLContextReal {
public:
GLContextStub();
diff --git a/ui/gl/gl_context_wgl.cc b/ui/gl/gl_context_wgl.cc
index 916e49d..dba107b 100644
--- a/ui/gl/gl_context_wgl.cc
+++ b/ui/gl/gl_context_wgl.cc
@@ -15,7 +15,7 @@
namespace gfx {
GLContextWGL::GLContextWGL(GLShareGroup* share_group)
- : GLContext(share_group),
+ : GLContextReal(share_group),
context_(NULL) {
}
@@ -81,7 +81,7 @@ bool GLContextWGL::MakeCurrent(GLSurface* surface) {
return false;
}
- SetCurrent(this, surface);
+ SetCurrent(surface);
if (!InitializeExtensionBindings()) {
ReleaseCurrent(surface);
return false;
@@ -100,7 +100,7 @@ void GLContextWGL::ReleaseCurrent(GLSurface* surface) {
if (!IsCurrent(surface))
return;
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
wglMakeCurrent(NULL, NULL);
}
@@ -111,7 +111,7 @@ bool GLContextWGL::IsCurrent(GLSurface* surface) {
// If our context is current then our notion of which GLContext is
// current must be correct. On the other hand, third-party code
// using OpenGL might change the current context.
- DCHECK(!native_context_is_current || (GetCurrent() == this));
+ DCHECK(!native_context_is_current || (GetRealCurrent() == this));
if (!native_context_is_current)
return false;
diff --git a/ui/gl/gl_context_wgl.h b/ui/gl/gl_context_wgl.h
index d3f6541..13a274b 100644
--- a/ui/gl/gl_context_wgl.h
+++ b/ui/gl/gl_context_wgl.h
@@ -15,7 +15,7 @@ namespace gfx {
class GLSurface;
// This class is a wrapper around a GL context.
-class GLContextWGL : public GLContext {
+class GLContextWGL : public GLContextReal {
public:
explicit GLContextWGL(GLShareGroup* share_group);
virtual ~GLContextWGL();
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index 94166eed..65f29c6 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -254,22 +254,19 @@ bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) {
bool switched_contexts = g_current_gl_context != this;
GLSurface* current_surface = GLSurface::GetCurrent();
if (switched_contexts || surface != current_surface) {
- if (!switched_contexts && current_surface &&
- virtual_context->IsCurrent(surface)) {
- // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent()
- // calls if the GLSurface uses the same underlying surface or renders to
- // an FBO.
- if (!surface->OnMakeCurrent(real_context_)) {
- LOG(ERROR) << "Could not make GLSurface current.";
+ // MakeCurrent 'lite' path that avoids potentially expensive MakeCurrent()
+ // calls if the GLSurface uses the same underlying surface or renders to
+ // an FBO.
+ if (switched_contexts || !current_surface ||
+ !virtual_context->IsCurrent(surface)) {
+ if (!real_context_->MakeCurrent(surface)) {
return false;
}
- } else if (!real_context_->MakeCurrent(surface)) {
- return false;
}
}
- DCHECK(GLSurface::GetCurrent());
- DCHECK(real_context_->IsCurrent(GLSurface::GetCurrent()));
+ DCHECK_EQ(real_context_, GLContext::GetRealCurrent());
+ DCHECK(real_context_->IsCurrent(NULL));
DCHECK(virtual_context->IsCurrent(surface));
if (switched_contexts || virtual_context != current_context_) {
@@ -290,6 +287,12 @@ bool VirtualGLApi::MakeCurrent(GLContext* virtual_context, GLSurface* surface) {
SetGLApi(temp);
}
SetGLApi(this);
+
+ virtual_context->SetCurrent(surface);
+ if (!surface->OnMakeCurrent(virtual_context)) {
+ LOG(ERROR) << "Could not make GLSurface current.";
+ return false;
+ }
return true;
}
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 1073304..84efbc6 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -16,6 +16,7 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_stub.h"
+#include "ui/gl/scoped_make_current.h"
#if defined(USE_X11)
extern "C" {
@@ -410,20 +411,23 @@ bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) {
if (size == GetSize())
return true;
+ scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
GLContext* current_context = GLContext::GetCurrent();
- bool was_current = current_context && current_context->IsCurrent(this);
- if (was_current)
+ bool was_current =
+ current_context && current_context->IsCurrent(this);
+ if (was_current) {
+ scoped_make_current.reset(
+ new ui::ScopedMakeCurrent(current_context, this));
current_context->ReleaseCurrent(this);
+ }
Destroy();
if (!Initialize()) {
- LOG(ERROR) << "Failed to resize pbuffer.";
+ LOG(ERROR) << "Failed to resize window.";
return false;
}
- if (was_current)
- return current_context->MakeCurrent(this);
return true;
}
@@ -554,8 +558,14 @@ bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) {
if (size == size_)
return true;
+ scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
GLContext* current_context = GLContext::GetCurrent();
- bool was_current = current_context && current_context->IsCurrent(this);
+ bool was_current =
+ current_context && current_context->IsCurrent(this);
+ if (was_current) {
+ scoped_make_current.reset(
+ new ui::ScopedMakeCurrent(current_context, this));
+ }
size_ = size;
@@ -564,9 +574,6 @@ bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) {
return false;
}
- if (was_current)
- return current_context->MakeCurrent(this);
-
return true;
}
diff --git a/ui/gl/gl_surface_osmesa.cc b/ui/gl/gl_surface_osmesa.cc
index 7994eec..9a556bc 100644
--- a/ui/gl/gl_surface_osmesa.cc
+++ b/ui/gl/gl_surface_osmesa.cc
@@ -6,6 +6,7 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_osmesa.h"
+#include "ui/gl/scoped_make_current.h"
namespace gfx {
@@ -23,10 +24,15 @@ void GLSurfaceOSMesa::Destroy() {
}
bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) {
+ scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
GLContext* current_context = GLContext::GetCurrent();
- bool was_current = current_context && current_context->IsCurrent(this);
- if (was_current)
+ bool was_current =
+ current_context && current_context->IsCurrent(this);
+ if (was_current) {
+ scoped_make_current.reset(
+ new ui::ScopedMakeCurrent(current_context, this));
current_context->ReleaseCurrent(this);
+ }
// Preserve the old buffer.
scoped_ptr<int32[]> old_buffer(buffer_.release());
@@ -48,9 +54,6 @@ bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) {
size_ = new_size;
- if (was_current)
- return current_context->MakeCurrent(this);
-
return true;
}