summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl/gl_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/gl/gl_context.cc')
-rw-r--r--ui/gfx/gl/gl_context.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc
index 87379bf..6c25052e 100644
--- a/ui/gfx/gl/gl_context.cc
+++ b/ui/gfx/gl/gl_context.cc
@@ -6,13 +6,17 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/threading/thread_local.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/gl/gl_surface.h"
#include "ui/gfx/gl/gl_switches.h"
namespace gfx {
+static base::ThreadLocalPointer<GLContext> current_context_;
+
GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
if (!share_group_.get())
share_group_ = new GLShareGroup;
@@ -22,6 +26,9 @@ GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
GLContext::~GLContext() {
share_group_->RemoveContext(this);
+ if (GetCurrent() == this) {
+ SetCurrent(NULL, NULL);
+ }
}
std::string GLContext::GetExtensions() {
@@ -61,6 +68,15 @@ bool GLContext::LosesAllContextsOnContextLost()
}
}
+GLContext* GLContext::GetCurrent() {
+ return current_context_.Get();
+}
+
+void GLContext::SetCurrent(GLContext* context, GLSurface* surface) {
+ current_context_.Set(context);
+ GLSurface::SetCurrent(surface);
+}
+
bool GLContext::WasAllocatedUsingARBRobustness() {
return false;
}