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 // 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 12 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
| 13 #include "ui/gl/gl_surface_wgl.h" | 13 #include "ui/gl/gl_surface_wgl.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 GLContextWGL::GLContextWGL(GLShareGroup* share_group) | 17 GLContextWGL::GLContextWGL(GLShareGroup* share_group) |
| 18 : GLContextReal(share_group), | 18 : GLContextReal(share_group), context_(NULL) { |
| 19 context_(NULL) { | |
| 20 } | |
| 21 | |
| 22 GLContextWGL::~GLContextWGL() { | |
| 23 Destroy(); | |
| 24 } | |
| 25 | |
| 26 std::string GLContextWGL::GetExtensions() { | |
| 27 const char* extensions = NULL; | |
| 28 if (g_driver_wgl.fn.wglGetExtensionsStringARBFn) | |
| 29 extensions = wglGetExtensionsStringARB(GLSurfaceWGL::GetDisplayDC()); | |
| 30 else if (g_driver_wgl.fn.wglGetExtensionsStringEXTFn) | |
| 31 extensions = wglGetExtensionsStringEXT(); | |
| 32 | |
| 33 if (extensions) | |
| 34 return GLContext::GetExtensions() + " " + extensions; | |
| 35 | |
| 36 return GLContext::GetExtensions(); | |
| 37 } | 19 } |
| 38 | 20 |
| 39 bool GLContextWGL::Initialize( | 21 bool GLContextWGL::Initialize( |
| 40 GLSurface* compatible_surface, GpuPreference gpu_preference) { | 22 GLSurface* compatible_surface, GpuPreference gpu_preference) { |
| 41 // Get the handle of another initialized context in the share group _before_ | 23 // Get the handle of another initialized context in the share group _before_ |
| 42 // setting context_. Otherwise this context will be considered initialized | 24 // setting context_. Otherwise this context will be considered initialized |
| 43 // and could potentially be returned by GetHandle. | 25 // and could potentially be returned by GetHandle. |
| 44 HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle()); | 26 HGLRC share_handle = static_cast<HGLRC>(share_group()->GetHandle()); |
| 45 | 27 |
| 46 context_ = wglCreateContext( | 28 context_ = wglCreateContext( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 DCHECK(IsCurrent(NULL)); | 117 DCHECK(IsCurrent(NULL)); |
| 136 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { | 118 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { |
| 137 wglSwapIntervalEXT(interval); | 119 wglSwapIntervalEXT(interval); |
| 138 } else { | 120 } else { |
| 139 LOG(WARNING) << | 121 LOG(WARNING) << |
| 140 "Could not disable vsync: driver does not " | 122 "Could not disable vsync: driver does not " |
| 141 "support WGL_EXT_swap_control"; | 123 "support WGL_EXT_swap_control"; |
| 142 } | 124 } |
| 143 } | 125 } |
| 144 | 126 |
| 127 std::string GLContextWGL::GetExtensions() { | |
| 128 const char* extensions = NULL; | |
| 129 if (g_driver_wgl.fn.wglGetExtensionsStringARBFn) | |
| 130 extensions = wglGetExtensionsStringARB(GLSurfaceWGL::GetDisplayDC()); | |
| 131 else if (g_driver_wgl.fn.wglGetExtensionsStringEXTFn) | |
| 132 extensions = wglGetExtensionsStringEXT(); | |
| 133 | |
| 134 if (extensions) | |
| 135 return GLContext::GetExtensions() + " " + extensions; | |
|
dcheng
2015/05/02 01:15:08
I wonder how much code bloat we have from string's
| |
| 136 | |
| 137 return GLContext::GetExtensions(); | |
| 138 } | |
| 139 | |
| 140 GLContextWGL::~GLContextWGL() { | |
| 141 Destroy(); | |
| 142 } | |
| 143 | |
| 145 } // namespace gfx | 144 } // namespace gfx |
| OLD | NEW |