| 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_surface_wgl.h" | 5 #include "ui/gl/gl_surface_wgl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
| 10 #include "ui/gl/gl_gl_api_implementation.h" | 10 #include "ui/gl/gl_gl_api_implementation.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 bool GLSurfaceWGL::InitializeOneOff() { | 157 bool GLSurfaceWGL::InitializeOneOff() { |
| 158 static bool initialized = false; | 158 static bool initialized = false; |
| 159 if (initialized) | 159 if (initialized) |
| 160 return true; | 160 return true; |
| 161 | 161 |
| 162 DCHECK(g_display == NULL); | 162 DCHECK(g_display == NULL); |
| 163 scoped_ptr<DisplayWGL> wgl_display(new DisplayWGL); | 163 scoped_ptr<DisplayWGL> wgl_display(new DisplayWGL); |
| 164 if (!wgl_display->Init()) | 164 if (!wgl_display->Init()) |
| 165 return false; | 165 return false; |
| 166 | 166 |
| 167 // Create a temporary GL context to bind to extension entry points. | |
| 168 HGLRC gl_context = wglCreateContext(wgl_display->device_context()); | |
| 169 if (!gl_context) { | |
| 170 LOG(ERROR) << "Failed to create temporary context."; | |
| 171 return false; | |
| 172 } | |
| 173 if (!wglMakeCurrent(wgl_display->device_context(), gl_context)) { | |
| 174 LOG(ERROR) << "Failed to make temporary GL context current."; | |
| 175 wglDeleteContext(gl_context); | |
| 176 return false; | |
| 177 } | |
| 178 // Get bindings to extension functions that cannot be acquired without a | |
| 179 // current context. | |
| 180 InitializeGLBindingsGL(); | |
| 181 InitializeGLBindingsWGL(); | |
| 182 | |
| 183 wglMakeCurrent(NULL, NULL); | |
| 184 wglDeleteContext(gl_context); | |
| 185 | |
| 186 g_display = wgl_display.release(); | 167 g_display = wgl_display.release(); |
| 187 initialized = true; | 168 initialized = true; |
| 188 return true; | 169 return true; |
| 189 } | 170 } |
| 190 | 171 |
| 191 HDC GLSurfaceWGL::GetDisplayDC() { | 172 HDC GLSurfaceWGL::GetDisplayDC() { |
| 192 return g_display->device_context(); | 173 return g_display->device_context(); |
| 193 } | 174 } |
| 194 | 175 |
| 195 NativeViewGLSurfaceWGL::NativeViewGLSurfaceWGL(gfx::AcceleratedWidget window) | 176 NativeViewGLSurfaceWGL::NativeViewGLSurfaceWGL(gfx::AcceleratedWidget window) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 340 |
| 360 gfx::Size PbufferGLSurfaceWGL::GetSize() { | 341 gfx::Size PbufferGLSurfaceWGL::GetSize() { |
| 361 return size_; | 342 return size_; |
| 362 } | 343 } |
| 363 | 344 |
| 364 void* PbufferGLSurfaceWGL::GetHandle() { | 345 void* PbufferGLSurfaceWGL::GetHandle() { |
| 365 return device_context_; | 346 return device_context_; |
| 366 } | 347 } |
| 367 | 348 |
| 368 } // namespace gfx | 349 } // namespace gfx |
| OLD | NEW |