summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-02 21:38:22 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-02 21:38:22 +0000
commita519ef7a6ea47b7b200a81f5205b77fea69a88e8 (patch)
treee56ce512f31ae1063952e8dcd1a4f5e21b13838b
parenta97ef5e8a2b07b735120d041de8e4612dfe59185 (diff)
downloadsrc-a519ef7a6ea47b7b200a81f5205b77fea69a88e8.tar.gz
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/src@14553 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gpu/GrBufferAllocPool.cpp14
-rw-r--r--gpu/GrContext.cpp12
-rw-r--r--gpu/GrDrawTarget.cpp4
-rw-r--r--gpu/GrDrawTarget.h2
-rw-r--r--gpu/GrGeometryBuffer.h16
-rw-r--r--gpu/GrGpu.cpp28
-rw-r--r--gpu/GrGpu.h19
-rw-r--r--gpu/GrGpuObject.cpp (renamed from gpu/GrResource.cpp)23
-rw-r--r--gpu/GrIndexBuffer.h6
-rw-r--r--gpu/GrPath.h6
-rw-r--r--gpu/GrRenderTarget.cpp2
-rw-r--r--gpu/GrResourceCache.cpp64
-rw-r--r--gpu/GrResourceCache.h50
-rw-r--r--gpu/GrStencilBuffer.h9
-rw-r--r--gpu/GrVertexBuffer.h4
-rw-r--r--gpu/SkGrPixelRef.cpp2
-rw-r--r--gpu/gl/GrGLIndexBuffer.cpp8
-rw-r--r--gpu/gl/GrGLIndexBuffer.h4
-rw-r--r--gpu/gl/GrGLPath.h2
-rw-r--r--gpu/gl/GrGLStencilBuffer.cpp2
-rw-r--r--gpu/gl/GrGLStencilBuffer.h2
-rw-r--r--gpu/gl/GrGLVertexArray.cpp2
-rw-r--r--gpu/gl/GrGLVertexArray.h8
-rw-r--r--gpu/gl/GrGLVertexBuffer.cpp8
-rw-r--r--gpu/gl/GrGLVertexBuffer.h4
-rw-r--r--gpu/gl/GrGpuGL.cpp2
26 files changed, 150 insertions, 153 deletions
diff --git a/gpu/GrBufferAllocPool.cpp b/gpu/GrBufferAllocPool.cpp
index 2dbf3eb2..2f18e15a 100644
--- a/gpu/GrBufferAllocPool.cpp
+++ b/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<int>((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/gpu/GrContext.cpp b/gpu/GrContext.cpp
index 90bf8c04..c518a1c8 100644
--- a/gpu/GrContext.cpp
+++ b/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<GrTexture*>(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<GrStencilBuffer*>(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/gpu/GrDrawTarget.cpp b/gpu/GrDrawTarget.cpp
index 5512f174..48473058 100644
--- a/gpu/GrDrawTarget.cpp
+++ b/gpu/GrDrawTarget.cpp
@@ -361,7 +361,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
maxValidVertex = geoSrc.fVertexCount;
break;
case kBuffer_GeometrySrcType:
- maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->sizeInBytes() / geoSrc.fVertexSize);
+ maxValidVertex = static_cast<int>(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<int>(geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint16_t));
+ maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t));
break;
}
if (maxIndex > maxValidIndex) {
diff --git a/gpu/GrDrawTarget.h b/gpu/GrDrawTarget.h
index 46dd9d00..bbaf5a96 100644
--- a/gpu/GrDrawTarget.h
+++ b/gpu/GrDrawTarget.h
@@ -742,7 +742,7 @@ protected:
case kArray_GeometrySrcType:
return src.fIndexCount;
case kBuffer_GeometrySrcType:
- return static_cast<int>(src.fIndexBuffer->sizeInBytes() / sizeof(uint16_t));
+ return static_cast<int>(src.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t));
default:
SkFAIL("Unexpected Index Source.");
return 0;
diff --git a/gpu/GrGeometryBuffer.h b/gpu/GrGeometryBuffer.h
index 3bb7118f..2a5aab7a 100644
--- a/gpu/GrGeometryBuffer.h
+++ b/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/gpu/GrGpu.cpp b/gpu/GrGpu.cpp
index 82da8c2f..bc929525 100644
--- a/gpu/GrGpu.cpp
+++ b/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/gpu/GrGpu.h b/gpu/GrGpu.h
index dd5b2c83..fc162370 100644
--- a/gpu/GrGpu.h
+++ b/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<GrResource> ResourceList;
+ typedef SkTInternalLList<GrGpuObject> ObjectList;
SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> 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/gpu/GrResource.cpp b/gpu/GrGpuObject.cpp
index e20a30ff..43a86f2d 100644
--- a/gpu/GrResource.cpp
+++ b/gpu/GrGpuObject.cpp
@@ -7,44 +7,43 @@
*/
-#include "GrResource.h"
+#include "GrGpuObject.h"
#include "GrGpu.h"
-GrResource::GrResource(GrGpu* gpu, bool isWrapped) {
+GrGpuObject::GrGpuObject(GrGpu* gpu, bool isWrapped) {
fGpu = gpu;
- fCacheEntry = NULL;
fDeferredRefCount = 0;
if (isWrapped) {
fFlags = kWrapped_FlagBit;
} else {
fFlags = 0;
}
- fGpu->insertResource(this);
+ fGpu->insertObject(this);
}
-GrResource::~GrResource() {
+GrGpuObject::~GrGpuObject() {
// subclass should have released this.
SkASSERT(0 == fDeferredRefCount);
- SkASSERT(!this->isValid());
+ SkASSERT(this->wasDestroyed());
}
-void GrResource::release() {
+void GrGpuObject::release() {
if (NULL != fGpu) {
this->onRelease();
- fGpu->removeResource(this);
+ fGpu->removeObject(this);
fGpu = NULL;
}
}
-void GrResource::abandon() {
+void GrGpuObject::abandon() {
if (NULL != fGpu) {
this->onAbandon();
- fGpu->removeResource(this);
+ fGpu->removeObject(this);
fGpu = NULL;
}
}
-const GrContext* GrResource::getContext() const {
+const GrContext* GrGpuObject::getContext() const {
if (NULL != fGpu) {
return fGpu->getContext();
} else {
@@ -52,7 +51,7 @@ const GrContext* GrResource::getContext() const {
}
}
-GrContext* GrResource::getContext() {
+GrContext* GrGpuObject::getContext() {
if (NULL != fGpu) {
return fGpu->getContext();
} else {
diff --git a/gpu/GrIndexBuffer.h b/gpu/GrIndexBuffer.h
index e23bc9b1..113b89d3 100644
--- a/gpu/GrIndexBuffer.h
+++ b/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<int>(this->sizeInBytes() / (sizeof(uint16_t) * 6));
+ return static_cast<int>(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/gpu/GrPath.h b/gpu/GrPath.h
index f481ea42..d324e6a7 100644
--- a/gpu/GrPath.h
+++ b/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/gpu/GrRenderTarget.cpp b/gpu/GrRenderTarget.cpp
index 9348dc16..13fc2290 100644
--- a/gpu/GrRenderTarget.cpp
+++ b/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/gpu/GrResourceCache.cpp b/gpu/GrResourceCache.cpp
index ba8b9629..26f75925 100644
--- a/gpu/GrResourceCache.cpp
+++ b/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<EntryList&>(list),
- EntryList::Iter::kTail_IterStart);
+ const GrResourceCacheEntry* entry = iter.init(const_cast<EntryList&>(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<EntryList&>(fExclusiveList),
- EntryList::Iter::kHead_IterStart);
+ const GrResourceCacheEntry* entry = iter.init(const_cast<EntryList&>(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/gpu/GrResourceCache.h b/gpu/GrResourceCache.h
index a8309188..b2f91cdb 100644
--- a/gpu/GrResourceCache.h
+++ b/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<GrResourceEntry, GrResourceKey> fCache;
+ GrTMultiMap<GrResourceCacheEntry, GrResourceKey> fCache;
// We're an internal doubly linked list
- typedef SkTInternalLList<GrResourceEntry> EntryList;
+ typedef SkTInternalLList<GrResourceCacheEntry> EntryList;
EntryList fList;
#ifdef SK_DEBUG
@@ -356,7 +356,7 @@ private:
void purgeInvalidated();
#ifdef SK_DEBUG
- static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list);
+ static size_t countBytes(const SkTInternalLList<GrResourceCacheEntry>& list);
#endif
};
diff --git a/gpu/GrStencilBuffer.h b/gpu/GrStencilBuffer.h
index 37d40f16..696ba839 100644
--- a/gpu/GrStencilBuffer.h
+++ b/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/gpu/GrVertexBuffer.h b/gpu/GrVertexBuffer.h
index a2bd5a1b..c3cf5348 100644
--- a/gpu/GrVertexBuffer.h
+++ b/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/gpu/SkGrPixelRef.cpp b/gpu/SkGrPixelRef.cpp
index 18fefcc7..fd21f107 100644
--- a/gpu/SkGrPixelRef.cpp
+++ b/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/gpu/gl/GrGLIndexBuffer.cpp b/gpu/gl/GrGLIndexBuffer.cpp
index b6290b18..4e7f989c 100644
--- a/gpu/gl/GrGLIndexBuffer.cpp
+++ b/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/gpu/gl/GrGLIndexBuffer.h b/gpu/gl/GrGLIndexBuffer.h
index 32a80860..893e3571 100644
--- a/gpu/gl/GrGLIndexBuffer.h
+++ b/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/gpu/gl/GrGLPath.h b/gpu/gl/GrGLPath.h
index 3647d4d6..3409547b 100644
--- a/gpu/gl/GrGLPath.h
+++ b/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/gpu/gl/GrGLStencilBuffer.cpp b/gpu/gl/GrGLStencilBuffer.cpp
index 33e346c6..abcb3c4b 100644
--- a/gpu/gl/GrGLStencilBuffer.cpp
+++ b/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/gpu/gl/GrGLStencilBuffer.h b/gpu/gl/GrGLStencilBuffer.h
index 2bf33ef7..1cb0a330 100644
--- a/gpu/gl/GrGLStencilBuffer.h
+++ b/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/gpu/gl/GrGLVertexArray.cpp b/gpu/gl/GrGLVertexArray.cpp
index abd337a8..66feb820 100644
--- a/gpu/gl/GrGLVertexArray.cpp
+++ b/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/gpu/gl/GrGLVertexArray.h b/gpu/gl/GrGLVertexArray.h
index 8a61f1a2..0e5bffe4 100644
--- a/gpu/gl/GrGLVertexArray.h
+++ b/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/gpu/gl/GrGLVertexBuffer.cpp b/gpu/gl/GrGLVertexBuffer.cpp
index 685166c9..8bfe1f0c 100644
--- a/gpu/gl/GrGLVertexBuffer.cpp
+++ b/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/gpu/gl/GrGLVertexBuffer.h b/gpu/gl/GrGLVertexBuffer.h
index 1741adc2..1b9c4f17 100644
--- a/gpu/gl/GrGLVertexBuffer.h
+++ b/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/gpu/gl/GrGpuGL.cpp b/gpu/gl/GrGpuGL.cpp
index 9b92fe25..1a1bad7f 100644
--- a/gpu/gl/GrGpuGL.cpp
+++ b/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));