Minor code cleanup of Debug GL Interface

http://codereview.appspot.com/6032043/



git-svn-id: http://skia.googlecode.com/svn/trunk@3690 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index df8fb7b..026f3b9 100644
--- a/gyp/gpu.gyp
+++ b/gyp/gpu.gyp
@@ -302,7 +302,6 @@
 
         '../src/gpu/gl/debug/GrGLCreateDebugInterface.cpp',
         '../src/gpu/gl/debug/GrFakeRefObj.h',
-        '../src/gpu/gl/debug/GrFakeRefObj.cpp',
         '../src/gpu/gl/debug/GrBufferObj.h',
         '../src/gpu/gl/debug/GrBufferObj.cpp',
         '../src/gpu/gl/debug/GrFBBindableObj.h',
diff --git a/src/gpu/gl/debug/GrBufferObj.cpp b/src/gpu/gl/debug/GrBufferObj.cpp
index 0cd4fc8..7d605eb 100644
--- a/src/gpu/gl/debug/GrBufferObj.cpp
+++ b/src/gpu/gl/debug/GrBufferObj.cpp
@@ -7,3 +7,25 @@
  */
 
 #include "GrBufferObj.h"
+
+void GrBufferObj::allocate(GrGLint size, const GrGLchar *dataPtr) {
+    GrAlwaysAssert(size >= 0);
+
+    // delete pre-existing data
+    delete[] fDataPtr;
+
+    fSize = size;
+    fDataPtr = new GrGLchar[size];
+    if (dataPtr) {
+        memcpy(fDataPtr, dataPtr, fSize);
+    }
+    // TODO: w/ no dataPtr the data is unitialized - this could be tracked
+}
+
+void GrBufferObj::deleteAction() {
+
+    // buffers are automatically unmapped when deleted
+    this->resetMapped();
+
+    this->INHERITED::deleteAction();
+}
diff --git a/src/gpu/gl/debug/GrBufferObj.h b/src/gpu/gl/debug/GrBufferObj.h
index e4cfee2..c41cb1f 100644
--- a/src/gpu/gl/debug/GrBufferObj.h
+++ b/src/gpu/gl/debug/GrBufferObj.h
@@ -33,41 +33,22 @@
         GrAlwaysAssert(!fMapped);
     }
 
-    void setMapped()        { fMapped = true; }
-    void resetMapped()      { fMapped = false; }
-    bool getMapped() const  { return fMapped; }
+    void setMapped()             { fMapped = true; }
+    void resetMapped()           { fMapped = false; }
+    bool getMapped() const       { return fMapped; }
 
-    void setBound()         { fBound = true; }
-    void resetBound()       { fBound = false; }
-    bool getBound() const   { return fBound; }
+    void setBound()              { fBound = true; }
+    void resetBound()            { fBound = false; }
+    bool getBound() const        { return fBound; }
 
-    void allocate(GrGLint size, const GrGLchar *dataPtr) {
-        GrAlwaysAssert(size >= 0);
+    void allocate(GrGLint size, const GrGLchar *dataPtr);
+    GrGLint getSize() const      { return fSize; }
+    GrGLchar *getDataPtr()       { return fDataPtr; }
 
-        // delete pre-existing data
-        delete[] fDataPtr;
-
-        fSize = size;
-        fDataPtr = new GrGLchar[size];
-        if (dataPtr) {
-            memcpy(fDataPtr, dataPtr, fSize);
-        }
-        // TODO: w/ no dataPtr the data is unitialized - this could be tracked
-    }
-    GrGLint getSize() const { return fSize; }
-    GrGLchar *getDataPtr()  { return fDataPtr; }
-
-    GrGLint getUsage() const { return fUsage; }
     void setUsage(GrGLint usage) { fUsage = usage; }
+    GrGLint getUsage() const     { return fUsage; }
 
-    virtual void deleteAction() SK_OVERRIDE {
-
-        // buffers are automatically unmapped when deleted
-        this->resetMapped();
-
-        this->INHERITED::deleteAction();
-    }
-
+    virtual void deleteAction() SK_OVERRIDE;
 
 protected:
 private:
@@ -76,7 +57,9 @@
     bool        fMapped;       // is the buffer object mapped via "glMapBuffer"?
     bool        fBound;        // is the buffer object bound via "glBindBuffer"?
     GrGLint     fSize;         // size in bytes
