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

Unified Diff: ui/gl/gl_context.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: Fix OSX 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 side-by-side diff with in-line comments
Download patch
Index: ui/gl/gl_context.cc
diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc
index 496ed964e5e0f4f491556d4fe97f20169c8b32af..e867c50fdc5e54ee91b40c89ce8a54c7200d9be8 100644
--- a/ui/gl/gl_context.cc
+++ b/ui/gl/gl_context.cc
@@ -20,6 +20,9 @@ namespace gfx {
namespace {
base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
current_context_ = LAZY_INSTANCE_INITIALIZER;
+
+base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
+ current_real_context_ = LAZY_INSTANCE_INITIALIZER;
} // namespace
GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
@@ -32,7 +35,7 @@ GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
GLContext::~GLContext() {
share_group_->RemoveContext(this);
if (GetCurrent() == this) {
- SetCurrent(NULL, NULL);
+ SetCurrent(NULL);
}
}
@@ -90,8 +93,12 @@ GLContext* GLContext::GetCurrent() {
return current_context_.Pointer()->Get();
}
-void GLContext::SetCurrent(GLContext* context, GLSurface* surface) {
- current_context_.Pointer()->Set(context);
+GLContext* GLContext::GetRealCurrent() {
+ return current_real_context_.Pointer()->Get();
+}
+
+void GLContext::SetCurrent(GLSurface* surface) {
+ current_context_.Pointer()->Set(surface ? this : NULL);
GLSurface::SetCurrent(surface);
}
@@ -128,7 +135,12 @@ void GLContext::SetupForVirtualization() {
bool GLContext::MakeVirtuallyCurrent(
GLContext* virtual_context, GLSurface* surface) {
DCHECK(virtual_gl_api_);
- return virtual_gl_api_->MakeCurrent(virtual_context, surface);
+ bool result = virtual_gl_api_->MakeCurrent(virtual_context, surface);
+ if (result) {
+ virtual_context->SetCurrent(surface);
+ surface->OnMakeCurrent(virtual_context);
no sievers 2013/06/04 23:47:20 Wait, why add a call to surface->OnMakeCurrent() h
jonathan.backer 2013/06/05 14:02:10 Most (all?) of the implementations of GLSurface::O
+ }
+ return result;
}
void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) {
@@ -140,4 +152,15 @@ void GLContext::SetRealGLApi() {
SetGLToRealGLApi();
}
+GLContextReal::GLContextReal(GLShareGroup* share_group)
+ : GLContext(share_group) {}
+
+GLContextReal::~GLContextReal() {}
+
+void GLContextReal::SetCurrent(GLSurface* surface) {
+ GLContext::SetCurrent(surface);
+ current_real_context_.Pointer()->Set(surface ? this : NULL);
+ GLSurface::SetRealCurrent(surface);
+}
+
} // namespace gfx

Powered by Google App Engine
This is Rietveld 408576698