Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / ui / gl / gl_context_glx.cc
index 248d04b..9b6cfb4 100644 (file)
@@ -11,7 +11,6 @@ extern "C" {
 #include "base/debug/trace_event.h"
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
-#include "third_party/mesa/src/include/GL/osmesa.h"
 #include "ui/gl/GL/glextchromium.h"
 #include "ui/gl/gl_bindings.h"
 #include "ui/gl/gl_implementation.h"
@@ -19,20 +18,6 @@ extern "C" {
 
 namespace gfx {
 
-namespace {
-
-// scoped_ptr functor for XFree(). Use as follows:
-//   scoped_ptr_malloc<XVisualInfo, ScopedPtrXFree> foo(...);
-// where "XVisualInfo" is any X type that is freed with XFree.
-class ScopedPtrXFree {
- public:
-  void operator()(void* x) const {
-    ::XFree(x);
-  }
-};
-
-}  // namespace
-
 GLContextGLX::GLContextGLX(GLShareGroup* share_group)
   : GLContextReal(share_group),
     context_(NULL),
@@ -112,6 +97,7 @@ bool GLContextGLX::MakeCurrent(GLSurface* surface) {
   if (IsCurrent(surface))
     return true;
 
+  ScopedReleaseCurrent release_current;
   TRACE_EVENT0("gpu", "GLContextGLX::MakeCurrent");
   if (!glXMakeContextCurrent(
       display_,
@@ -128,18 +114,17 @@ bool GLContextGLX::MakeCurrent(GLSurface* surface) {
 
   SetCurrent(surface);
   if (!InitializeDynamicBindings()) {
-    ReleaseCurrent(surface);
     Destroy();
     return false;
   }
 
   if (!surface->OnMakeCurrent(this)) {
     LOG(ERROR) << "Could not make current.";
-    ReleaseCurrent(surface);
     Destroy();
     return false;
   }
 
+  release_current.Cancel();
   return true;
 }