public:
SkBitmap fBitmap[SK_ARRAY_COUNT(gRec)];
- DecodeView() {
+ DecodeView() {
SkFILEStream stream("/skimages/index.png");
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
if (codec) {
codec->decode(&stream, &fBitmap[i], gRec[i].fPrefConfig,
SkImageDecoder::kDecodePixels_Mode);
}
+ SkDELETE(codec);
}
}
#include "GrTextureUnitObj.h"
-GrDebugGL GrDebugGL::Obj;
+GrDebugGL* GrDebugGL::gObj = NULL;
+int GrDebugGL::gStaticRefCount = 0;
GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = {
GrTextureObj::createGrTextureObj,
GrBufferObj::createGrBufferObj,
, 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);
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:
static Create gFactoryFunc[kObjTypeCount];
- static GrDebugGL Obj;
+ static GrDebugGL* gObj;
+ static int gStaticRefCount;
// global store of all objects
SkTArray<GrFakeRefObj *> fObjects;
GrDebugGLInterface()
: fWrapped(NULL) {
+ GrDebugGL::staticRef();
+ }
+
+ virtual ~GrDebugGLInterface() {
+ GrDebugGL::staticUnRef();
}
void setWrapped(GrGLInterface *interface) {