diff options
-rw-r--r-- | samplecode/SampleDecode.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/debug/GrDebugGL.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/debug/GrDebugGL.h | 25 | ||||
-rw-r--r-- | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp | 5 |
4 files changed, 34 insertions, 6 deletions
diff --git a/samplecode/SampleDecode.cpp b/samplecode/SampleDecode.cpp index 9188257b2d..fa2b72718a 100644 --- a/samplecode/SampleDecode.cpp +++ b/samplecode/SampleDecode.cpp @@ -27,7 +27,7 @@ class DecodeView : public SkView { public: SkBitmap fBitmap[SK_ARRAY_COUNT(gRec)]; - DecodeView() { + DecodeView() { SkFILEStream stream("/skimages/index.png"); SkImageDecoder* codec = SkImageDecoder::Factory(&stream); if (codec) { @@ -37,6 +37,7 @@ public: codec->decode(&stream, &fBitmap[i], gRec[i].fPrefConfig, SkImageDecoder::kDecodePixels_Mode); } + SkDELETE(codec); } } diff --git a/src/gpu/gl/debug/GrDebugGL.cpp b/src/gpu/gl/debug/GrDebugGL.cpp index c4cfe896fc..657003967f 100644 --- a/src/gpu/gl/debug/GrDebugGL.cpp +++ b/src/gpu/gl/debug/GrDebugGL.cpp @@ -16,7 +16,8 @@ #include "GrTextureUnitObj.h" -GrDebugGL GrDebugGL::Obj; +GrDebugGL* GrDebugGL::gObj = NULL; +int GrDebugGL::gStaticRefCount = 0; GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = { GrTextureObj::createGrTextureObj, GrBufferObj::createGrBufferObj, @@ -40,7 +41,9 @@ GrDebugGL::GrDebugGL() , fTexture(NULL) { for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { - fTextureUnits[i] = GR_CREATE(GrTextureUnitObj, GrDebugGL::kTextureUnit_ObjTypes); + + fTextureUnits[i] = reinterpret_cast<GrTextureUnitObj *>( + createObj(GrDebugGL::kTextureUnit_ObjTypes)); fTextureUnits[i]->ref(); fTextureUnits[i]->setNumber(i); diff --git a/src/gpu/gl/debug/GrDebugGL.h b/src/gpu/gl/debug/GrDebugGL.h index 4e714ee258..d6697fd211 100644 --- a/src/gpu/gl/debug/GrDebugGL.h +++ b/src/gpu/gl/debug/GrDebugGL.h @@ -84,13 +84,31 @@ public: GrGLint getUnPackRowLength() const { return fUnPackRowLength; } static GrDebugGL *getInstance() { -// static GrDebugGL Obj; + // someone should admit to actually using this class + GrAssert(0 < gStaticRefCount); - return &Obj; + if (NULL == gObj) { + gObj = SkNEW(GrDebugGL); + } + + return gObj; } void report() const; + static void staticRef() { + gStaticRefCount++; + } + + static void staticUnRef() { + GrAssert(gStaticRefCount > 0); + gStaticRefCount--; + if (0 == gStaticRefCount) { + SkDELETE(gObj); + gObj = NULL; + } + } + protected: private: @@ -113,7 +131,8 @@ private: static Create gFactoryFunc[kObjTypeCount]; - static GrDebugGL Obj; + static GrDebugGL* gObj; + static int gStaticRefCount; // global store of all objects SkTArray<GrFakeRefObj *> fObjects; diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index 22f32dcda1..3f58cc69da 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -1280,6 +1280,11 @@ public: GrDebugGLInterface() : fWrapped(NULL) { + GrDebugGL::staticRef(); + } + + virtual ~GrDebugGLInterface() { + GrDebugGL::staticUnRef(); } void setWrapped(GrGLInterface *interface) { |