| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 extern "C" { | 5 extern "C" { |
| 6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
| 7 } | 7 } |
| 8 | 8 |
| 9 #include "ui/gl/gl_context_glx.h" | 9 #include "ui/gl/gl_context_glx.h" |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 static_cast<GLXContext>(context_))) { | 106 static_cast<GLXContext>(context_))) { |
| 107 LOG(ERROR) << "Couldn't make context current with X drawable."; | 107 LOG(ERROR) << "Couldn't make context current with X drawable."; |
| 108 Destroy(); | 108 Destroy(); |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Set this as soon as the context is current, since we might call into GL. | 112 // Set this as soon as the context is current, since we might call into GL. |
| 113 SetRealGLApi(); | 113 SetRealGLApi(); |
| 114 | 114 |
| 115 SetCurrent(surface); | 115 SetCurrent(surface); |
| 116 ScopedReleaseCurrent release_current(this, surface); |
| 116 if (!InitializeDynamicBindings()) { | 117 if (!InitializeDynamicBindings()) { |
| 117 ReleaseCurrent(surface); | |
| 118 Destroy(); | 118 Destroy(); |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 if (!surface->OnMakeCurrent(this)) { | 122 if (!surface->OnMakeCurrent(this)) { |
| 123 LOG(ERROR) << "Could not make current."; | 123 LOG(ERROR) << "Could not make current."; |
| 124 ReleaseCurrent(surface); | |
| 125 Destroy(); | 124 Destroy(); |
| 126 return false; | 125 return false; |
| 127 } | 126 } |
| 128 | 127 |
| 128 release_current.Release(); |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void GLContextGLX::ReleaseCurrent(GLSurface* surface) { | 132 void GLContextGLX::ReleaseCurrent(GLSurface* surface) { |
| 133 if (!IsCurrent(surface)) | 133 if (!IsCurrent(surface)) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 SetCurrent(NULL); | 136 SetCurrent(NULL); |
| 137 if (!glXMakeContextCurrent(display_, 0, 0, 0)) | 137 if (!glXMakeContextCurrent(display_, 0, 0, 0)) |
| 138 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent"; | 138 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent"; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { | 208 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { |
| 209 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); | 209 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 GLContextGLX::~GLContextGLX() { | 212 GLContextGLX::~GLContextGLX() { |
| 213 Destroy(); | 213 Destroy(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace gfx | 216 } // namespace gfx |
| OLD | NEW |