diff options
author | Brian Osman <brianosman@google.com> | 2017-05-08 15:16:45 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-08 19:56:27 +0000 |
commit | 83b1b3db36e8622f4bbc8c391d5c714e258d1e03 (patch) | |
tree | 95c4bf6e53bc73f90373fa06dbf6afa8298420e5 /src/gpu/GrResourceCache.h | |
parent | aef837a542cd91fba46bc0b3d4571a598710b90e (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.
Bug: skia:
Change-Id: I6c37b12c8ab5bce94b91190e5f0beb91d31ae81b
Reviewed-on: https://skia-review.googlesource.com/14180
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrResourceCache.h')
-rw-r--r-- | src/gpu/GrResourceCache.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index d871c9ad13..61770b1b86 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(const SkTArray<GrGpuResourceFreedMessage>&); 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. |