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

Unified Diff: ui/gl/gl_context.cc

Issue 221433004: gpu: Bind dummy GL API when no context is current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 cd9a28c387dcfabd66c18b7ccf7bbd3b88c3ff44..6003dee17eaa2c7133705cde9ad5c55365ba5ca7 100644
--- a/ui/gl/gl_context.cc
+++ b/ui/gl/gl_context.cc
@@ -26,6 +26,25 @@ base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
current_real_context_ = LAZY_INSTANCE_INITIALIZER;
} // namespace
+GLContext::ScopedReleaseCurrent::ScopedReleaseCurrent(GLContext* context,
+ GLSurface* surface)
+ : context_(context), surface_(surface) {
+ DCHECK(context && surface);
+ DCHECK(context->IsCurrent(surface));
+}
+
+GLContext::ScopedReleaseCurrent::~ScopedReleaseCurrent() {
+ if (surface_) {
+ DCHECK(context_);
+ context_->ReleaseCurrent(surface_);
+ }
+}
+
+void GLContext::ScopedReleaseCurrent::Release() {
+ context_ = NULL;
+ surface_ = NULL;
+}
+
GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
if (!share_group_.get())
share_group_ = new GLShareGroup;
@@ -125,6 +144,8 @@ GLContext* GLContext::GetRealCurrent() {
void GLContext::SetCurrent(GLSurface* surface) {
current_context_.Pointer()->Set(surface ? this : NULL);
GLSurface::SetCurrent(surface);
+ if (!surface)
+ SetGLApiToNoContext();
}
GLStateRestorer* GLContext::GetGLStateRestorer() {

Powered by Google App Engine
This is Rietveld 408576698