Bug 1390386 - Remove old TLS current-context check. - r=daoshengmu
MozReview-Commit-ID: 18GSNztjkTM
--- 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 } }
@@ -3023,30 +3019,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;
@@ -3075,24 +3057,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
@@ -3291,22 +3291,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() {}
@@ -3440,25 +3434,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
@@ -735,20 +735,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)) {