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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 wglMakeCurrent(NULL, NULL); | 104 wglMakeCurrent(NULL, NULL); |
105 } | 105 } |
106 | 106 |
107 bool GLContextWGL::IsCurrent(GLSurface* surface) { | 107 bool GLContextWGL::IsCurrent(GLSurface* surface) { |
108 bool native_context_is_current = | 108 bool native_context_is_current = |
109 wglGetCurrentContext() == context_; | 109 wglGetCurrentContext() == context_; |
110 | 110 |
111 // If our context is current then our notion of which GLContext is | 111 // If our context is current then our notion of which GLContext is |
112 // current must be correct. On the other hand, third-party code | 112 // current must be correct. On the other hand, third-party code |
113 // using OpenGL might change the current context. | 113 // using OpenGL might change the current context. |
114 DCHECK(!native_context_is_current || (GetCurrent() == this)); | 114 DCHECK(!native_context_is_current || (GetRealCurrent() == this)); |
115 | 115 |
116 if (!native_context_is_current) | 116 if (!native_context_is_current) |
117 return false; | 117 return false; |
118 | 118 |
119 if (surface) { | 119 if (surface) { |
120 if (wglGetCurrentDC() != surface->GetHandle()) | 120 if (wglGetCurrentDC() != surface->GetHandle()) |
121 return false; | 121 return false; |
122 } | 122 } |
123 | 123 |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 void* GLContextWGL::GetHandle() { | 127 void* GLContextWGL::GetHandle() { |
128 return context_; | 128 return context_; |
129 } | 129 } |
130 | 130 |
131 void GLContextWGL::SetSwapInterval(int interval) { | 131 void GLContextWGL::SetSwapInterval(int interval) { |
132 DCHECK(IsCurrent(NULL)); | 132 DCHECK(IsCurrent(NULL)); |
133 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { | 133 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { |
134 wglSwapIntervalEXT(interval); | 134 wglSwapIntervalEXT(interval); |
135 } else { | 135 } else { |
136 LOG(WARNING) << | 136 LOG(WARNING) << |
137 "Could not disable vsync: driver does not " | 137 "Could not disable vsync: driver does not " |
138 "support WGL_EXT_swap_control"; | 138 "support WGL_EXT_swap_control"; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 } // namespace gfx | 142 } // namespace gfx |
OLD | NEW |