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

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

Issue 15928002: GPU: Keep track of the last real context and real surface made current. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make GetRealCurrent protected. 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 #include "ui/gl/gl_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // an FBO. 261 // an FBO.
262 if (!surface->OnMakeCurrent(real_context_)) { 262 if (!surface->OnMakeCurrent(real_context_)) {
263 LOG(ERROR) << "Could not make GLSurface current."; 263 LOG(ERROR) << "Could not make GLSurface current.";
264 return false; 264 return false;
265 } 265 }
266 } else if (!real_context_->MakeCurrent(surface)) { 266 } else if (!real_context_->MakeCurrent(surface)) {
267 return false; 267 return false;
268 } 268 }
269 } 269 }
270 270
271 DCHECK(GLSurface::GetCurrent()); 271 DCHECK_EQ(real_context_, GLContext::GetRealCurrent());
272 DCHECK(real_context_->IsCurrent(GLSurface::GetCurrent())); 272 DCHECK(GLSurface::GetRealCurrent());
273 DCHECK(real_context_->IsCurrent(GLSurface::GetRealCurrent()));
273 DCHECK(virtual_context->IsCurrent(surface)); 274 DCHECK(virtual_context->IsCurrent(surface));
274 275
275 if (switched_contexts || virtual_context != current_context_) { 276 if (switched_contexts || virtual_context != current_context_) {
276 // There should be no errors from the previous context leaking into the 277 // There should be no errors from the previous context leaking into the
277 // new context. 278 // new context.
278 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); 279 DCHECK_EQ(glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR));
279 280
280 current_context_ = virtual_context; 281 current_context_ = virtual_context;
281 // Set all state that is different from the real state 282 // Set all state that is different from the real state
282 // NOTE: !!! This is a temporary implementation that just restores all 283 // NOTE: !!! This is a temporary implementation that just restores all
283 // state to let us test that it works. 284 // state to let us test that it works.
284 // TODO: ASAP, change this to something that only restores the state 285 // TODO: ASAP, change this to something that only restores the state
285 // needed for individual GL calls. 286 // needed for individual GL calls.
286 GLApi* temp = GetCurrentGLApi(); 287 GLApi* temp = GetCurrentGLApi();
287 SetGLToRealGLApi(); 288 SetGLToRealGLApi();
288 if (virtual_context->GetGLStateRestorer()->IsInitialized()) 289 if (virtual_context->GetGLStateRestorer()->IsInitialized())
289 virtual_context->GetGLStateRestorer()->RestoreState(); 290 virtual_context->GetGLStateRestorer()->RestoreState();
290 SetGLApi(temp); 291 SetGLApi(temp);
291 } 292 }
292 SetGLApi(this); 293 SetGLApi(this);
294
293 return true; 295 return true;
294 } 296 }
295 297
296 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { 298 void VirtualGLApi::OnReleaseVirtuallyCurrent(GLContext* virtual_context) {
297 if (current_context_ == virtual_context) 299 if (current_context_ == virtual_context)
298 current_context_ = NULL; 300 current_context_ = NULL;
299 } 301 }
300 302
301 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 303 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
302 switch (name) { 304 switch (name) {
303 case GL_EXTENSIONS: 305 case GL_EXTENSIONS:
304 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 306 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
305 default: 307 default:
306 return driver_->fn.glGetStringFn(name); 308 return driver_->fn.glGetStringFn(name);
307 } 309 }
308 } 310 }
309 311
310 } // namespace gfx 312 } // namespace gfx
OLDNEW
« ui/gl/gl_context.cc ('K') | « ui/gl/gl_context_wgl.cc ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698