OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/gl/gl_context_wgl.h" | 7 #include "ui/gfx/gl/gl_context_wgl.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gfx/gl/gl_bindings.h" | 10 #include "ui/gfx/gl/gl_bindings.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 if (extensions) { | 32 if (extensions) { |
33 return GLContext::GetExtensions() + " " + extensions; | 33 return GLContext::GetExtensions() + " " + extensions; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 return GLContext::GetExtensions(); | 37 return GLContext::GetExtensions(); |
38 } | 38 } |
39 | 39 |
40 bool GLContextWGL::Initialize( | 40 bool GLContextWGL::Initialize( |
41 GLSurface* compatible_surface, GpuPreference gpu_preference) { | 41 GLSurface* compatible_surface, GpuPreference gpu_preference) { |
42 GLSurfaceWGL* surface_wgl = static_cast<GLSurfaceWGL*>(compatible_surface); | |
43 | |
44 // TODO(apatrick): When contexts and surfaces are separated, we won't be | 42 // TODO(apatrick): When contexts and surfaces are separated, we won't be |
45 // able to use surface_ here. Either use a display device context or a | 43 // able to use surface_ here. Either use a display device context or a |
46 // surface that the context is compatible with not necessarily limited to | 44 // surface that the context is compatible with not necessarily limited to |
47 // rendering to. | 45 // rendering to. |
48 context_ = wglCreateContext(static_cast<HDC>(surface_wgl->GetHandle())); | 46 context_ = wglCreateContext( |
| 47 static_cast<HDC>(compatible_surface->GetHandle())); |
49 if (!context_) { | 48 if (!context_) { |
50 LOG(ERROR) << "Failed to create GL context."; | 49 LOG(ERROR) << "Failed to create GL context."; |
51 Destroy(); | 50 Destroy(); |
52 return false; | 51 return false; |
53 } | 52 } |
54 | 53 |
55 if (share_group()) { | 54 if (share_group()) { |
56 HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle()); | 55 HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle()); |
57 if (share_handle) { | 56 if (share_handle) { |
58 if (!wglShareLists(share_handle, context_)) { | 57 if (!wglShareLists(share_handle, context_)) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (HasExtension("WGL_EXT_swap_control") && wglSwapIntervalEXT) { | 128 if (HasExtension("WGL_EXT_swap_control") && wglSwapIntervalEXT) { |
130 wglSwapIntervalEXT(interval); | 129 wglSwapIntervalEXT(interval); |
131 } else { | 130 } else { |
132 LOG(WARNING) << | 131 LOG(WARNING) << |
133 "Could not disable vsync: driver does not " | 132 "Could not disable vsync: driver does not " |
134 "support WGL_EXT_swap_control"; | 133 "support WGL_EXT_swap_control"; |
135 } | 134 } |
136 } | 135 } |
137 | 136 |
138 } // namespace gfx | 137 } // namespace gfx |
OLD | NEW |