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