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

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

Issue 98643013: Take GL version and extensions correctly into account when binding functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clarify code in generate_bindings.py according to feedback Created 6 years, 11 months 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
OLDNEW
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
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
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
OLDNEW
« ui/gl/gl_surface.cc ('K') | « ui/gl/gl_surface_mac.cc ('k') | ui/gl/gl_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698