| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (!glXMakeContextCurrent( | 116 if (!glXMakeContextCurrent( |
| 117 display_, | 117 display_, |
| 118 reinterpret_cast<GLXDrawable>(surface->GetHandle()), | 118 reinterpret_cast<GLXDrawable>(surface->GetHandle()), |
| 119 reinterpret_cast<GLXDrawable>(surface->GetHandle()), | 119 reinterpret_cast<GLXDrawable>(surface->GetHandle()), |
| 120 static_cast<GLXContext>(context_))) { | 120 static_cast<GLXContext>(context_))) { |
| 121 LOG(ERROR) << "Couldn't make context current with X drawable."; | 121 LOG(ERROR) << "Couldn't make context current with X drawable."; |
| 122 Destroy(); | 122 Destroy(); |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Set this as soon as the context is current, since we might call into GL. |
| 127 SetRealGLApi(); |
| 128 |
| 126 SetCurrent(surface); | 129 SetCurrent(surface); |
| 127 if (!InitializeExtensionBindings()) { | 130 if (!InitializeExtensionBindings()) { |
| 128 ReleaseCurrent(surface); | 131 ReleaseCurrent(surface); |
| 129 Destroy(); | 132 Destroy(); |
| 130 return false; | 133 return false; |
| 131 } | 134 } |
| 132 | 135 |
| 133 if (!surface->OnMakeCurrent(this)) { | 136 if (!surface->OnMakeCurrent(this)) { |
| 134 LOG(ERROR) << "Could not make current."; | 137 LOG(ERROR) << "Could not make current."; |
| 135 ReleaseCurrent(surface); | 138 ReleaseCurrent(surface); |
| 136 Destroy(); | 139 Destroy(); |
| 137 return false; | 140 return false; |
| 138 } | 141 } |
| 139 | 142 |
| 140 SetRealGLApi(); | |
| 141 return true; | 143 return true; |
| 142 } | 144 } |
| 143 | 145 |
| 144 void GLContextGLX::ReleaseCurrent(GLSurface* surface) { | 146 void GLContextGLX::ReleaseCurrent(GLSurface* surface) { |
| 145 if (!IsCurrent(surface)) | 147 if (!IsCurrent(surface)) |
| 146 return; | 148 return; |
| 147 | 149 |
| 148 SetCurrent(NULL); | 150 SetCurrent(NULL); |
| 149 if (!glXMakeContextCurrent(display_, 0, 0, 0)) | 151 if (!glXMakeContextCurrent(display_, 0, 0, 0)) |
| 150 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent"; | 152 LOG(ERROR) << "glXMakeCurrent failed in ReleaseCurrent"; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 221 |
| 220 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { | 222 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { |
| 221 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); | 223 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); |
| 222 } | 224 } |
| 223 | 225 |
| 224 GLContextGLX::~GLContextGLX() { | 226 GLContextGLX::~GLContextGLX() { |
| 225 Destroy(); | 227 Destroy(); |
| 226 } | 228 } |
| 227 | 229 |
| 228 } // namespace gfx | 230 } // namespace gfx |
| OLD | NEW |