Bug 942507 - GLContext doesn't need to have userdata. r=bjacob
authorDan Glastonbury <dglastonbury@mozilla.com>
Fri, 06 Dec 2013 10:23:16 -0500
changeset 173879 013d080dbc299471934d0252d3dd45d7188b2376
parent 173878 906f5a72000038420ef7a7854569a1e6457dfb6d
child 173880 b76e788fa2171a90855b5c7a6b4c8a9752bb5a46
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs942507
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 942507 - GLContext doesn't need to have userdata. r=bjacob
gfx/gl/GLContext.h
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/OGLShaderProgram.cpp
gfx/layers/opengl/OGLShaderProgram.h
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2410,26 +2410,16 @@ public:
 #endif
         return MakeCurrentImpl(aForce);
     }
 
     virtual bool SetupLookupFunction() = 0;
 
     virtual void ReleaseSurface() {}
 
-    void *GetUserData(void *aKey) {
-        void *result = nullptr;
-        mUserData.Get(aKey, &result);
-        return result;
-    }
-
-    void SetUserData(void *aKey, void *aValue) {
-        mUserData.Put(aKey, aValue);
-    }
-
     // Mark this context as destroyed.  This will nullptr out all
     // the GL function pointers!
     void MarkDestroyed();
 
     bool IsDestroyed() {
         // MarkDestroyed will mark all these as null.
         return mSymbols.fUseProgram == nullptr;
     }
@@ -2905,18 +2895,16 @@ public:
         return mTexGarbageBin;
     }
 
     void EmptyTexGarbageBin();
 
     bool IsOffscreenSizeAllowed(const gfxIntSize& aSize) const;
 
 protected:
-    nsDataHashtable<nsPtrHashKey<void>, void*> mUserData;
-
     GLuint mReadTextureImagePrograms[4];
 
     bool InitWithPrefix(const char *prefix, bool trygl);
 
     void InitExtensions();
 
     nsTArray<nsIntRect> mViewportStack;
     nsTArray<nsIntRect> mScissorStack;
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -228,20 +228,16 @@ FPSState::DrawFPS(TimeStamp aNow,
   aProgram->SetRenderOffset(0, 0);
 
   aContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ZERO,
                                LOCAL_GL_ONE, LOCAL_GL_ZERO);
 
   DrawQuads(aContext, mVBOs, aProgram, rects);
 }
 
-#ifdef CHECK_CURRENT_PROGRAM
-int ShaderProgramOGL::sCurrentProgramKey = 0;
-#endif
-
 CompositorOGL::CompositorOGL(nsIWidget *aWidget, int aSurfaceWidth,
                              int aSurfaceHeight, bool aUseExternalSurfaceSize)
   : mWidget(aWidget)
   , mWidgetSize(-1, -1)
   , mSurfaceSize(aSurfaceWidth, aSurfaceHeight)
   , mHasBGRA(0)
   , mUseExternalSurfaceSize(aUseExternalSurfaceSize)
   , mFrameInProgress(false)
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -444,19 +444,17 @@ ShaderProgramOGL::Activate()
   if (mProgramState == STATE_NEW) {
     if (!Initialize()) {
       NS_WARNING("Shader could not be initialised");
       return;
     }
   }
   NS_ASSERTION(HasInitialized(), "Attempting to activate a program that's not in use!");
   mGL->fUseProgram(mProgram);
-#if CHECK_CURRENT_PROGRAM
-  mGL->SetUserData(&sCurrentProgramKey, this);
-#endif
+
   // check and set the projection matrix
   if (mIsProjectionMatrixStale) {
     SetProjectionMatrix(mProjectionMatrix);
   }
 }
 
 
 void
--- a/gfx/layers/opengl/OGLShaderProgram.h
+++ b/gfx/layers/opengl/OGLShaderProgram.h
@@ -194,21 +194,24 @@ private:
     mHasMatrixProj(false) {}
 };
 
 
 #if defined(DEBUG)
 #define CHECK_CURRENT_PROGRAM 1
 #define ASSERT_THIS_PROGRAM                                             \
   do {                                                                  \
-    NS_ASSERTION(mGL->GetUserData(&sCurrentProgramKey) == this, \
+    GLuint currentProgram;                                              \
+    mGL->GetUIntegerv(LOCAL_GL_CURRENT_PROGRAM, &currentProgram);       \
+    NS_ASSERTION(currentProgram == mProgram,                            \
                  "SetUniform with wrong program active!");              \
   } while (0)
 #else
-#define ASSERT_THIS_PROGRAM
+#define ASSERT_THIS_PROGRAM                                             \
+  do { } while (0)
 #endif
 
 /**
  * Represents an OGL shader program. The details of a program are represented
  * by a ProgramProfileOGL
  */
 class ShaderProgramOGL
 {
@@ -380,19 +383,16 @@ protected:
   ProgramProfileOGL mProfile;
   enum {
     STATE_NEW,
     STATE_OK,
     STATE_ERROR
   } mProgramState;
 
   GLint mTexCoordMultiplierUniformLocation;
-#ifdef CHECK_CURRENT_PROGRAM
-  static int sCurrentProgramKey;
-#endif
 
   void SetUniform(GLint aLocation, float aFloatValue);
   void SetUniform(GLint aLocation, const gfxRGBA& aColor);
   void SetUniform(GLint aLocation, int aLength, float *aFloatValues);
   void SetUniform(GLint aLocation, GLint aIntValue);
   void SetMatrixUniform(GLint aLocation, const gfx3DMatrix& aMatrix);
   void SetMatrixUniform(GLint aLocation, const float *aFloatValues);