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

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

Issue 16838007: Ensure real GL Api is set before making GL calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 // This file implements the GLContextWGL and PbufferGLContext classes. 5 // This file implements the GLContextWGL and PbufferGLContext classes.
6 6
7 #include "ui/gl/gl_context_wgl.h" 7 #include "ui/gl/gl_context_wgl.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (IsCurrent(surface)) 74 if (IsCurrent(surface))
75 return true; 75 return true;
76 76
77 TRACE_EVENT0("gpu", "GLContextWGL::MakeCurrent"); 77 TRACE_EVENT0("gpu", "GLContextWGL::MakeCurrent");
78 78
79 if (!wglMakeCurrent(static_cast<HDC>(surface->GetHandle()), context_)) { 79 if (!wglMakeCurrent(static_cast<HDC>(surface->GetHandle()), context_)) {
80 LOG(ERROR) << "Unable to make gl context current."; 80 LOG(ERROR) << "Unable to make gl context current.";
81 return false; 81 return false;
82 } 82 }
83 83
84 // Set this as soon as the context is current, since we might call into GL.
85 SetRealGLApi();
86
84 SetCurrent(surface); 87 SetCurrent(surface);
85 if (!InitializeExtensionBindings()) { 88 if (!InitializeExtensionBindings()) {
86 ReleaseCurrent(surface); 89 ReleaseCurrent(surface);
87 return false; 90 return false;
88 } 91 }
89 92
90 if (!surface->OnMakeCurrent(this)) { 93 if (!surface->OnMakeCurrent(this)) {
91 LOG(ERROR) << "Could not make current."; 94 LOG(ERROR) << "Could not make current.";
92 return false; 95 return false;
93 } 96 }
94 97
95 SetRealGLApi();
96 return true; 98 return true;
97 } 99 }
98 100
99 void GLContextWGL::ReleaseCurrent(GLSurface* surface) { 101 void GLContextWGL::ReleaseCurrent(GLSurface* surface) {
100 if (!IsCurrent(surface)) 102 if (!IsCurrent(surface))
101 return; 103 return;
102 104
103 SetCurrent(NULL); 105 SetCurrent(NULL);
104 wglMakeCurrent(NULL, NULL); 106 wglMakeCurrent(NULL, NULL);
105 } 107 }
(...skipping 27 matching lines...) Expand all
133 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) { 135 if (gfx::g_driver_wgl.ext.b_WGL_EXT_swap_control) {
134 wglSwapIntervalEXT(interval); 136 wglSwapIntervalEXT(interval);
135 } else { 137 } else {
136 LOG(WARNING) << 138 LOG(WARNING) <<
137 "Could not disable vsync: driver does not " 139 "Could not disable vsync: driver does not "
138 "support WGL_EXT_swap_control"; 140 "support WGL_EXT_swap_control";
139 } 141 }
140 } 142 }
141 143
142 } // namespace gfx 144 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698