aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceCache.h
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-05-09 13:19:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-09 18:45:04 +0000
commit13dddce65fd87a8175a209a49f35615735a2886a (patch)
tree0f7d85e7ba8db0b3acc7c0ac2dccd839808856cf /src/gpu/GrResourceCache.h
parent3734c7d9e39cce682c5095a8f187d41223955f5c (diff)
Added SkImage::MakeCrossContextFromEncoded
Designed for Flutter's threading architecture, with an eye to being useful to other clients. Under the hood, uses a new image generator class to lazily wrap a texture for multiple GrContexts. Re-land of https://skia-review.googlesource.com/c/14180/ Bug: skia: Change-Id: I3dd382640629b79b3058f18fee68d043566e43e5 Reviewed-on: https://skia-review.googlesource.com/15895 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/GrResourceCache.h')
-rw-r--r--src/gpu/GrResourceCache.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index d871c9ad13..71070ee6e9 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -24,6 +24,11 @@ class GrCaps;
class SkString;
class SkTraceMemoryDump;
+struct GrGpuResourceFreedMessage {
+ GrGpuResource* fResource;
+ uint32_t fOwningUniqueID;
+};
+
/**
* Manages the lifetime of all GrGpuResource instances.
*
@@ -43,7 +48,7 @@ class SkTraceMemoryDump;
*/
class GrResourceCache {
public:
- GrResourceCache(const GrCaps* caps);
+ GrResourceCache(const GrCaps* caps, uint32_t contextUniqueID);
~GrResourceCache();
// Default maximum number of budgeted resources in the cache.
@@ -174,6 +179,9 @@ public:
};
void notifyFlushOccurred(FlushType);
+ /** Maintain a ref to this resource until we receive a GrGpuResourceFreedMessage. */
+ void insertCrossContextGpuResource(GrGpuResource* resource);
+
#if GR_CACHE_STATS
struct Stats {
int fTotal;
@@ -241,6 +249,7 @@ private:
/// @}
void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>&);
+ void processFreedGpuResources();
void addToNonpurgeableArray(GrGpuResource*);
void removeFromNonpurgeableArray(GrGpuResource*);
bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCount > fMaxCount; }
@@ -287,6 +296,7 @@ private:
}
typedef SkMessageBus<GrUniqueKeyInvalidatedMessage>::Inbox InvalidUniqueKeyInbox;
+ typedef SkMessageBus<GrGpuResourceFreedMessage>::Inbox FreedGpuResourceInbox;
typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue;
typedef SkTDArray<GrGpuResource*> ResourceArray;
@@ -326,6 +336,9 @@ private:
uint32_t fExternalFlushCnt;
InvalidUniqueKeyInbox fInvalidUniqueKeyInbox;
+ FreedGpuResourceInbox fFreedGpuResourceInbox;
+
+ uint32_t fContextUniqueID;
// This resource is allowed to be in the nonpurgeable array for the sake of validate() because
// we're in the midst of converting it to purgeable status.