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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. | 189 // Set this as soon as the context is current, since we might call into GL. |
190 SetRealGLApi(); | 190 SetRealGLApi(); |
191 | 191 |
192 SetCurrent(surface); | 192 SetCurrent(surface); |
| 193 ScopedReleaseCurrent release_current(this, surface); |
| 194 |
193 if (!InitializeDynamicBindings()) { | 195 if (!InitializeDynamicBindings()) { |
194 ReleaseCurrent(surface); | |
195 return false; | 196 return false; |
196 } | 197 } |
197 | 198 |
198 if (!surface->OnMakeCurrent(this)) { | 199 if (!surface->OnMakeCurrent(this)) { |
199 LOG(ERROR) << "Unable to make gl context current."; | 200 LOG(ERROR) << "Unable to make gl context current."; |
200 return false; | 201 return false; |
201 } | 202 } |
202 | 203 |
| 204 release_current.Release(); |
203 return true; | 205 return true; |
204 } | 206 } |
205 | 207 |
206 void GLContextCGL::ReleaseCurrent(GLSurface* surface) { | 208 void GLContextCGL::ReleaseCurrent(GLSurface* surface) { |
207 if (!IsCurrent(surface)) | 209 if (!IsCurrent(surface)) |
208 return; | 210 return; |
209 | 211 |
210 SetCurrent(NULL); | 212 SetCurrent(NULL); |
211 CGLSetCurrentContext(NULL); | 213 CGLSetCurrentContext(NULL); |
212 } | 214 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 297 |
296 GLContextCGL::~GLContextCGL() { | 298 GLContextCGL::~GLContextCGL() { |
297 Destroy(); | 299 Destroy(); |
298 } | 300 } |
299 | 301 |
300 GpuPreference GLContextCGL::GetGpuPreference() { | 302 GpuPreference GLContextCGL::GetGpuPreference() { |
301 return gpu_preference_; | 303 return gpu_preference_; |
302 } | 304 } |
303 | 305 |
304 } // namespace gfx | 306 } // namespace gfx |
OLD | NEW |