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
This commit is contained in:
robertphillips@google.com 2012-04-16 16:24:35 +00:00
Родитель 6853e808a4
Коммит 0dd84a399a
10 изменённых файлов: 92 добавлений и 91 удалений

Просмотреть файл

@ -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',

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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"

Просмотреть файл

@ -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; }
};
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -7,3 +7,8 @@
*/
#include "GrShaderObj.h"
void GrShaderObj::deleteAction() {
this->INHERITED::deleteAction();
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -7,3 +7,8 @@
*/
#include "GrTextureObj.h"
void GrTextureObj::deleteAction() {
this->INHERITED::deleteAction();
}

Просмотреть файл

@ -43,10 +43,7 @@ public:
return 0 != fTextureUnitReferees.count();
}
virtual void deleteAction() SK_OVERRIDE {
this->INHERITED::deleteAction();
}
virtual void deleteAction() SK_OVERRIDE;
protected: