From 089a780c3355129eefc942246534bc1f126b8ccb Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Fri, 2 May 2014 21:38:22 +0000 Subject: Split GrResource into GrCacheable/GrGpuObject Before this change, an object needed to inherit from GrResource (and thus be a GPU object) in order to live in the GrResourceCache. That was a problem for caching items that weren't GPU objects themselves, but owned GPU objects. This change splits GrResource into two classes: 1. GrCacheable: The base class for objects that can live in the GrResourceCache. 2. GrGpuObject, which inherits from GrCacheable: The base class for objects that get tracked by GrGpu. This change is purely a refactor; there is no change in functionality. Change-Id: I3e8daeb1f123041f414aa306c1366e959ae9e39e BUG=skia: R=bsalomon@google.com Author: cdalton@nvidia.com Review URL: https://codereview.chromium.org/251013002 git-svn-id: http://skia.googlecode.com/svn/trunk@14553 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrBufferAllocPool.cpp | 14 ++++----- src/gpu/GrContext.cpp | 12 ++++---- src/gpu/GrDrawTarget.cpp | 4 +-- src/gpu/GrDrawTarget.h | 2 +- src/gpu/GrGeometryBuffer.h | 16 +++++----- src/gpu/GrGpu.cpp | 28 +++++++++--------- src/gpu/GrGpu.h | 19 ++++++------ src/gpu/GrGpuObject.cpp | 60 +++++++++++++++++++++++++++++++++++++ src/gpu/GrIndexBuffer.h | 6 ++-- src/gpu/GrPath.h | 6 ++-- src/gpu/GrRenderTarget.cpp | 2 +- src/gpu/GrResource.cpp | 61 -------------------------------------- src/gpu/GrResourceCache.cpp | 64 ++++++++++++++++++++-------------------- src/gpu/GrResourceCache.h | 50 +++++++++++++++---------------- src/gpu/GrStencilBuffer.h | 9 +++--- src/gpu/GrVertexBuffer.h | 4 +-- src/gpu/SkGrPixelRef.cpp | 2 +- src/gpu/gl/GrGLIndexBuffer.cpp | 8 ++--- src/gpu/gl/GrGLIndexBuffer.h | 4 +-- src/gpu/gl/GrGLPath.h | 2 +- src/gpu/gl/GrGLStencilBuffer.cpp | 2 +- src/gpu/gl/GrGLStencilBuffer.h | 2 +- src/gpu/gl/GrGLVertexArray.cpp | 2 +- src/gpu/gl/GrGLVertexArray.h | 8 ++--- src/gpu/gl/GrGLVertexBuffer.cpp | 8 ++--- src/gpu/gl/GrGLVertexBuffer.h | 4 +-- src/gpu/gl/GrGpuGL.cpp | 2 +- 27 files changed, 199 insertions(+), 202 deletions(-) create mode 100644 src/gpu/GrGpuObject.cpp delete mode 100644 src/gpu/GrResource.cpp (limited to 'src') diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index 2dbf3eb283..2f18e15a72 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -109,7 +109,7 @@ void GrBufferAllocPool::unlock() { if (block.fBuffer->isLocked()) { block.fBuffer->unlock(); } else { - size_t flushSize = block.fBuffer->sizeInBytes() - block.fBytesFree; + size_t flushSize = block.fBuffer->gpuMemorySize() - block.fBytesFree; flushCpuData(fBlocks.back().fBuffer, flushSize); } fBufferPtr = NULL; @@ -135,7 +135,7 @@ void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { SkASSERT(!fBlocks[i].fBuffer->isLocked()); } for (int i = 0; i < fBlocks.count(); ++i) { - size_t bytes = fBlocks[i].fBuffer->sizeInBytes() - fBlocks[i].fBytesFree; + size_t bytes = fBlocks[i].fBuffer->gpuMemorySize() - fBlocks[i].fBytesFree; bytesInUse += bytes; SkASSERT(bytes || unusedBlockAllowed); } @@ -161,7 +161,7 @@ void* GrBufferAllocPool::makeSpace(size_t size, if (NULL != fBufferPtr) { BufferBlock& back = fBlocks.back(); - size_t usedBytes = back.fBuffer->sizeInBytes() - back.fBytesFree; + size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; size_t pad = GrSizeAlignUpPad(usedBytes, alignment); if ((size + pad) <= back.fBytesFree) { @@ -201,7 +201,7 @@ int GrBufferAllocPool::currentBufferItems(size_t itemSize) const { VALIDATE(); if (NULL != fBufferPtr) { const BufferBlock& back = fBlocks.back(); - size_t usedBytes = back.fBuffer->sizeInBytes() - back.fBytesFree; + size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; size_t pad = GrSizeAlignUpPad(usedBytes, itemSize); return static_cast((back.fBytesFree - pad) / itemSize); } else if (fPreallocBuffersInUse < fPreallocBuffers.count()) { @@ -231,7 +231,7 @@ void GrBufferAllocPool::putBack(size_t bytes) { // caller shouldnt try to put back more than they've taken SkASSERT(!fBlocks.empty()); BufferBlock& block = fBlocks.back(); - size_t bytesUsed = block.fBuffer->sizeInBytes() - block.fBytesFree; + size_t bytesUsed = block.fBuffer->gpuMemorySize() - block.fBytesFree; if (bytes >= bytesUsed) { bytes -= bytesUsed; fBytesInUse -= bytesUsed; @@ -290,7 +290,7 @@ bool GrBufferAllocPool::createBlock(size_t requestSize) { prev.fBuffer->unlock(); } else { flushCpuData(prev.fBuffer, - prev.fBuffer->sizeInBytes() - prev.fBytesFree); + prev.fBuffer->gpuMemorySize() - prev.fBytesFree); } fBufferPtr = NULL; } @@ -348,7 +348,7 @@ void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, SkASSERT(NULL != buffer); SkASSERT(!buffer->isLocked()); SkASSERT(fCpuData.get() == fBufferPtr); - SkASSERT(flushSize <= buffer->sizeInBytes()); + SkASSERT(flushSize <= buffer->gpuMemorySize()); VALIDATE(true); if (fGpu->caps()->bufferLockSupport() && diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 90bf8c042e..c518a1c8ac 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -238,7 +238,7 @@ GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, const GrCacheID& cacheID, const GrTextureParams* params) { GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID); - GrResource* resource = fTextureCache->find(resourceKey); + GrCacheable* resource = fTextureCache->find(resourceKey); SkSafeRef(resource); return static_cast(resource); } @@ -264,7 +264,7 @@ GrStencilBuffer* GrContext::findStencilBuffer(int width, int height, GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, height, sampleCnt); - GrResource* resource = fTextureCache->find(resourceKey); + GrCacheable* resource = fTextureCache->find(resourceKey); return static_cast(resource); } @@ -397,7 +397,7 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params, if (NULL != texture) { // Adding a resource could put us overbudget. Try to free up the // necessary space before adding it. - fTextureCache->purgeAsNeeded(1, texture->sizeInBytes()); + fTextureCache->purgeAsNeeded(1, texture->gpuMemorySize()); fTextureCache->addResource(resourceKey, texture); if (NULL != cacheKey) { @@ -416,7 +416,7 @@ static GrTexture* create_scratch_texture(GrGpu* gpu, GrResourceKey key = GrTexture::ComputeScratchKey(texture->desc()); // Adding a resource could put us overbudget. Try to free up the // necessary space before adding it. - textureCache->purgeAsNeeded(1, texture->sizeInBytes()); + textureCache->purgeAsNeeded(1, texture->gpuMemorySize()); // Make the resource exclusive so future 'find' calls don't return it textureCache->addResource(key, texture, GrResourceCache::kHide_OwnershipFlag); } @@ -448,7 +448,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra desc.fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc.fHeight)); } - GrResource* resource = NULL; + GrCacheable* resource = NULL; int origWidth = desc.fWidth; int origHeight = desc.fHeight; @@ -1819,7 +1819,7 @@ GrPath* GrContext::createPath(const SkPath& inPath, const SkStrokeRec& stroke) { path->ref(); } else { path = fGpu->createPath(inPath, stroke); - fTextureCache->purgeAsNeeded(1, path->sizeInBytes()); + fTextureCache->purgeAsNeeded(1, path->gpuMemorySize()); fTextureCache->addResource(resourceKey, path); } return path; diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 5512f174d7..48473058ca 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -361,7 +361,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, maxValidVertex = geoSrc.fVertexCount; break; case kBuffer_GeometrySrcType: - maxValidVertex = static_cast(geoSrc.fVertexBuffer->sizeInBytes() / geoSrc.fVertexSize); + maxValidVertex = static_cast(geoSrc.fVertexBuffer->gpuMemorySize() / geoSrc.fVertexSize); break; } if (maxVertex > maxValidVertex) { @@ -378,7 +378,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, maxValidIndex = geoSrc.fIndexCount; break; case kBuffer_GeometrySrcType: - maxValidIndex = static_cast(geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint16_t)); + maxValidIndex = static_cast(geoSrc.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); break; } if (maxIndex > maxValidIndex) { diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 46dd9d00db..bbaf5a9676 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -742,7 +742,7 @@ protected: case kArray_GeometrySrcType: return src.fIndexCount; case kBuffer_GeometrySrcType: - return static_cast(src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t)); + return static_cast(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t)); default: SkFAIL("Unexpected Index Source."); return 0; diff --git a/src/gpu/GrGeometryBuffer.h b/src/gpu/GrGeometryBuffer.h index 3bb7118faf..2a5aab7a23 100644 --- a/src/gpu/GrGeometryBuffer.h +++ b/src/gpu/GrGeometryBuffer.h @@ -10,14 +10,14 @@ #ifndef GrGeometryBuffer_DEFINED #define GrGeometryBuffer_DEFINED -#include "GrResource.h" +#include "GrGpuObject.h" class GrGpu; /** * Parent class for vertex and index buffers */ -class GrGeometryBuffer : public GrResource { +class GrGeometryBuffer : public GrGpuObject { public: SK_DECLARE_INST_COUNT(GrGeometryBuffer); @@ -82,22 +82,22 @@ public: */ virtual bool updateData(const void* src, size_t srcSizeInBytes) = 0; - // GrResource overrides - virtual size_t sizeInBytes() const { return fSizeInBytes; } + // GrGpuObject overrides + virtual size_t gpuMemorySize() const { return fGpuMemorySize; } protected: - GrGeometryBuffer(GrGpu* gpu, bool isWrapped, size_t sizeInBytes, bool dynamic, bool cpuBacked) + GrGeometryBuffer(GrGpu* gpu, bool isWrapped, size_t gpuMemorySize, bool dynamic, bool cpuBacked) : INHERITED(gpu, isWrapped) - , fSizeInBytes(sizeInBytes) + , fGpuMemorySize(gpuMemorySize) , fDynamic(dynamic) , fCPUBacked(cpuBacked) {} private: - size_t fSizeInBytes; + size_t fGpuMemorySize; bool fDynamic; bool fCPUBacked; - typedef GrResource INHERITED; + typedef GrGpuObject INHERITED; }; #endif diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 82da8c2fe2..bc9295252a 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -57,11 +57,11 @@ void GrGpu::abandonResources() { fClipMaskManager.releaseResources(); - while (NULL != fResourceList.head()) { - fResourceList.head()->abandon(); + while (NULL != fObjectList.head()) { + fObjectList.head()->abandon(); } - SkASSERT(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); + SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()); SkSafeSetNull(fQuadIndexBuffer); delete fVertexPool; fVertexPool = NULL; @@ -73,11 +73,11 @@ void GrGpu::releaseResources() { fClipMaskManager.releaseResources(); - while (NULL != fResourceList.head()) { - fResourceList.head()->release(); + while (NULL != fObjectList.head()) { + fObjectList.head()->release(); } - SkASSERT(NULL == fQuadIndexBuffer || !fQuadIndexBuffer->isValid()); + SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()); SkSafeSetNull(fQuadIndexBuffer); delete fVertexPool; fVertexPool = NULL; @@ -85,18 +85,18 @@ void GrGpu::releaseResources() { fIndexPool = NULL; } -void GrGpu::insertResource(GrResource* resource) { - SkASSERT(NULL != resource); - SkASSERT(this == resource->getGpu()); +void GrGpu::insertObject(GrGpuObject* object) { + SkASSERT(NULL != object); + SkASSERT(this == object->getGpu()); - fResourceList.addToHead(resource); + fObjectList.addToHead(object); } -void GrGpu::removeResource(GrResource* resource) { - SkASSERT(NULL != resource); - SkASSERT(this == resource->getGpu()); +void GrGpu::removeObject(GrGpuObject* object) { + SkASSERT(NULL != object); + SkASSERT(this == object->getGpu()); - fResourceList.remove(resource); + fObjectList.remove(object); } diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index dd5b2c83bd..fc1623708e 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -13,11 +13,11 @@ #include "SkPath.h" class GrContext; +class GrGpuObject; class GrIndexBufferAllocPool; class GrPath; class GrPathRenderer; class GrPathRendererChain; -class GrResource; class GrStencilBuffer; class GrVertexBufferAllocPool; @@ -231,29 +231,28 @@ public: size_t rowBytes); /** - * Called to tell Gpu object that all GrResources have been lost and should + * Called to tell GrGpu that all GrGpuObjects have been lost and should * be abandoned. Overrides must call INHERITED::abandonResources(). */ virtual void abandonResources(); /** - * Called to tell Gpu object to release all GrResources. Overrides must call + * Called to tell GrGpu to release all GrGpuObjects. Overrides must call * INHERITED::releaseResources(). */ void releaseResources(); /** - * Add resource to list of resources. Should only be called by GrResource. + * Add object to list of objects. Should only be called by GrGpuObject. * @param resource the resource to add. */ - void insertResource(GrResource* resource); + void insertObject(GrGpuObject* object); /** - * Remove resource from list of resources. Should only be called by - * GrResource. + * Remove object from list of objects. Should only be called by GrGpuObject. * @param resource the resource to remove. */ - void removeResource(GrResource* resource); + void removeObject(GrGpuObject* object); // GrDrawTarget overrides virtual void clear(const SkIRect* rect, @@ -503,7 +502,7 @@ private: enum { kPreallocGeomPoolStateStackCnt = 4, }; - typedef SkTInternalLList ResourceList; + typedef SkTInternalLList ObjectList; SkSTArray fGeomPoolStateStack; ResetTimestamp fResetTimestamp; uint32_t fResetBits; @@ -516,7 +515,7 @@ private: mutable GrIndexBuffer* fQuadIndexBuffer; // Used to abandon/release all resources created by this GrGpu. TODO: Move this // functionality to GrResourceCache. - ResourceList fResourceList; + ObjectList fObjectList; typedef GrDrawTarget INHERITED; }; diff --git a/src/gpu/GrGpuObject.cpp b/src/gpu/GrGpuObject.cpp new file mode 100644 index 0000000000..43a86f2d51 --- /dev/null +++ b/src/gpu/GrGpuObject.cpp @@ -0,0 +1,60 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "GrGpuObject.h" +#include "GrGpu.h" + +GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) { + fGpu = gpu; + fDeferredRefCount = 0; + if (isWrapped) { + fFlags = kWrapped_FlagBit; + } else { + fFlags = 0; + } + fGpu->insertObject(this); +} + +GrGpuObject::~GrGpuObject() { + // subclass should have released this. + SkASSERT(0 == fDeferredRefCount); + SkASSERT(this->wasDestroyed()); +} + +void GrGpuObject::release() { + if (NULL != fGpu) { + this->onRelease(); + fGpu->removeObject(this); + fGpu = NULL; + } +} + +void GrGpuObject::abandon() { + if (NULL != fGpu) { + this->onAbandon(); + fGpu->removeObject(this); + fGpu = NULL; + } +} + +const GrContext* GrGpuObject::getContext() const { + if (NULL != fGpu) { + return fGpu->getContext(); + } else { + return NULL; + } +} + +GrContext* GrGpuObject::getContext() { + if (NULL != fGpu) { + return fGpu->getContext(); + } else { + return NULL; + } +} diff --git a/src/gpu/GrIndexBuffer.h b/src/gpu/GrIndexBuffer.h index e23bc9b19a..113b89d307 100644 --- a/src/gpu/GrIndexBuffer.h +++ b/src/gpu/GrIndexBuffer.h @@ -21,11 +21,11 @@ public: * @return the maximum number of quads using full size of index buffer. */ int maxQuads() const { - return static_cast(this->sizeInBytes() / (sizeof(uint16_t) * 6)); + return static_cast(this->gpuMemorySize() / (sizeof(uint16_t) * 6)); } protected: - GrIndexBuffer(GrGpu* gpu, bool isWrapped, size_t sizeInBytes, bool dynamic, bool cpuBacked) - : INHERITED(gpu, isWrapped, sizeInBytes, dynamic, cpuBacked) {} + GrIndexBuffer(GrGpu* gpu, bool isWrapped, size_t gpuMemorySize, bool dynamic, bool cpuBacked) + : INHERITED(gpu, isWrapped, gpuMemorySize, dynamic, cpuBacked) {} private: typedef GrGeometryBuffer INHERITED; }; diff --git a/src/gpu/GrPath.h b/src/gpu/GrPath.h index f481ea4286..d324e6a745 100644 --- a/src/gpu/GrPath.h +++ b/src/gpu/GrPath.h @@ -8,13 +8,13 @@ #ifndef GrPath_DEFINED #define GrPath_DEFINED -#include "GrResource.h" +#include "GrGpuObject.h" #include "GrResourceCache.h" #include "SkPath.h" #include "SkRect.h" #include "SkStrokeRec.h" -class GrPath : public GrResource { +class GrPath : public GrGpuObject { public: SK_DECLARE_INST_COUNT(GrPath); @@ -41,7 +41,7 @@ protected: SkRect fBounds; private: - typedef GrResource INHERITED; + typedef GrGpuObject INHERITED; }; #endif diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp index 9348dc16a6..13fc229075 100644 --- a/src/gpu/GrRenderTarget.cpp +++ b/src/gpu/GrRenderTarget.cpp @@ -63,7 +63,7 @@ void GrRenderTarget::discard() { context->discardRenderTarget(this); } -size_t GrRenderTarget::sizeInBytes() const { +size_t GrRenderTarget::gpuMemorySize() const { size_t colorBits; if (kUnknown_GrPixelConfig == fDesc.fConfig) { colorBits = 32; // don't know, make a guess diff --git a/src/gpu/GrResource.cpp b/src/gpu/GrResource.cpp deleted file mode 100644 index e20a30ffd3..0000000000 --- a/src/gpu/GrResource.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "GrResource.h" -#include "GrGpu.h" - -GrResource::GrResource(GrGpu* gpu, bool isWrapped) { - fGpu = gpu; - fCacheEntry = NULL; - fDeferredRefCount = 0; - if (isWrapped) { - fFlags = kWrapped_FlagBit; - } else { - fFlags = 0; - } - fGpu->insertResource(this); -} - -GrResource::~GrResource() { - // subclass should have released this. - SkASSERT(0 == fDeferredRefCount); - SkASSERT(!this->isValid()); -} - -void GrResource::release() { - if (NULL != fGpu) { - this->onRelease(); - fGpu->removeResource(this); - fGpu = NULL; - } -} - -void GrResource::abandon() { - if (NULL != fGpu) { - this->onAbandon(); - fGpu->removeResource(this); - fGpu = NULL; - } -} - -const GrContext* GrResource::getContext() const { - if (NULL != fGpu) { - return fGpu->getContext(); - } else { - return NULL; - } -} - -GrContext* GrResource::getContext() { - if (NULL != fGpu) { - return fGpu->getContext(); - } else { - return NULL; - } -} diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index ba8b9629eb..26f7592548 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -9,7 +9,7 @@ #include "GrResourceCache.h" -#include "GrResource.h" +#include "GrCacheable.h" DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage); @@ -26,20 +26,20 @@ GrResourceKey::ResourceType GrResourceKey::GenerateResourceType() { /////////////////////////////////////////////////////////////////////////////// -GrResourceEntry::GrResourceEntry(const GrResourceKey& key, GrResource* resource) +GrResourceCacheEntry::GrResourceCacheEntry(const GrResourceKey& key, GrCacheable* resource) : fKey(key), fResource(resource) { // we assume ownership of the resource, and will unref it when we die SkASSERT(resource); resource->ref(); } -GrResourceEntry::~GrResourceEntry() { +GrResourceCacheEntry::~GrResourceCacheEntry() { fResource->setCacheEntry(NULL); fResource->unref(); } #ifdef SK_DEBUG -void GrResourceEntry::validate() const { +void GrResourceCacheEntry::validate() const { SkASSERT(fResource); SkASSERT(fResource->getCacheEntry() == this); fResource->validate(); @@ -75,7 +75,7 @@ GrResourceCache::~GrResourceCache() { EntryList::Iter iter; // Unlike the removeAll, here we really remove everything, including locked resources. - while (GrResourceEntry* entry = fList.head()) { + while (GrResourceCacheEntry* entry = fList.head()) { GrAutoResourceCacheValidate atcv(this); // remove from our cache @@ -108,14 +108,14 @@ void GrResourceCache::setLimits(int maxResources, size_t maxResourceBytes) { } } -void GrResourceCache::internalDetach(GrResourceEntry* entry, +void GrResourceCache::internalDetach(GrResourceCacheEntry* entry, BudgetBehaviors behavior) { fList.remove(entry); // update our stats if (kIgnore_BudgetBehavior == behavior) { fClientDetachedCount += 1; - fClientDetachedBytes += entry->resource()->sizeInBytes(); + fClientDetachedBytes += entry->resource()->gpuMemorySize(); #if GR_CACHE_STATS if (fHighWaterClientDetachedCount < fClientDetachedCount) { @@ -130,23 +130,23 @@ void GrResourceCache::internalDetach(GrResourceEntry* entry, SkASSERT(kAccountFor_BudgetBehavior == behavior); fEntryCount -= 1; - fEntryBytes -= entry->resource()->sizeInBytes(); + fEntryBytes -= entry->resource()->gpuMemorySize(); } } -void GrResourceCache::attachToHead(GrResourceEntry* entry, +void GrResourceCache::attachToHead(GrResourceCacheEntry* entry, BudgetBehaviors behavior) { fList.addToHead(entry); // update our stats if (kIgnore_BudgetBehavior == behavior) { fClientDetachedCount -= 1; - fClientDetachedBytes -= entry->resource()->sizeInBytes(); + fClientDetachedBytes -= entry->resource()->gpuMemorySize(); } else { SkASSERT(kAccountFor_BudgetBehavior == behavior); fEntryCount += 1; - fEntryBytes += entry->resource()->sizeInBytes(); + fEntryBytes += entry->resource()->gpuMemorySize(); #if GR_CACHE_STATS if (fHighWaterEntryCount < fEntryCount) { @@ -164,15 +164,15 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry, // is relying on the texture. class GrTFindUnreffedFunctor { public: - bool operator()(const GrResourceEntry* entry) const { + bool operator()(const GrResourceCacheEntry* entry) const { return entry->resource()->unique(); } }; -GrResource* GrResourceCache::find(const GrResourceKey& key, uint32_t ownershipFlags) { +GrCacheable* GrResourceCache::find(const GrResourceKey& key, uint32_t ownershipFlags) { GrAutoResourceCacheValidate atcv(this); - GrResourceEntry* entry = NULL; + GrResourceCacheEntry* entry = NULL; if (ownershipFlags & kNoOtherOwners_OwnershipFlag) { GrTFindUnreffedFunctor functor; @@ -198,7 +198,7 @@ GrResource* GrResourceCache::find(const GrResourceKey& key, uint32_t ownershipFl } void GrResourceCache::addResource(const GrResourceKey& key, - GrResource* resource, + GrCacheable* resource, uint32_t ownershipFlags) { SkASSERT(NULL == resource->getCacheEntry()); // we don't expect to create new resources during a purge. In theory @@ -208,7 +208,7 @@ void GrResourceCache::addResource(const GrResourceKey& key, SkASSERT(!fPurging); GrAutoResourceCacheValidate atcv(this); - GrResourceEntry* entry = SkNEW_ARGS(GrResourceEntry, (key, resource)); + GrResourceCacheEntry* entry = SkNEW_ARGS(GrResourceCacheEntry, (key, resource)); resource->setCacheEntry(entry); this->attachToHead(entry); @@ -220,7 +220,7 @@ void GrResourceCache::addResource(const GrResourceKey& key, } -void GrResourceCache::makeExclusive(GrResourceEntry* entry) { +void GrResourceCache::makeExclusive(GrResourceCacheEntry* entry) { GrAutoResourceCacheValidate atcv(this); // When scratch textures are detached (to hide them from future finds) they @@ -233,7 +233,7 @@ void GrResourceCache::makeExclusive(GrResourceEntry* entry) { #endif } -void GrResourceCache::removeInvalidResource(GrResourceEntry* entry) { +void GrResourceCache::removeInvalidResource(GrResourceCacheEntry* entry) { // If the resource went invalid while it was detached then purge it // This can happen when a 3D context was lost, // the client called GrContext::contextDestroyed() to notify Gr, @@ -241,19 +241,19 @@ void GrResourceCache::removeInvalidResource(GrResourceEntry* entry) { // texture (which was invalidated at contextDestroyed time). fClientDetachedCount -= 1; fEntryCount -= 1; - size_t size = entry->resource()->sizeInBytes(); + size_t size = entry->resource()->gpuMemorySize(); fClientDetachedBytes -= size; fEntryBytes -= size; } -void GrResourceCache::makeNonExclusive(GrResourceEntry* entry) { +void GrResourceCache::makeNonExclusive(GrResourceCacheEntry* entry) { GrAutoResourceCacheValidate atcv(this); #ifdef SK_DEBUG fExclusiveList.remove(entry); #endif - if (entry->resource()->isValid()) { + if (entry->resource()->isValidOnGpu()) { // Since scratch textures still count against the cache budget even // when they have been removed from the cache, re-adding them doesn't // alter the budget information. @@ -313,13 +313,13 @@ void GrResourceCache::purgeInvalidated() { // // This is complicated and confusing. May try this in the future. For // now, these resources are just LRU'd as if we never got the message. - while (GrResourceEntry* entry = fCache.find(invalidated[i].key, GrTFindUnreffedFunctor())) { + while (GrResourceCacheEntry* entry = fCache.find(invalidated[i].key, GrTFindUnreffedFunctor())) { this->deleteResource(entry); } } } -void GrResourceCache::deleteResource(GrResourceEntry* entry) { +void GrResourceCache::deleteResource(GrResourceCacheEntry* entry) { SkASSERT(1 == entry->fResource->getRefCnt()); // remove from our cache @@ -347,7 +347,7 @@ void GrResourceCache::internalPurge(int extraCount, size_t extraBytes) { // doubly linked list doesn't invalidate its data/pointers // outside of the specific area where a deletion occurs (e.g., // in internalDetach) - GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart); + GrResourceCacheEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart); while (NULL != entry) { GrAutoResourceCacheValidate atcv(this); @@ -358,7 +358,7 @@ void GrResourceCache::internalPurge(int extraCount, size_t extraBytes) { break; } - GrResourceEntry* prev = iter.prev(); + GrResourceCacheEntry* prev = iter.prev(); if (entry->fResource->unique()) { changed = true; this->deleteResource(entry); @@ -371,7 +371,7 @@ void GrResourceCache::internalPurge(int extraCount, size_t extraBytes) { void GrResourceCache::purgeAllUnlocked() { GrAutoResourceCacheValidate atcv(this); - // we can have one GrResource holding a lock on another + // we can have one GrCacheable holding a lock on another // so we don't want to just do a simple loop kicking each // entry out. Instead change the budget and purge. @@ -406,11 +406,11 @@ size_t GrResourceCache::countBytes(const EntryList& list) { EntryList::Iter iter; - const GrResourceEntry* entry = iter.init(const_cast(list), - EntryList::Iter::kTail_IterStart); + const GrResourceCacheEntry* entry = iter.init(const_cast(list), + EntryList::Iter::kTail_IterStart); for ( ; NULL != entry; entry = iter.prev()) { - bytes += entry->resource()->sizeInBytes(); + bytes += entry->resource()->gpuMemorySize(); } return bytes; } @@ -431,8 +431,8 @@ void GrResourceCache::validate() const { EntryList::Iter iter; // check that the exclusively held entries are okay - const GrResourceEntry* entry = iter.init(const_cast(fExclusiveList), - EntryList::Iter::kHead_IterStart); + const GrResourceCacheEntry* entry = iter.init(const_cast(fExclusiveList), + EntryList::Iter::kHead_IterStart); for ( ; NULL != entry; entry = iter.next()) { entry->validate(); @@ -468,7 +468,7 @@ void GrResourceCache::printStats() { EntryList::Iter iter; - GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart); + GrResourceCacheEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart); for ( ; NULL != entry; entry = iter.prev()) { if (entry->fResource->getRefCnt() > 1) { diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index a8309188ff..b2f91cdbdb 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -18,8 +18,8 @@ #include "SkMessageBus.h" #include "SkTInternalLList.h" -class GrResource; -class GrResourceEntry; +class GrCacheable; +class GrResourceCacheEntry; class GrResourceKey { public: @@ -28,11 +28,11 @@ public: return gDomain; } - /** Uniquely identifies the GrResource subclass in the key to avoid collisions + /** Uniquely identifies the GrCacheable subclass in the key to avoid collisions across resource types. */ typedef uint8_t ResourceType; - /** Flags set by the GrResource subclass. */ + /** Flags set by the GrCacheable subclass. */ typedef uint8_t ResourceFlags; /** Generate a unique ResourceType */ @@ -115,12 +115,12 @@ struct GrResourceInvalidatedMessage { /////////////////////////////////////////////////////////////////////////////// -class GrResourceEntry { +class GrResourceCacheEntry { public: - GrResource* resource() const { return fResource; } + GrCacheable* resource() const { return fResource; } const GrResourceKey& key() const { return fKey; } - static const GrResourceKey& GetKey(const GrResourceEntry& e) { return e.key(); } + static const GrResourceKey& GetKey(const GrResourceCacheEntry& e) { return e.key(); } static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } #ifdef SK_DEBUG void validate() const; @@ -129,14 +129,14 @@ public: #endif private: - GrResourceEntry(const GrResourceKey& key, GrResource* resource); - ~GrResourceEntry(); + GrResourceCacheEntry(const GrResourceKey& key, GrCacheable* resource); + ~GrResourceCacheEntry(); GrResourceKey fKey; - GrResource* fResource; + GrCacheable* fResource; // Linked list for the LRU ordering. - SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceEntry); + SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceCacheEntry); friend class GrResourceCache; }; @@ -144,7 +144,7 @@ private: /////////////////////////////////////////////////////////////////////////////// /** - * Cache of GrResource objects. + * Cache of GrCacheable objects. * * These have a corresponding GrResourceKey, built from 128bits identifying the * resource. Multiple resources can map to same GrResourceKey. @@ -157,7 +157,7 @@ private: * For fast searches, we maintain a hash map based on the GrResourceKey. * * It is a goal to make the GrResourceCache the central repository and bookkeeper - * of all resources. It should replace the linked list of GrResources that + * of all resources. It should replace the linked list of GrGpuObjects that * GrGpu uses to call abandon/release. */ class GrResourceCache { @@ -233,8 +233,8 @@ public: * For a resource to be completely exclusive to a caller both kNoOtherOwners * and kHide must be specified. */ - GrResource* find(const GrResourceKey& key, - uint32_t ownershipFlags = 0); + GrCacheable* find(const GrResourceKey& key, + uint32_t ownershipFlags = 0); /** * Add the new resource to the cache (by creating a new cache entry based @@ -248,7 +248,7 @@ public: * is called. */ void addResource(const GrResourceKey& key, - GrResource* resource, + GrCacheable* resource, uint32_t ownershipFlags = 0); /** @@ -263,18 +263,18 @@ public: * the cache's budget and should be made non-exclusive when exclusive access * is no longer needed. */ - void makeExclusive(GrResourceEntry* entry); + void makeExclusive(GrResourceCacheEntry* entry); /** * Restore 'entry' so that it can be found by future searches. 'entry' * will also be purgeable (provided its lock count is now 0.) */ - void makeNonExclusive(GrResourceEntry* entry); + void makeNonExclusive(GrResourceCacheEntry* entry); /** * Remove a resource from the cache and delete it! */ - void deleteResource(GrResourceEntry* entry); + void deleteResource(GrResourceCacheEntry* entry); /** * Removes every resource in the cache that isn't locked. @@ -310,15 +310,15 @@ private: kIgnore_BudgetBehavior }; - void internalDetach(GrResourceEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior); - void attachToHead(GrResourceEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior); + void internalDetach(GrResourceCacheEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior); + void attachToHead(GrResourceCacheEntry*, BudgetBehaviors behavior = kAccountFor_BudgetBehavior); - void removeInvalidResource(GrResourceEntry* entry); + void removeInvalidResource(GrResourceCacheEntry* entry); - GrTMultiMap fCache; + GrTMultiMap fCache; // We're an internal doubly linked list - typedef SkTInternalLList EntryList; + typedef SkTInternalLList EntryList; EntryList fList; #ifdef SK_DEBUG @@ -356,7 +356,7 @@ private: void purgeInvalidated(); #ifdef SK_DEBUG - static size_t countBytes(const SkTInternalLList& list); + static size_t countBytes(const SkTInternalLList& list); #endif }; diff --git a/src/gpu/GrStencilBuffer.h b/src/gpu/GrStencilBuffer.h index 37d40f16ba..696ba83912 100644 --- a/src/gpu/GrStencilBuffer.h +++ b/src/gpu/GrStencilBuffer.h @@ -11,13 +11,12 @@ #define GrStencilBuffer_DEFINED #include "GrClipData.h" -#include "GrResource.h" +#include "GrGpuObject.h" class GrRenderTarget; -class GrResourceEntry; class GrResourceKey; -class GrStencilBuffer : public GrResource { +class GrStencilBuffer : public GrGpuObject { public: SK_DECLARE_INST_COUNT(GrStencilBuffer); @@ -55,7 +54,7 @@ public: protected: GrStencilBuffer(GrGpu* gpu, bool isWrapped, int width, int height, int bits, int sampleCnt) - : GrResource(gpu, isWrapped) + : GrGpuObject(gpu, isWrapped) , fWidth(width) , fHeight(height) , fBits(bits) @@ -75,7 +74,7 @@ private: SkIRect fLastClipStackRect; SkIPoint fLastClipSpaceOffset; - typedef GrResource INHERITED; + typedef GrGpuObject INHERITED; }; #endif diff --git a/src/gpu/GrVertexBuffer.h b/src/gpu/GrVertexBuffer.h index a2bd5a1b4d..c3cf534892 100644 --- a/src/gpu/GrVertexBuffer.h +++ b/src/gpu/GrVertexBuffer.h @@ -15,8 +15,8 @@ class GrVertexBuffer : public GrGeometryBuffer { protected: - GrVertexBuffer(GrGpu* gpu, bool isWrapped, size_t sizeInBytes, bool dynamic, bool cpuBacked) - : INHERITED(gpu, isWrapped, sizeInBytes, dynamic, cpuBacked) {} + GrVertexBuffer(GrGpu* gpu, bool isWrapped, size_t gpuMemorySize, bool dynamic, bool cpuBacked) + : INHERITED(gpu, isWrapped, gpuMemorySize, dynamic, cpuBacked) {} private: typedef GrGeometryBuffer INHERITED; }; diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp index 18fefcc789..fd21f1073b 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -167,7 +167,7 @@ SkPixelRef* SkGrPixelRef::deepCopy(SkBitmap::Config dstConfig, const SkIRect* su } bool SkGrPixelRef::onReadPixels(SkBitmap* dst, const SkIRect* subset) { - if (NULL == fSurface || !fSurface->isValid()) { + if (NULL == fSurface || fSurface->wasDestroyed()) { return false; } diff --git a/src/gpu/gl/GrGLIndexBuffer.cpp b/src/gpu/gl/GrGLIndexBuffer.cpp index b6290b1826..4e7f989ce0 100644 --- a/src/gpu/gl/GrGLIndexBuffer.cpp +++ b/src/gpu/gl/GrGLIndexBuffer.cpp @@ -14,7 +14,7 @@ GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu, const Desc& desc) } void GrGLIndexBuffer::onRelease() { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.release(this->getGpuGL()); } @@ -27,7 +27,7 @@ void GrGLIndexBuffer::onAbandon() { } void* GrGLIndexBuffer::lock() { - if (this->isValid()) { + if (!this->wasDestroyed()) { return fImpl.lock(this->getGpuGL()); } else { return NULL; @@ -39,7 +39,7 @@ void* GrGLIndexBuffer::lockPtr() const { } void GrGLIndexBuffer::unlock() { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.unlock(this->getGpuGL()); } } @@ -49,7 +49,7 @@ bool GrGLIndexBuffer::isLocked() const { } bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) { - if (this->isValid()) { + if (!this->wasDestroyed()) { return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes); } else { return false; diff --git a/src/gpu/gl/GrGLIndexBuffer.h b/src/gpu/gl/GrGLIndexBuffer.h index 32a8086063..893e357173 100644 --- a/src/gpu/gl/GrGLIndexBuffer.h +++ b/src/gpu/gl/GrGLIndexBuffer.h @@ -26,7 +26,7 @@ public: size_t baseOffset() const { return fImpl.baseOffset(); } void bind() const { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.bind(this->getGpuGL()); } } @@ -45,7 +45,7 @@ protected: private: GrGpuGL* getGpuGL() const { - SkASSERT(this->isValid()); + SkASSERT(!this->wasDestroyed()); return (GrGpuGL*)(this->getGpu()); } diff --git a/src/gpu/gl/GrGLPath.h b/src/gpu/gl/GrGLPath.h index 3647d4d628..3409547b2b 100644 --- a/src/gpu/gl/GrGLPath.h +++ b/src/gpu/gl/GrGLPath.h @@ -27,7 +27,7 @@ public: GrGLuint pathID() const { return fPathID; } // TODO: Figure out how to get an approximate size of the path in Gpu // memory. - virtual size_t sizeInBytes() const SK_OVERRIDE { return 100; } + virtual size_t gpuMemorySize() const SK_OVERRIDE { return 100; } protected: virtual void onRelease() SK_OVERRIDE; diff --git a/src/gpu/gl/GrGLStencilBuffer.cpp b/src/gpu/gl/GrGLStencilBuffer.cpp index 33e346c617..abcb3c4ba0 100644 --- a/src/gpu/gl/GrGLStencilBuffer.cpp +++ b/src/gpu/gl/GrGLStencilBuffer.cpp @@ -13,7 +13,7 @@ GrGLStencilBuffer::~GrGLStencilBuffer() { this->release(); } -size_t GrGLStencilBuffer::sizeInBytes() const { +size_t GrGLStencilBuffer::gpuMemorySize() const { uint64_t size = this->width(); size *= this->height(); size *= fFormat.fTotalBits; diff --git a/src/gpu/gl/GrGLStencilBuffer.h b/src/gpu/gl/GrGLStencilBuffer.h index 2bf33ef7b2..1cb0a3301a 100644 --- a/src/gpu/gl/GrGLStencilBuffer.h +++ b/src/gpu/gl/GrGLStencilBuffer.h @@ -36,7 +36,7 @@ public: virtual ~GrGLStencilBuffer(); - virtual size_t sizeInBytes() const SK_OVERRIDE; + virtual size_t gpuMemorySize() const SK_OVERRIDE; GrGLuint renderbufferID() const { return fRenderbufferID; diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp index abd337a806..66feb82053 100644 --- a/src/gpu/gl/GrGLVertexArray.cpp +++ b/src/gpu/gl/GrGLVertexArray.cpp @@ -69,7 +69,7 @@ void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used /////////////////////////////////////////////////////////////////////////////////////////////////// GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount) - : GrResource(gpu, false) + : INHERITED(gpu, false) , fID(id) , fAttribArrays(attribCount) , fIndexBufferIDIsValid(false) { diff --git a/src/gpu/gl/GrGLVertexArray.h b/src/gpu/gl/GrGLVertexArray.h index 8a61f1a2c6..0e5bffe4c1 100644 --- a/src/gpu/gl/GrGLVertexArray.h +++ b/src/gpu/gl/GrGLVertexArray.h @@ -8,7 +8,7 @@ #ifndef GrGLVertexArray_DEFINED #define GrGLVertexArray_DEFINED -#include "GrResource.h" +#include "GrGpuObject.h" #include "GrTypesPriv.h" #include "gl/GrGLDefines.h" #include "gl/GrGLFunctions.h" @@ -130,7 +130,7 @@ private: * This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array * and is used to track the state of the vertex array to avoid redundant GL calls. */ -class GrGLVertexArray : public GrResource { +class GrGLVertexArray : public GrGpuObject { public: GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount); @@ -157,7 +157,7 @@ public: void invalidateCachedState(); - virtual size_t sizeInBytes() const SK_OVERRIDE { return 0; } + virtual size_t gpuMemorySize() const SK_OVERRIDE { return 0; } protected: virtual void onAbandon() SK_OVERRIDE; @@ -170,7 +170,7 @@ private: GrGLuint fIndexBufferID; bool fIndexBufferIDIsValid; - typedef GrResource INHERITED; + typedef GrGpuObject INHERITED; }; #endif diff --git a/src/gpu/gl/GrGLVertexBuffer.cpp b/src/gpu/gl/GrGLVertexBuffer.cpp index 685166c90b..8bfe1f0c96 100644 --- a/src/gpu/gl/GrGLVertexBuffer.cpp +++ b/src/gpu/gl/GrGLVertexBuffer.cpp @@ -14,7 +14,7 @@ GrGLVertexBuffer::GrGLVertexBuffer(GrGpuGL* gpu, const Desc& desc) } void GrGLVertexBuffer::onRelease() { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.release(this->getGpuGL()); } @@ -28,7 +28,7 @@ void GrGLVertexBuffer::onAbandon() { } void* GrGLVertexBuffer::lock() { - if (this->isValid()) { + if (!this->wasDestroyed()) { return fImpl.lock(this->getGpuGL()); } else { return NULL; @@ -40,7 +40,7 @@ void* GrGLVertexBuffer::lockPtr() const { } void GrGLVertexBuffer::unlock() { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.unlock(this->getGpuGL()); } } @@ -50,7 +50,7 @@ bool GrGLVertexBuffer::isLocked() const { } bool GrGLVertexBuffer::updateData(const void* src, size_t srcSizeInBytes) { - if (this->isValid()) { + if (!this->wasDestroyed()) { return fImpl.updateData(this->getGpuGL(), src, srcSizeInBytes); } else { return false; diff --git a/src/gpu/gl/GrGLVertexBuffer.h b/src/gpu/gl/GrGLVertexBuffer.h index 1741adc23d..1b9c4f17be 100644 --- a/src/gpu/gl/GrGLVertexBuffer.h +++ b/src/gpu/gl/GrGLVertexBuffer.h @@ -26,7 +26,7 @@ public: size_t baseOffset() const { return fImpl.baseOffset(); } void bind() const { - if (this->isValid()) { + if (!this->wasDestroyed()) { fImpl.bind(this->getGpuGL()); } } @@ -45,7 +45,7 @@ protected: private: GrGpuGL* getGpuGL() const { - SkASSERT(this->isValid()); + SkASSERT(!this->wasDestroyed()); return (GrGpuGL*)(this->getGpu()); } diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 9b92fe25da..1a1bad7f28 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -2788,7 +2788,7 @@ GrGLAttribArrayState* GrGpuGL::HWGeometryState::bindArrayAndBuffersToDraw( // We use a vertex array if we're on a core profile and the verts are in a VBO. if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) { - if (NULL == fVBOVertexArray || !fVBOVertexArray->isValid()) { + if (NULL == fVBOVertexArray || fVBOVertexArray->wasDestroyed()) { SkSafeUnref(fVBOVertexArray); GrGLuint arrayID; GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); -- cgit v1.2.3