Bug 704839 - [3/9] - Refactor mutual ownership of WebGL objects - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Sun, 04 Dec 2011 14:15:42 -0500
changeset 82003 539c05fd263cdd8362c8531d1f78c93e4539fad1
parent 82002 cba3b08c4bac7f659968be87198815e0a1acb4ac
child 82004 e8de56f450c95cc9b4d7f77b1950535e1764ed6a
push idunknown
push userunknown
push dateunknown
reviewersjgilbert
bugs704839
milestone11.0a1
Bug 704839 - [3/9] - Refactor mutual ownership of WebGL objects - r=jgilbert This patch renames GLuint mName to mGLName for consistency.
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLContextValidate.cpp
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -1092,17 +1092,17 @@ protected:
 class WebGLBuffer :
     public nsIWebGLBuffer,
     public WebGLZeroingObject<8>, // almost never has more than 8 owners
     public WebGLContextBoundObject
 {
 public:
     WebGLBuffer(WebGLContext *context, WebGLuint name) :
         WebGLContextBoundObject(context),
-        mName(name), mDeleted(false), mHasEverBeenBound(false),
+        mGLName(name), mDeleted(false), mHasEverBeenBound(false),
         mByteLength(0), mTarget(LOCAL_GL_NONE), mData(nsnull)
     {}
 
     ~WebGLBuffer() {
         Delete();
     }
 
     void Delete() {
@@ -1115,17 +1115,17 @@ public:
 
         mDeleted = true;
         mByteLength = 0;
     }
 
     bool Deleted() const { return mDeleted; }
     bool HasEverBeenBound() { return mHasEverBeenBound; }
     void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
-    GLuint GLName() const { return mName; }
+    GLuint GLName() const { return mGLName; }
     GLuint ByteLength() const { return mByteLength; }
     GLenum Target() const { return mTarget; }
     const void *Data() const { return mData; }
 
     void SetByteLength(GLuint byteLength) { mByteLength = byteLength; }
     void SetTarget(GLenum target) { mTarget = target; }
 
     // element array buffers are the only buffers for which we need to keep a copy of the data.
@@ -1200,17 +1200,17 @@ public:
         mCachedMaxUshortElement = FindMaxElementInSubArray<GLshort>(mByteLength>>1, 0);
         return mCachedMaxUshortElement;
       }
     }
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBGLBUFFER
 protected:
-    WebGLuint mName;
+    WebGLuint mGLName;
     bool mDeleted;
     bool mHasEverBeenBound;
     GLuint mByteLength;
     GLenum mTarget;
 
     PRUint8 mCachedMaxUbyteElement;
     bool mHasCachedMaxUbyteElement;
     PRUint16 mCachedMaxUshortElement;
@@ -1224,17 +1224,17 @@ class WebGLTexture :
     public nsIWebGLTexture,
     public WebGLZeroingObject<8>, // almost never has more than 8 owners
     public WebGLContextBoundObject
 {
 public:
 
     WebGLTexture(WebGLContext *context, WebGLuint name) :
         WebGLContextBoundObject(context),
-        mDeleted(false), mHasEverBeenBound(false), mName(name),
+        mDeleted(false), mHasEverBeenBound(false), mGLName(name),
         mTarget(0),
         mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR),
         mMagFilter(LOCAL_GL_LINEAR),
         mWrapS(LOCAL_GL_REPEAT),
         mWrapT(LOCAL_GL_REPEAT),
         mFacesCount(0),
         mMaxLevelWithCustomImages(0),
         mHaveGeneratedMipmap(false),
@@ -1247,28 +1247,28 @@ public:
             return;
         ZeroOwners();
         mDeleted = true;
     }
 
     bool Deleted() { return mDeleted; }
     bool HasEverBeenBound() { return mHasEverBeenBound; }
     void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
-    WebGLuint GLName() { return mName; }
+    WebGLuint GLName() { return mGLName; }
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBGLTEXTURE
 
 protected:
     friend class WebGLContext;
     friend class WebGLFramebuffer;
 
     bool mDeleted;
     bool mHasEverBeenBound;
-    WebGLuint mName;
+    WebGLuint mGLName;
 
     // we store information about the various images that are part of
     // this texture (cubemap faces, mipmap levels)
 
 public:
 
     struct ImageInfo {
         ImageInfo() : mWidth(0), mHeight(0), mFormat(0), mType(0), mIsDefined(false) {}
@@ -1412,17 +1412,17 @@ public:
             mContext->ErrorInvalidOperation("bindTexture: this texture has already been bound to a different target");
             // very important to return here before modifying texture state! This was the place when I lost a whole day figuring
             // very strange 'invalid write' crashes.
             return;
         }
 
         mTarget = aTarget;
 
-        mContext->gl->fBindTexture(mTarget, mName);
+        mContext->gl->fBindTexture(mTarget, mGLName);
 
         if (firstTimeThisTextureIsBound) {
             mFacesCount = (mTarget == LOCAL_GL_TEXTURE_2D) ? 1 : 6;
             EnsureMaxLevelWithCustomImagesAtLeast(0);
             SetDontKnowIfNeedFakeBlack();
 
             // thanks to the WebKit people for finding this out: GL_TEXTURE_WRAP_R is not
             // present in GLES 2, but is present in GL and it seems as if for cube maps
@@ -1658,17 +1658,17 @@ public:
 class WebGLShader :
     public nsIWebGLShader,
     public WebGLZeroingObject<8>, // almost never has more than 8 owners
     public WebGLContextBoundObject
 {
 public:
     WebGLShader(WebGLContext *context, WebGLuint name, WebGLenum stype) :
         WebGLContextBoundObject(context),
-        mName(name), mDeleted(false), mType(stype),
+        mGLName(name), mDeleted(false), mType(stype),
         mNeedsTranslation(true), mAttachCount(0),
         mDeletePending(false)
     { }
 
     void DetachedFromProgram() {
         DecrementAttachCount();
         if (mDeletePending && AttachCount() <= 0) {
             DeleteWhenNotAttached();
@@ -1692,17 +1692,17 @@ public:
             return;
 
         ZeroOwners();
         mDeleted = true;
         mDeletePending = false;
     }
 
     bool Deleted() { return mDeleted; }
-    WebGLuint GLName() { return mName; }
+    WebGLuint GLName() { return mGLName; }
     WebGLenum ShaderType() { return mType; }
 
     PRInt32 AttachCount() { return mAttachCount; }
     void IncrementAttachCount() { mAttachCount++; }
     void DecrementAttachCount() { mAttachCount--; }
 
     void SetSource(const nsAString& src) {
         // XXX do some quick gzip here maybe -- getting this will be very rare
@@ -1723,17 +1723,17 @@ public:
         mTranslationLog.Assign(msg); 
     }
 
     const nsCString& TranslationLog() const { return mTranslationLog; }
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBGLSHADER
 protected:
-    WebGLuint mName;
+    WebGLuint mGLName;
     bool mDeleted;
     WebGLenum mType;
     nsString mSource;
     nsCString mTranslationLog;
     bool mNeedsTranslation;
     PRInt32 mAttachCount;
     bool mDeletePending;
 };
@@ -1744,17 +1744,17 @@ class WebGLProgram :
                                   // but that shouldn't be performance-critical as references to the uniformlocations are stored
                                   // in mMapUniformLocations, limiting the churning
     public WebGLContextBoundObject
 {
 public:
 
     WebGLProgram(WebGLContext *context, WebGLuint name) :
         WebGLContextBoundObject(context),
-        mName(name), mDeleted(false), mDeletePending(false),
+        mGLName(name), mDeleted(false), mDeletePending(false),
         mLinkStatus(false), mGeneration(0),
         mUniformMaxNameLength(0), mAttribMaxNameLength(0),
         mUniformCount(0), mAttribCount(0)
     {
         mMapUniformLocations.Init();
     }
 
     void DeleteWhenNotCurrent() {
@@ -1795,17 +1795,17 @@ public:
         }
     }
 
     bool Deleted() { return mDeleted; }
     void SetDeletePending() { mDeletePending = true; }
     void ClearDeletePending() { mDeletePending = false; }
     bool HasDeletePending() { return mDeletePending; }
 
-    WebGLuint GLName() { return mName; }
+    WebGLuint GLName() { return mGLName; }
     const nsTArray<nsRefPtr<WebGLShader> >& AttachedShaders() const { return mAttachedShaders; }
     bool LinkStatus() { return mLinkStatus; }
     PRUint32 Generation() const { return mGeneration.value(); }
     void SetLinkStatus(bool val) { mLinkStatus = val; }
 
     bool ContainsShader(WebGLShader *shader) {
         return mAttachedShaders.Contains(shader);
     }
@@ -1863,17 +1863,17 @@ public:
     WebGLint AttribMaxNameLength() const { return mAttribMaxNameLength; }
     WebGLint UniformCount() const { return mUniformCount; }
     WebGLint AttribCount() const { return mAttribCount; }
     bool IsAttribInUse(unsigned i) const { return mAttribsInUse[i]; }
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBGLPROGRAM
 protected:
-    WebGLuint mName;
+    WebGLuint mGLName;
     bool mDeleted;
     bool mDeletePending;
     bool mLinkStatus;
     // attached shaders of the program object
     nsTArray<nsRefPtr<WebGLShader> > mAttachedShaders;
     CheckedUint32 mGeneration;
 
     // post-link data
@@ -1890,32 +1890,32 @@ class WebGLRenderbuffer :
     public WebGLZeroingObject<8>, // almost never has more than 8 owners
     public WebGLRectangleObject,
     public WebGLContextBoundObject
 {
 public:
 
     WebGLRenderbuffer(WebGLContext *context, WebGLuint name, WebGLuint secondBufferName = 0) :
         WebGLContextBoundObject(context),
-        mName(name),
+        mGLName(name),
         mInternalFormat(0),
         mInternalFormatForGL(0),
         mDeleted(false), mHasEverBeenBound(false), mInitialized(false)
     { }
 
     void Delete() {
         if (mDeleted)
             return;
         ZeroOwners();
         mDeleted = true;
     }
     bool Deleted() const { return mDeleted; }
     bool HasEverBeenBound() { return mHasEverBeenBound; }
     void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
-    WebGLuint GLName() const { return mName; }
+    WebGLuint GLName() const { return mGLName; }
 
     bool Initialized() const { return mInitialized; }
     void SetInitialized(bool aInitialized) { mInitialized = aInitialized; }
 
     WebGLenum InternalFormat() const { return mInternalFormat; }
     void SetInternalFormat(WebGLenum aInternalFormat) { mInternalFormat = aInternalFormat; }
     
     WebGLenum InternalFormatForGL() const { return mInternalFormatForGL; }
@@ -1943,17 +1943,17 @@ public:
         NS_ABORT();
         return 0;
     }
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBGLRENDERBUFFER
 
 protected:
-    WebGLuint mName;
+    WebGLuint mGLName;
     WebGLenum mInternalFormat;
     WebGLenum mInternalFormatForGL;
 
     bool mDeleted;
     bool mHasEverBeenBound;
     bool mInitialized;
 
     friend class WebGLFramebuffer;
@@ -2055,33 +2055,33 @@ class WebGLFramebuffer :
     public nsIWebGLFramebuffer,
     public WebGLZeroingObject<8>, // almost never has more than 8 owners
     public WebGLContextBoundObject
 {
 public:
 
     WebGLFramebuffer(WebGLContext *context, WebGLuint name) :
         WebGLContextBoundObject(context),
-        mName(name), mDeleted(false), mHasEverBeenBound(false),
+        mGLName(name), mDeleted(false), mHasEverBeenBound(false),
         mColorAttachment(LOCAL_GL_COLOR_ATTACHMENT0),
         mDepthAttachment(LOCAL_GL_DEPTH_ATTACHMENT),
         mStencilAttachment(LOCAL_GL_STENCIL_ATTACHMENT),
         mDepthStencilAttachment(LOCAL_GL_DEPTH_STENCIL_ATTACHMENT)
     { }
 
     void Delete() {
         if (mDeleted)
             return;
         ZeroOwners();
         mDeleted = true;
     }
     bool Deleted() { return mDeleted; }
     bool HasEverBeenBound() { return mHasEverBeenBound; }
     void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; }
-    WebGLuint GLName() { return mName; }
+    WebGLuint GLName() { return mGLName; }
     
     WebGLsizei width() { return mColorAttachment.width(); }
     WebGLsizei height() { return mColorAttachment.height(); }
 
     nsresult FramebufferRenderbuffer(WebGLenum target,
                                      WebGLenum attachment,
                                      WebGLenum rbtarget,
                                      nsIWebGLRenderbuffer *rbobj)
@@ -2304,17 +2304,17 @@ protected:
 
         if (mStencilAttachment.HasUninitializedRenderbuffer())
             mStencilAttachment.Renderbuffer()->SetInitialized(true);
 
         if (mDepthStencilAttachment.HasUninitializedRenderbuffer())
             mDepthStencilAttachment.Renderbuffer()->SetInitialized(true);
     }
 
-    WebGLuint mName;
+    WebGLuint mGLName;
     bool mDeleted;
     bool mHasEverBeenBound;
 
     // we only store pointers to attached renderbuffers, not to attached textures, because
     // we will only need to initialize renderbuffers. Textures are already initialized.
     WebGLFramebufferAttachment mColorAttachment,
                                mDepthAttachment,
                                mStencilAttachment,
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -52,39 +52,39 @@
 using namespace mozilla;
 
 /*
  * Pull all the data out of the program that will be used by validate later on
  */
 bool
 WebGLProgram::UpdateInfo(gl::GLContext *gl)
 {
-    gl->fGetProgramiv(mName, LOCAL_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &mAttribMaxNameLength);
-    gl->fGetProgramiv(mName, LOCAL_GL_ACTIVE_UNIFORM_MAX_LENGTH, &mUniformMaxNameLength);
-    gl->fGetProgramiv(mName, LOCAL_GL_ACTIVE_UNIFORMS, &mUniformCount);
-    gl->fGetProgramiv(mName, LOCAL_GL_ACTIVE_ATTRIBUTES, &mAttribCount);
+    gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &mAttribMaxNameLength);
+    gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_UNIFORM_MAX_LENGTH, &mUniformMaxNameLength);
+    gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_UNIFORMS, &mUniformCount);
+    gl->fGetProgramiv(mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES, &mAttribCount);
 
     GLint numVertexAttribs;
     if (mContext->MinCapabilityMode())  {
         numVertexAttribs = MINVALUE_GL_MAX_VERTEX_ATTRIBS;
     } else {
         gl->fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
     }
     mAttribsInUse.clear();
     mAttribsInUse.resize(numVertexAttribs);
 
     nsAutoArrayPtr<char> nameBuf(new char[mAttribMaxNameLength]);
 
     for (int i = 0; i < mAttribCount; ++i) {
         GLint attrnamelen;
         GLint attrsize;
         GLenum attrtype;
-        gl->fGetActiveAttrib(mName, i, mAttribMaxNameLength, &attrnamelen, &attrsize, &attrtype, nameBuf);
+        gl->fGetActiveAttrib(mGLName, i, mAttribMaxNameLength, &attrnamelen, &attrsize, &attrtype, nameBuf);
         if (attrnamelen > 0) {
-            GLint loc = gl->fGetAttribLocation(mName, nameBuf);
+            GLint loc = gl->fGetAttribLocation(mGLName, nameBuf);
             mAttribsInUse[loc] = true;
         }
     }
 
     return true;
 }
 
 /*