Switch GrGpu's GrResource list over to using SkTDLinkedList
https://codereview.appspot.com/6500062/ git-svn-id: http://skia.googlecode.com/svn/trunk@5379 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
b78765e63b
commit
9474ed0617
@ -48,6 +48,7 @@ public:
|
||||
}
|
||||
|
||||
void remove(T* entry) {
|
||||
SkASSERT(NULL != fHead && NULL != fTail);
|
||||
SkASSERT(this->isInList(entry));
|
||||
|
||||
T* prev = entry->fPrev;
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "GrRefCnt.h"
|
||||
|
||||
#include "SkTDLinkedList.h"
|
||||
|
||||
class GrGpu;
|
||||
class GrContext;
|
||||
class GrResourceEntry;
|
||||
@ -80,14 +82,17 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
friend class GrGpu; // GrGpu manages list of resources.
|
||||
#if GR_DEBUG
|
||||
friend class GrGpu; // for assert in GrGpu to access getGpu
|
||||
#endif
|
||||
|
||||
GrGpu* fGpu; // not reffed. The GrGpu can be deleted while there
|
||||
// are still live GrResources. It will call
|
||||
// release() on all such resources in its
|
||||
// destructor.
|
||||
GrResource* fNext; // dl-list of resources per-GrGpu
|
||||
GrResource* fPrevious;
|
||||
|
||||
// we're a dlinklist
|
||||
SK_DEFINE_DLINKEDLIST_INTERFACE(GrResource);
|
||||
|
||||
GrResourceEntry* fCacheEntry; // NULL if not in cache
|
||||
|
||||
|
@ -37,8 +37,7 @@ GrGpu::GrGpu()
|
||||
, fIndexPoolUseCnt(0)
|
||||
, fQuadIndexBuffer(NULL)
|
||||
, fUnitSquareVertexBuffer(NULL)
|
||||
, fContextIsDirty(true)
|
||||
, fResourceHead(NULL) {
|
||||
, fContextIsDirty(true) {
|
||||
|
||||
fClipMaskManager.setGpu(this);
|
||||
|
||||
@ -68,8 +67,8 @@ void GrGpu::abandonResources() {
|
||||
|
||||
fClipMaskManager.releaseResources();
|
||||
|
||||
while (NULL != fResourceHead) {
|
||||
fResourceHead->abandon();
|
||||
while (NULL != fResourceList.head()) {
|
||||
fResourceList.head()->abandon();
|
||||
}
|
||||
|
||||
GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
|
||||
@ -87,8 +86,8 @@ void GrGpu::releaseResources() {
|
||||
|
||||
fClipMaskManager.releaseResources();
|
||||
|
||||
while (NULL != fResourceHead) {
|
||||
fResourceHead->release();
|
||||
while (NULL != fResourceList.head()) {
|
||||
fResourceList.head()->release();
|
||||
}
|
||||
|
||||
GrAssert(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid());
|
||||
@ -105,33 +104,15 @@ void GrGpu::releaseResources() {
|
||||
void GrGpu::insertResource(GrResource* resource) {
|
||||
GrAssert(NULL != resource);
|
||||
GrAssert(this == resource->getGpu());
|
||||
GrAssert(NULL == resource->fNext);
|
||||
GrAssert(NULL == resource->fPrevious);
|
||||
|
||||
resource->fNext = fResourceHead;
|
||||
if (NULL != fResourceHead) {
|
||||
GrAssert(NULL == fResourceHead->fPrevious);
|
||||
fResourceHead->fPrevious = resource;
|
||||
}
|
||||
fResourceHead = resource;
|
||||
fResourceList.addToHead(resource);
|
||||
}
|
||||
|
||||
void GrGpu::removeResource(GrResource* resource) {
|
||||
GrAssert(NULL != resource);
|
||||
GrAssert(NULL != fResourceHead);
|
||||
GrAssert(this == resource->getGpu());
|
||||
|
||||
if (fResourceHead == resource) {
|
||||
GrAssert(NULL == resource->fPrevious);
|
||||
fResourceHead = resource->fNext;
|
||||
} else {
|
||||
GrAssert(NULL != fResourceHead);
|
||||
resource->fPrevious->fNext = resource->fNext;
|
||||
}
|
||||
if (NULL != resource->fNext) {
|
||||
resource->fNext->fPrevious = resource->fPrevious;
|
||||
}
|
||||
resource->fNext = NULL;
|
||||
resource->fPrevious = NULL;
|
||||
fResourceList.remove(resource);
|
||||
}
|
||||
|
||||
|
||||
|
@ -554,7 +554,8 @@ private:
|
||||
|
||||
bool fContextIsDirty;
|
||||
|
||||
GrResource* fResourceHead;
|
||||
typedef SkTDLinkedList<GrResource> ResourceList;
|
||||
ResourceList fResourceList;
|
||||
|
||||
// Given a rt, find or create a stencil buffer and attach it
|
||||
bool attachStencilBufferToRenderTarget(GrRenderTarget* target);
|
||||
|
@ -14,8 +14,6 @@ SK_DEFINE_INST_COUNT(GrResource)
|
||||
|
||||
GrResource::GrResource(GrGpu* gpu) {
|
||||
fGpu = gpu;
|
||||
fNext = NULL;
|
||||
fPrevious = NULL;
|
||||
fCacheEntry = NULL;
|
||||
fGpu->insertResource(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user