Chromium Code Reviews| 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 #include "ui/gl/gl_context_cgl.h" | 5 #include "ui/gl/gl_context_cgl.h" |
| 6 | 6 |
| 7 #include <OpenGL/CGLRenderers.h> | 7 #include <OpenGL/CGLRenderers.h> |
| 8 #include <OpenGL/CGLTypes.h> | 8 #include <OpenGL/CGLTypes.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 return true; | 179 return true; |
| 180 | 180 |
| 181 TRACE_EVENT0("gpu", "GLContextCGL::MakeCurrent"); | 181 TRACE_EVENT0("gpu", "GLContextCGL::MakeCurrent"); |
| 182 | 182 |
| 183 if (CGLSetCurrentContext( | 183 if (CGLSetCurrentContext( |
| 184 static_cast<CGLContextObj>(context_)) != kCGLNoError) { | 184 static_cast<CGLContextObj>(context_)) != kCGLNoError) { |
| 185 LOG(ERROR) << "Unable to make gl context current."; | 185 LOG(ERROR) << "Unable to make gl context current."; |
| 186 return false; | 186 return false; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Set this as soon as the context is current, since we might call into GL. | |
| 190 SetRealGLApi(); | |
|
greggman
2013/06/12 22:17:18
Do you want to restore it if it fails?
I know tha
| |
| 191 | |
| 189 SetCurrent(surface); | 192 SetCurrent(surface); |
| 190 if (!InitializeExtensionBindings()) { | 193 if (!InitializeExtensionBindings()) { |
| 191 ReleaseCurrent(surface); | 194 ReleaseCurrent(surface); |
| 192 return false; | 195 return false; |
| 193 } | 196 } |
| 194 | 197 |
| 195 if (!surface->OnMakeCurrent(this)) { | 198 if (!surface->OnMakeCurrent(this)) { |
| 196 LOG(ERROR) << "Unable to make gl context current."; | 199 LOG(ERROR) << "Unable to make gl context current."; |
| 197 return false; | 200 return false; |
| 198 } | 201 } |
| 199 | 202 |
| 200 SetRealGLApi(); | |
| 201 return true; | 203 return true; |
| 202 } | 204 } |
| 203 | 205 |
| 204 void GLContextCGL::ReleaseCurrent(GLSurface* surface) { | 206 void GLContextCGL::ReleaseCurrent(GLSurface* surface) { |
| 205 if (!IsCurrent(surface)) | 207 if (!IsCurrent(surface)) |
| 206 return; | 208 return; |
| 207 | 209 |
| 208 SetCurrent(NULL); | 210 SetCurrent(NULL); |
| 209 CGLSetCurrentContext(NULL); | 211 CGLSetCurrentContext(NULL); |
| 210 } | 212 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 | 295 |
| 294 GLContextCGL::~GLContextCGL() { | 296 GLContextCGL::~GLContextCGL() { |
| 295 Destroy(); | 297 Destroy(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 GpuPreference GLContextCGL::GetGpuPreference() { | 300 GpuPreference GLContextCGL::GetGpuPreference() { |
| 299 return gpu_preference_; | 301 return gpu_preference_; |
| 300 } | 302 } |
| 301 | 303 |
| 302 } // namespace gfx | 304 } // namespace gfx |
| OLD | NEW |