Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: include/gpu/GrResource.h

Issue 24222004: Don't reuse scratch textures patch (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: check nothing changes Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrResource.h
===================================================================
--- include/gpu/GrResource.h (revision 11979)
+++ include/gpu/GrResource.h (working copy)
@@ -66,10 +66,24 @@
void setCacheEntry(GrResourceEntry* cacheEntry) { fCacheEntry = cacheEntry; }
GrResourceEntry* getCacheEntry() { return fCacheEntry; }
- void incDeferredRefCount() const { SkASSERT(fDeferredRefCount >= 0); ++fDeferredRefCount; }
- void decDeferredRefCount() const { SkASSERT(fDeferredRefCount > 0); --fDeferredRefCount; }
+ void incDeferredRefCount() const {
+ SkASSERT(fDeferredRefCount >= 0);
+ ++fDeferredRefCount;
+ }
+
+ void decDeferredRefCount() const {
+ SkASSERT(fDeferredRefCount > 0);
+ --fDeferredRefCount;
+ if (0 == fDeferredRefCount && this->needsDeferredUnref()) {
+ SkASSERT(this->getRefCnt() > 1);
+ this->unref();
+ }
+ }
+
int getDeferredRefCount() const { return fDeferredRefCount; }
+ void setNeedsDeferredUnref() { fFlags |= kDeferredUnref_FlagBit; }
+
protected:
/**
* isWrapped indicates we have wrapped a client-created backend resource in a GrResource. If it
@@ -87,7 +101,8 @@
virtual void onAbandon() {};
bool isInCache() const { return NULL != fCacheEntry; }
- bool isWrapped() const { return kWrapped_Flag & fFlags; }
+ bool isWrapped() const { return kWrapped_FlagBit & fFlags; }
+ bool needsDeferredUnref() const { return SkToBool(kDeferredUnref_FlagBit & fFlags); }
private:
#ifdef SK_DEBUG
@@ -105,7 +120,20 @@
mutable int fDeferredRefCount; // How many references in deferred drawing buffers.
enum Flags {
- kWrapped_Flag = 0x1,
+ /**
+ * This resource wraps a GPU resource given to us by the user.
+ * Lifetime management is left up to the user (i.e., we will not
+ * free it).
+ */
+ kWrapped_FlagBit = 0x1,
+
+ /**
+ * This texture should be de-refed when the deferred ref count goes
+ * to zero. A resource gets into this state when the resource cache
+ * is holding a ref-of-obligation (i.e., someone needs to own it but
+ * no one else wants to) but doesn't really want to keep it around.
+ */
+ kDeferredUnref_FlagBit = 0x2,
};
uint32_t fFlags;
« no previous file with comments | « no previous file | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698