aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-16 16:24:35 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-16 16:24:35 +0000
commit0dd84a399ae8903784eac1c361c08449f822307f (patch)
tree18ce74bcc7e823ffacbc23c6601d18d2f745920a
parent6853e808a464ca75ff1328338d1eb55ff27c4337 (diff)
Minor code cleanup of Debug GL Interface
-rw-r--r--gyp/gpu.gyp1
-rw-r--r--src/gpu/gl/debug/GrBufferObj.cpp22
-rw-r--r--src/gpu/gl/debug/GrBufferObj.h45
-rw-r--r--src/gpu/gl/debug/GrFakeRefObj.cpp9
-rw-r--r--src/gpu/gl/debug/GrFakeRefObj.h24
-rw-r--r--src/gpu/gl/debug/GrProgramObj.h54
-rw-r--r--src/gpu/gl/debug/GrShaderObj.cpp5
-rw-r--r--src/gpu/gl/debug/GrShaderObj.h11
-rw-r--r--src/gpu/gl/debug/GrTextureObj.cpp7
-rw-r--r--src/gpu/gl/debug/GrTextureObj.h5
10 files changed, 92 insertions, 91 deletions
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index df8fb7bba8..026f3b937f 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 0cd4fc8068..7d605ebef1 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 e4cfee2a0e..c41cb1fe14 100644
--- a/src/gpu/gl/debug/GrBufferObj.h
+++ b/src/gpu/gl/debug/GrBufferObj.h
@@ -33,41 +33,22 @@ public:
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 @@ private:
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 508f5c34ae..0000000000
--- 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 8dbef9cb59..81fb90c4d0 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 @@ public:
, 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 @@ public:
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 @@ public:
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 d83eab8805..eebcc88850 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 60c6903ecb..8d3caa1e3f 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 ca6ccdc048..200c8b650c 100644
--- a/src/gpu/gl/debug/GrShaderObj.h
+++ b/src/gpu/gl/debug/GrShaderObj.h
@@ -18,15 +18,12 @@ class GrShaderObj : public GrFakeRefObj {
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 24284d43be..86063fbc99 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 922c9853cb..0443ab7c7a 100644
--- a/src/gpu/gl/debug/GrTextureObj.h
+++ b/src/gpu/gl/debug/GrTextureObj.h
@@ -43,10 +43,7 @@ public:
return 0 != fTextureUnitReferees.count();
}
- virtual void deleteAction() SK_OVERRIDE {
-
- this->INHERITED::deleteAction();
- }
+ virtual void deleteAction() SK_OVERRIDE;
protected: