| 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 // This file implements the GLContextWGL and PbufferGLContext classes. | 5 // This file implements the GLContextWGL and PbufferGLContext classes. |
| 6 | 6 |
| 7 #include "ui/gl/gl_context_wgl.h" | 7 #include "ui/gl/gl_context_wgl.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 if (!wglMakeCurrent(static_cast<HDC>(surface->GetHandle()), context_)) { | 79 if (!wglMakeCurrent(static_cast<HDC>(surface->GetHandle()), context_)) { |
| 80 LOG(ERROR) << "Unable to make gl context current."; | 80 LOG(ERROR) << "Unable to make gl context current."; |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Set this as soon as the context is current, since we might call into GL. | 84 // Set this as soon as the context is current, since we might call into GL. |
| 85 SetRealGLApi(); | 85 SetRealGLApi(); |
| 86 | 86 |
| 87 SetCurrent(surface); | 87 SetCurrent(surface); |
| 88 ScopedReleaseCurrent release_current(this, surface); |
| 89 |
| 88 if (!InitializeDynamicBindings()) { | 90 if (!InitializeDynamicBindings()) { |
| 89 ReleaseCurrent(surface); | |
| 90 return false; | 91 return false; |
| 91 } | 92 } |
| 92 | 93 |
| 93 if (!surface->OnMakeCurrent(this)) { | 94 if (!surface->OnMakeCurrent(this)) { |
| 94 LOG(ERROR) << "Could not make current."; | 95 LOG(ERROR) << "Could not make current."; |
| 95 return false; | 96 return false; |
| 96 } | 97 } |
| 97 | 98 |
| 99 release_current.Release(); |
| 98 return true; | 100 return true; |
| 99 } | 101 } |
| 100 | 102 |
| 101 void GLContextWGL::ReleaseCurrent(GLSurface* surface) { | 103 void GLContextWGL::ReleaseCurrent(GLSurface* surface) { |
| 102 if (!IsCurrent(surface)) | 104 if (!IsCurrent(surface)) |
| 103 return; | 105 return; |
| 104 | 106 |
| 105 SetCurrent(NULL); | 107 SetCurrent(NULL); |
| 106 wglMakeCurrent(NULL, NULL); | 108 wglMakeCurrent(NULL, NULL); |
| 107 } | 109 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 135 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { | 137 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { |
| 136 wglSwapIntervalEXT(interval); | 138 wglSwapIntervalEXT(interval); |
| 137 } else { | 139 } else { |
| 138 LOG(WARNING) << | 140 LOG(WARNING) << |
| 139 "Could not disable vsync: driver does not " | 141 "Could not disable vsync: driver does not " |
| 140 "support WGL_EXT_swap_control"; | 142 "support WGL_EXT_swap_control"; |
| 141 } | 143 } |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace gfx | 146 } // namespace gfx |
| OLD | NEW |