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

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: Accommodated changes in content tests 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
« no previous file with comments | « ui/gl/gl_surface.cc ('k') | ui/gl/gl_surface_win.cc » ('j') | 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) 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
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
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
OLDNEW
« no previous file with comments | « ui/gl/gl_surface.cc ('k') | ui/gl/gl_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698