Bug 1390386 - Remove old TLS current-context check. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 11 Aug 2017 13:41:31 -0700
changeset 702515 1845f4548f69e6ba9d374bae91f8474651494c4b
parent 702514 de1888550aaecd11c6bb6f2823461c853f7ce679
child 702516 dbc0e03cf34882d45606212bb838def7102622ff
push id90545
push userbmo:jgilbert@mozilla.com
push dateThu, 23 Nov 2017 11:45:26 +0000
reviewersdaoshengmu
bugs1390386
milestone59.0a1
Bug 1390386 - Remove old TLS current-context check. - r=daoshengmu MozReview-Commit-ID: 18GSNztjkTM
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/thebes/gfxPlatform.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -55,20 +55,16 @@
 #endif
 
 namespace mozilla {
 namespace gl {
 
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
-#ifdef MOZ_GL_DEBUG
-unsigned GLContext::sCurrentGLContextTLS = -1;
-#endif
-
 MOZ_THREAD_LOCAL(const GLContext*) GLContext::sCurrentContext;
 
 // If adding defines, don't forget to undefine symbols. See #undef block below.
 #define CORE_SYMBOL(x) { (PRFuncPtr*) &mSymbols.f##x, { #x, nullptr } }
 #define CORE_EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x, #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL3(x,y,z,w) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, #x #w, nullptr } }
 #define END_SYMBOLS { nullptr, { nullptr } }
@@ -3030,30 +3026,16 @@ GetBytesPerTexel(GLenum format, GLenum t
 }
 
 bool
 GLContext::MakeCurrent(bool aForce) const
 {
     if (MOZ_UNLIKELY( IsDestroyed() ))
         return false;
 
-#ifdef MOZ_GL_DEBUG
-    PR_SetThreadPrivate(sCurrentGLContextTLS, (void*)this);
-
-    // XXX this assertion is disabled because it's triggering on Mac;
-    // we need to figure out why and reenable it.
-#if 0
-    // IsOwningThreadCurrent is a bit of a misnomer;
-    // the "owning thread" is the creation thread,
-    // and the only thread that can own this.  We don't
-    // support contexts used on multiple threads.
-    NS_ASSERTION(IsOwningThreadCurrent(),
-                 "MakeCurrent() called on different thread than this context was created on!");
-#endif
-#endif
     if (mUseTLSIsCurrent && !aForce && sCurrentContext.get() == this) {
         MOZ_ASSERT(IsCurrent());
         return true;
     }
 
     if (!MakeCurrentImpl(aForce))
         return false;
 
@@ -3082,24 +3064,16 @@ GLContext::BeforeGLCall_Debug(const char
 {
     MOZ_ASSERT(mDebugFlags);
 
     FlushErrors();
 
     if (mDebugFlags & DebugFlagTrace) {
         printf_stderr("[gl:%p] > %s\n", this, funcName);
     }
-
-    GLContext* tlsContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
-    if (this != tlsContext) {
-        printf_stderr("Fatal: %s called on non-current context %p. The"
-                      " current context for this thread is %p.\n",
-                      funcName, this, tlsContext);
-        MOZ_CRASH("GFX: GLContext is not current.");
-    }
 }
 
 void
 GLContext::AfterGLCall_Debug(const char* const funcName) const
 {
     MOZ_ASSERT(mDebugFlags);
 
     // calling fFinish() immediately after every GL call makes sure that if this GL command crashes,
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -3307,22 +3307,16 @@ public:
 // -----------------------------------------------------------------------------
 // Everything that isn't standard GL APIs
 protected:
     typedef gfx::SurfaceFormat SurfaceFormat;
 
     virtual bool MakeCurrentImpl(bool aForce) const = 0;
 
 public:
-#ifdef MOZ_GL_DEBUG
-    static void StaticInit() {
-        PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr);
-    }
-#endif
-
     bool MakeCurrent(bool aForce = false) const;
 
     virtual bool Init() = 0;
 
     virtual bool SetupLookupFunction() = 0;
 
     virtual void ReleaseSurface() {}
 
@@ -3456,25 +3450,16 @@ public:
 protected:
     RefPtr<GLContext> mSharedContext;
 
     // The thread id which this context was created.
     PlatformThreadId mOwningThreadId;
 
     GLContextSymbols mSymbols;
 
-#ifdef MOZ_GL_DEBUG
-    // Non-zero debug flags will check that we don't send call
-    // to a GLContext that isn't current on the current
-    // thread.
-    // Store the current context when binding to thread local
-    // storage to support debug flags on an arbitrary thread.
-    static unsigned sCurrentGLContextTLS;
-#endif
-
     UniquePtr<GLBlitHelper> mBlitHelper;
     UniquePtr<GLReadTexImageHelper> mReadTexImageHelper;
 
 public:
     GLBlitHelper* BlitHelper();
     GLBlitTextureImageHelper* BlitTextureImageHelper();
     GLReadTexImageHelper* ReadTexImageHelper();
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -770,20 +770,16 @@ gfxPlatform::Init()
 
 #ifdef USE_SKIA
     SkGraphics::Init();
 #  ifdef MOZ_ENABLE_FREETYPE
     SkInitCairoFT(gPlatform->FontHintingEnabled());
 #  endif
 #endif
 
-#ifdef MOZ_GL_DEBUG
-    GLContext::StaticInit();
-#endif
-
     InitLayersIPC();
 
     gPlatform->PopulateScreenInfo();
     gPlatform->ComputeTileSize();
 
     nsresult rv;
     rv = gfxPlatformFontList::Init();
     if (NS_FAILED(rv)) {