Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: ui/gfx/gl/gl_surface_wgl.cc

Issue 8588009: use-gl=desktop mode got broken in r109111. GL proc addresses were not being found because ::GetPr... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/gfx/gl/gl_surface_wgl.h" 5 #include "ui/gfx/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 "ui/gfx/gl/gl_bindings.h" 9 #include "ui/gfx/gl/gl_bindings.h"
9 10
10 namespace gfx { 11 namespace gfx {
11 12
12 namespace { 13 namespace {
13 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = { 14 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = {
14 sizeof(kPixelFormatDescriptor), // Size of structure. 15 sizeof(kPixelFormatDescriptor), // Size of structure.
15 1, // Default version. 16 1, // Default version.
16 PFD_DRAW_TO_WINDOW | // Window drawing support. 17 PFD_DRAW_TO_WINDOW | // Window drawing support.
17 PFD_SUPPORT_OPENGL | // OpenGL support. 18 PFD_SUPPORT_OPENGL | // OpenGL support.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void* GLSurfaceWGL::GetDisplay() { 151 void* GLSurfaceWGL::GetDisplay() {
151 return GetDisplayDC(); 152 return GetDisplayDC();
152 } 153 }
153 154
154 bool GLSurfaceWGL::InitializeOneOff() { 155 bool GLSurfaceWGL::InitializeOneOff() {
155 static bool initialized = false; 156 static bool initialized = false;
156 if (initialized) 157 if (initialized)
157 return true; 158 return true;
158 159
159 DCHECK(g_display == NULL); 160 DCHECK(g_display == NULL);
160 g_display = new DisplayWGL; 161 scoped_ptr<DisplayWGL> wgl_display(new DisplayWGL);
161 if (!g_display->Init()) { 162 if (!wgl_display->Init())
162 delete g_display; 163 return false;
163 g_display = NULL; 164
165 // Create a temporary GL context to bind to extension entry points.
166 HGLRC gl_context = wglCreateContext(wgl_display->device_context());
167 if (!gl_context) {
168 LOG(ERROR) << "Failed to create temporary context.";
164 return false; 169 return false;
165 } 170 }
171 if (!wglMakeCurrent(wgl_display->device_context(), gl_context)) {
172 LOG(ERROR) << "Failed to make temporary GL context current.";
173 wglDeleteContext(gl_context);
174 return false;
175 }
176 // Get bindings to extension functions that cannot be acquired without a
177 // current context.
178 InitializeGLBindingsGL();
179 InitializeGLBindingsWGL();
166 180
181 wglMakeCurrent(NULL, NULL);
182 wglDeleteContext(gl_context);
183
184 g_display = wgl_display.release();
167 initialized = true; 185 initialized = true;
168 return true; 186 return true;
169 } 187 }
170 188
171 HDC GLSurfaceWGL::GetDisplayDC() { 189 HDC GLSurfaceWGL::GetDisplayDC() {
172 return g_display->device_context(); 190 return g_display->device_context();
173 } 191 }
174 192
175 NativeViewGLSurfaceWGL::NativeViewGLSurfaceWGL(gfx::PluginWindowHandle window) 193 NativeViewGLSurfaceWGL::NativeViewGLSurfaceWGL(gfx::PluginWindowHandle window)
176 : window_(window), 194 : window_(window),
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 357
340 gfx::Size PbufferGLSurfaceWGL::GetSize() { 358 gfx::Size PbufferGLSurfaceWGL::GetSize() {
341 return size_; 359 return size_;
342 } 360 }
343 361
344 void* PbufferGLSurfaceWGL::GetHandle() { 362 void* PbufferGLSurfaceWGL::GetHandle() {
345 return device_context_; 363 return device_context_;
346 } 364 }
347 365
348 } // namespace gfx 366 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698