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

Unified Diff: gpu/command_buffer/service/gl_context_virtual.cc

Issue 14069008: GPU: Reduce MakeCurrent calls to fix Orange San Diego (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged work-around. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('k') | ui/gl/gl_context_egl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gl_context_virtual.cc
diff --git a/gpu/command_buffer/service/gl_context_virtual.cc b/gpu/command_buffer/service/gl_context_virtual.cc
index de94f43e57cfe9839deaad240a6cdaefd20c8c04..d0602b2eefeb68b6844b8425aee7a46bf7981472 100644
--- a/gpu/command_buffer/service/gl_context_virtual.cc
+++ b/gpu/command_buffer/service/gl_context_virtual.cc
@@ -29,12 +29,19 @@ bool GLContextVirtual::Initialize(
gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) {
display_ = static_cast<gfx::Display*>(compatible_surface->GetDisplay());
- if (!shared_context_->MakeCurrent(compatible_surface))
- return false;
+ // Virtual contexts obviously can't make a context that is compatible
+ // with the surface (the context already exists), but we do need to
+ // make a context current for SetupForVirtualization() below.
+ if (!IsCurrent(compatible_surface)) {
+ if (!shared_context_->MakeCurrent(compatible_surface)) {
+ // This is likely an error. The real context should be made as
+ // compatible with all required surfaces when it was created.
+ LOG(ERROR) << "Failed MakeCurrent(compatible_surface)";
+ return false;
+ }
+ }
shared_context_->SetupForVirtualization();
-
- shared_context_->ReleaseCurrent(compatible_surface);
return true;
}
@@ -58,18 +65,14 @@ void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) {
}
bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) {
- bool context_current = shared_context_->IsCurrent(NULL);
- if (!context_current)
- return false;
-
- if (!surface)
- return true;
-
- gfx::GLSurface* current_surface = gfx::GLSurface::GetCurrent();
- return surface->GetBackingFrameBufferObject() ||
- surface->IsOffscreen() ||
- (current_surface &&
- current_surface->GetHandle() == surface->GetHandle());
+ // If it's a real surface it needs to be current.
+ if (surface &&
+ !surface->GetBackingFrameBufferObject() &&
+ !surface->IsOffscreen())
+ return shared_context_->IsCurrent(surface);
+
+ // Otherwise, only insure the context itself is current.
+ return shared_context_->IsCurrent(NULL);
}
void* GLContextVirtual::GetHandle() {
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('k') | ui/gl/gl_context_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698