summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl/gl_surface.cc
diff options
context:
space:
mode:
authorkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 23:08:56 +0000
committerkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 23:08:56 +0000
commitc777de5b0773fad970c88b748c237120e5d6d563 (patch)
tree9eac25d954ce3d7b8ac39b2de428546d3350da94 /ui/gfx/gl/gl_surface.cc
parentc257d0561bfaf52c37fcbc3cc2f9b457836b8db5 (diff)
downloadchromium_src-c777de5b0773fad970c88b748c237120e5d6d563.zip
chromium_src-c777de5b0773fad970c88b748c237120e5d6d563.tar.gz
chromium_src-c777de5b0773fad970c88b748c237120e5d6d563.tar.bz2
Keep track of the current per-thread context and surface. Add
ScopedMakeCurrent to make it easier to briefly make another context current. Use it in AcceleratedSurface implementation and verify in the caller that it is working. This infrastructure would have made it possible to catch http://crbug.com/95492 and similar bugs where the wrong context was current. BUG=95962 TEST=ran CSS 3D example poster-circle; no assertion failures Review URL: http://codereview.chromium.org/7787022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/gl_surface.cc')
-rw-r--r--ui/gfx/gl/gl_surface.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/gfx/gl/gl_surface.cc b/ui/gfx/gl/gl_surface.cc
index 399d816..a0e881d 100644
--- a/ui/gfx/gl/gl_surface.cc
+++ b/ui/gfx/gl/gl_surface.cc
@@ -4,14 +4,19 @@
#include "ui/gfx/gl/gl_surface.h"
+#include "base/threading/thread_local.h"
#include "ui/gfx/gl/gl_context.h"
namespace gfx {
+static base::ThreadLocalPointer<GLSurface> current_surface_;
+
GLSurface::GLSurface() {
}
GLSurface::~GLSurface() {
+ if (GetCurrent() == this)
+ SetCurrent(NULL);
}
bool GLSurface::Initialize()
@@ -26,4 +31,12 @@ unsigned int GLSurface::GetBackingFrameBufferObject() {
void GLSurface::OnMakeCurrent(GLContext* context) {
}
+GLSurface* GLSurface::GetCurrent() {
+ return current_surface_.Get();
+}
+
+void GLSurface::SetCurrent(GLSurface* surface) {
+ current_surface_.Set(surface);
+}
+
} // namespace gfx