diff options
-rw-r--r-- | ui/gfx/compositor/compositor_gl.cc | 6 | ||||
-rw-r--r-- | ui/gfx/compositor/compositor_gl.h | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc index 3d53d28..078556b 100644 --- a/ui/gfx/compositor/compositor_gl.cc +++ b/ui/gfx/compositor/compositor_gl.cc @@ -349,6 +349,10 @@ bool SharedResourcesGL::MakeSharedContextCurrent() { return context_->MakeCurrent(surface_.get()); } +gfx::ScopedMakeCurrent* SharedResourcesGL::GetScopedMakeCurrent() { + return new gfx::ScopedMakeCurrent(context_.get(), surface_.get()); +} + scoped_refptr<gfx::GLContext> SharedResourcesGL::CreateContext( gfx::GLSurface* surface) { if (initialized_) @@ -374,7 +378,7 @@ TextureGL::~TextureGL() { if (texture_id_) { SharedResourcesGL* instance = SharedResourcesGL::GetInstance(); DCHECK(instance); - instance->MakeSharedContextCurrent(); + scoped_ptr<gfx::ScopedMakeCurrent> bind(instance->GetScopedMakeCurrent()); glDeleteTextures(1, &texture_id_); } } diff --git a/ui/gfx/compositor/compositor_gl.h b/ui/gfx/compositor/compositor_gl.h index 586e793..871f7aa 100644 --- a/ui/gfx/compositor/compositor_gl.h +++ b/ui/gfx/compositor/compositor_gl.h @@ -11,6 +11,7 @@ #include "base/memory/singleton.h" #include "base/memory/ref_counted.h" #include "ui/gfx/compositor/compositor.h" +#include "ui/gfx/gl/scoped_make_current.h" #include "ui/gfx/size.h" namespace gfx { @@ -32,6 +33,10 @@ class COMPOSITOR_EXPORT SharedResourcesGL : public SharedResources { virtual bool MakeSharedContextCurrent(); + // Creates an instance of ScopedMakeCurrent. + // Note: Caller is responsible for managing lifetime of returned pointer. + gfx::ScopedMakeCurrent* GetScopedMakeCurrent(); + // Creates a context that shares the resources hosted by this singleton. scoped_refptr<gfx::GLContext> CreateContext(gfx::GLSurface* surface); |