-    GrGLint     fUsage;        // one of: GL_STREAM_DRAW, GL_STATIC_DRAW, GL_DYNAMIC_DRAW
+    GrGLint     fUsage;        // one of: GL_STREAM_DRAW, 
+                               //         GL_STATIC_DRAW, 
+                               //         GL_DYNAMIC_DRAW
 
     typedef GrFakeRefObj INHERITED;
 };
diff --git a/src/gpu/gl/debug/GrFakeRefObj.cpp b/src/gpu/gl/debug/GrFakeRefObj.cpp
deleted file mode 100644
index 508f5c3..0000000
--- a/src/gpu/gl/debug/GrFakeRefObj.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-

-#include "GrFakeRefObj.h"
\ No newline at end of file
diff --git a/src/gpu/gl/debug/GrFakeRefObj.h b/src/gpu/gl/debug/GrFakeRefObj.h
index 8dbef9c..81fb90c 100644
--- a/src/gpu/gl/debug/GrFakeRefObj.h
+++ b/src/gpu/gl/debug/GrFakeRefObj.h
@@ -10,6 +10,7 @@
 #define GrFakeRefObj_DEFINED
 
 #include "gl/GrGLInterface.h"
+#include "GrNoncopyable.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // This object is used to track the OpenGL objects. We don't use real
@@ -18,7 +19,7 @@
 // are tracking in this class are actually OpenGL's references to the objects
 // not "ours"
 // Each object also gets a unique globally identifying ID
-class GrFakeRefObj {
+class GrFakeRefObj : public GrNoncopyable {
 public:
     GrFakeRefObj() 
         : fRef(0)
@@ -26,7 +27,8 @@
         , fMarkedForDeletion(false)
         , fDeleted(false) {
 
-        static int fNextID = 0;  // source for globally unique IDs - 0 is reserved!
+        // source for globally unique IDs - 0 is reserved!
+        static int fNextID = 0;  
 
         fID = ++fNextID;
     }
@@ -49,15 +51,15 @@
             this->deleteAction(); 
         }
     }
-    int getRefCount() const { return fRef; }
-    int getHighRefCount() const { return fHighRefCount; }
+    int getRefCount() const             { return fRef; }
+    int getHighRefCount() const         { return fHighRefCount; }
 
-    GrGLuint getID() const { return fID; }
+    GrGLuint getID() const              { return fID; }
 
-    void setMarkedForDeletion() { fMarkedForDeletion = true; }
-    bool getMarkedForDeletion() const { return fMarkedForDeletion; }
+    void setMarkedForDeletion()         { fMarkedForDeletion = true; }
+    bool getMarkedForDeletion() const   { return fMarkedForDeletion; }
 
-    bool getDeleted() const     { return fDeleted; }
+    bool getDeleted() const             { return fDeleted; }
 
     // The deleteAction fires if the object has been marked for deletion but
     // couldn't be deleted earlier due to refs
@@ -67,16 +69,16 @@
 
 protected:
 private:
-    int         fRef;
+    int         fRef;               // ref count
     int         fHighRefCount;      // high water mark of the ref count
-    GrGLuint    fID;
+    GrGLuint    fID;                // globally unique ID
     bool        fMarkedForDeletion;
     // The deleted flag is only set when OpenGL thinks the object is deleted
     // It is obviously still allocated w/in this framework
     bool        fDeleted;
 
     // setDeleted should only ever appear in the deleteAction method!
-    void setDeleted()           { fDeleted = true; }
+    void setDeleted()                   { fDeleted = true; }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/gl/debug/GrProgramObj.h b/src/gpu/gl/debug/GrProgramObj.h
index d83eab8..eebcc88 100644
--- a/src/gpu/gl/debug/GrProgramObj.h
+++ b/src/gpu/gl/debug/GrProgramObj.h
@@ -13,31 +13,31 @@
 #include "GrFakeRefObj.h"
 class GrShaderObj;
 
-////////////////////////////////////////////////////////////////////////////////

