aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrGpuResource.h19
-rwxr-xr-xsrc/gpu/GrContext.cpp2
-rw-r--r--src/gpu/GrGpuResource.cpp7
-rw-r--r--src/gpu/GrResourceCache.cpp15
-rw-r--r--src/gpu/GrResourceCache2.cpp6
5 files changed, 26 insertions, 23 deletions
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index b01f0e9c34..afd9275d47 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -71,7 +71,7 @@ public:
}
protected:
- GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { }
+ GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0), fIsScratch(kNo_IsScratch) { }
bool internalHasPendingRead() const { return SkToBool(fPendingReads); }
bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); }
@@ -118,7 +118,16 @@ private:
// This class is used to manage conversion of refs to pending reads/writes.
friend class GrGpuResourceRef;
- friend class GrResourceCache2; // to check IO ref counts.
+
+ // This is temporary until GrResourceCache is fully replaced by GrResourceCache2.
+ enum IsScratch {
+ kNo_IsScratch,
+ kYes_IsScratch
+ } fIsScratch;
+
+ friend class GrContext; // to set the above field.
+ friend class GrResourceCache; // to check the above field.
+ friend class GrResourceCache2; // to check the above field.
template <typename, GrIOType> friend class GrPendingIOResource;
};
@@ -181,12 +190,6 @@ public:
*/
const GrResourceKey& getScratchKey() const { return fScratchKey; }
- /**
- * If this resource is currently cached by its contents then this will return
- * the content key. Otherwise, NULL is returned.
- */
- const GrResourceKey* getContentKey() const;
-
/**
* Gets an id that is unique for this GrGpuResource object. It is static in that it does
* not change when the content of the GrGpuResource object changes. This will never return
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6ece67fd10..a722eed88a 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
+
#include "GrContext.h"
#include "effects/GrConfigConversionEffect.h"
@@ -443,6 +444,7 @@ GrTexture* GrContext::createNewScratchTexture(const GrTextureDesc& desc) {
return NULL;
}
fResourceCache->addResource(texture->getScratchKey(), texture);
+ texture->fIsScratch = GrGpuResource::kYes_IsScratch;
return texture;
}
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 5452184793..a074d7c29e 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -101,13 +101,6 @@ void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) {
fScratchKey = scratchKey;
}
-const GrResourceKey* GrGpuResource::getContentKey() const {
- if (fCacheEntry && !fCacheEntry->key().isScratch()) {
- return &fCacheEntry->key();
- }
- return NULL;
-}
-
uint32_t GrGpuResource::CreateUniqueID() {
static int32_t gUniqueID = SK_InvalidUniqueID;
uint32_t id;
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index f50ed7d032..c683b5bcfc 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -6,10 +6,13 @@
* found in the LICENSE file.
*/
+
+
#include "GrResourceCache.h"
#include "GrGpuResource.h"
#include "GrTexturePriv.h"
+
DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage);
///////////////////////////////////////////////////////////////////////////////
@@ -178,7 +181,7 @@ void GrResourceCache::notifyPurgable(const GrGpuResource* resource) {
// scratch texture reuse is turned off.
SkASSERT(resource->getCacheEntry());
if (resource->getCacheEntry()->key().getResourceType() == GrTexturePriv::ResourceType() &&
- resource->getCacheEntry()->key().isScratch() &&
+ resource->fIsScratch &&
!fCaps->reuseScratchTextures() &&
!(static_cast<const GrTexture*>(resource)->desc().fFlags &
kRenderTarget_GrTextureFlagBit)) {
@@ -187,12 +190,12 @@ void GrResourceCache::notifyPurgable(const GrGpuResource* resource) {
}
GrGpuResource* GrResourceCache::find(const GrResourceKey& key) {
- // GrResourceCache2 is responsible for scratch resources.
- SkASSERT(!key.isScratch());
-
GrAutoResourceCacheValidate atcv(this);
- GrResourceCacheEntry* entry = fCache.find(key);
+ GrResourceCacheEntry* entry = NULL;
+
+ entry = fCache.find(key);
+
if (NULL == entry) {
return NULL;
}
@@ -201,6 +204,8 @@ GrGpuResource* GrResourceCache::find(const GrResourceKey& key) {
this->internalDetach(entry);
this->attachToHead(entry);
+ // GrResourceCache2 is responsible for scratch resources.
+ SkASSERT(GrGpuResource::kNo_IsScratch == entry->resource()->fIsScratch);
return entry->fResource;
}
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index 76673cf9f9..85e66a7642 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -67,15 +67,15 @@ public:
// either by drawing code or for pending io operations.
// This will be removed when flush no longer creates resources.
return resource->reffedOnlyByCache() && !resource->internalHasPendingIO() &&
- (NULL == resource->getContentKey());
+ GrGpuResource::kYes_IsScratch == resource->fIsScratch;
} else {
// Because duties are currently shared between GrResourceCache and GrResourceCache2, the
// current interpretation of this rule is that only GrResourceCache has a ref but that
// it has been marked as a scratch resource.
- return resource->reffedOnlyByCache() && (NULL == resource->getContentKey());
+ return resource->reffedOnlyByCache() &&
+ GrGpuResource::kYes_IsScratch == resource->fIsScratch;
}
}
-
private:
bool fFlushing;
};