-class GrProgramObj : public GrFakeRefObj {

-    GR_DEFINE_CREATOR(GrProgramObj);

-

-public:

-    GrProgramObj()

-        : GrFakeRefObj()

-        , fInUse(false) {}

-

-    void AttachShader(GrShaderObj *shader);

-

-    virtual void deleteAction() SK_OVERRIDE;

-

-    // TODO: this flag system won't work w/ multiple contexts!

-    void setInUse()         { fInUse = true; }

-    void resetInUse()       { fInUse = false; }

-    bool getInUse() const   { return fInUse; }

-

-protected:

-

-private:

-    SkTArray<GrShaderObj *> fShaders;

-    bool fInUse;            // has this program been activated by a glUseProgram call?

-

-    typedef GrFakeRefObj INHERITED;

-};

-

+////////////////////////////////////////////////////////////////////////////////
+class GrProgramObj : public GrFakeRefObj {
+    GR_DEFINE_CREATOR(GrProgramObj);
+
+public:
+    GrProgramObj()
+        : GrFakeRefObj()
+        , fInUse(false) {}
+
+    void AttachShader(GrShaderObj *shader);
+
+    virtual void deleteAction() SK_OVERRIDE;
+
+    // TODO: this flag system won't work w/ multiple contexts!
+    void setInUse()         { fInUse = true; }
+    void resetInUse()       { fInUse = false; }
+    bool getInUse() const   { return fInUse; }
+
+protected:
+
+private:
+    SkTArray<GrShaderObj *> fShaders;
+    bool fInUse;            // has this program been activated by a glUseProgram call?
+
+    typedef GrFakeRefObj INHERITED;
+};
+
 #endif // GrProgramObj_DEFINED
diff --git a/src/gpu/gl/debug/GrShaderObj.cpp b/src/gpu/gl/debug/GrShaderObj.cpp
index 60c6903..8d3caa1 100644
--- a/src/gpu/gl/debug/GrShaderObj.cpp
+++ b/src/gpu/gl/debug/GrShaderObj.cpp
@@ -7,3 +7,8 @@
  */
 
 #include "GrShaderObj.h"
+
+void GrShaderObj::deleteAction() {
+
+    this->INHERITED::deleteAction();
+}
diff --git a/src/gpu/gl/debug/GrShaderObj.h b/src/gpu/gl/debug/GrShaderObj.h
index ca6ccdc..200c8b6 100644
--- a/src/gpu/gl/debug/GrShaderObj.h
+++ b/src/gpu/gl/debug/GrShaderObj.h
@@ -18,15 +18,12 @@
 public:
     GrShaderObj() 
         : GrFakeRefObj()
-        , fType(GR_GL_VERTEX_SHADER)   {}
+        , fType(GR_GL_VERTEX_SHADER)    {}
 
-    void setType(GrGLenum type) { fType = type; }
-    GrGLenum getType()  { return fType; }
+    void setType(GrGLenum type)         { fType = type; }
+    GrGLenum getType()                  { return fType; }
 
-    virtual void deleteAction() SK_OVERRIDE {
-
-        this->INHERITED::deleteAction();
-    }
+    virtual void deleteAction() SK_OVERRIDE;
 
 protected:
 private:
diff --git a/src/gpu/gl/debug/GrTextureObj.cpp b/src/gpu/gl/debug/GrTextureObj.cpp
index 24284d4..86063fb 100644
--- a/src/gpu/gl/debug/GrTextureObj.cpp
+++ b/src/gpu/gl/debug/GrTextureObj.cpp
@@ -6,4 +6,9 @@
  * found in the LICENSE file.
  */
 
-#include "GrTextureObj.h"
\ No newline at end of file
+#include "GrTextureObj.h"
+
+void GrTextureObj::deleteAction() {
+
+    this->INHERITED::deleteAction();
+}
diff --git a/src/gpu/gl/debug/GrTextureObj.h b/src/gpu/gl/debug/GrTextureObj.h
index 922c985..0443ab7 100644
--- a/src/gpu/gl/debug/GrTextureObj.h
+++ b/src/gpu/gl/debug/GrTextureObj.h
@@ -43,10 +43,7 @@
         return 0 != fTextureUnitReferees.count();
     }
 
-    virtual void deleteAction() SK_OVERRIDE {
-
-        this->INHERITED::deleteAction();
-    }
+    virtual void deleteAction() SK_OVERRIDE;
 
 protected: