diff options
author | 2017-09-20 15:58:44 -0400 | |
---|---|---|
committer | 2017-09-20 20:21:50 +0000 | |
commit | d4f100dad90ed5beb1b614464d8c4fcb22c0a993 (patch) | |
tree | 4194bbcbe1884a5454143a7579f656113cf8f00f /include | |
parent | 8d4a5c75f07a70f71320a426f392783dbcf180ba (diff) |
Add native caching of uniquely keyed GrTextureProxies
Change-Id: I303fe025b7856b8d681a2d35b416c015bd468e1d
Reviewed-on: https://skia-review.googlesource.com/48300
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/private/GrSurfaceProxy.h | 2 | ||||
-rw-r--r-- | include/private/GrTextureProxy.h | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 12ba91ba91..fcb839c1fe 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -378,7 +378,7 @@ protected: bool instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, bool needsStencil, GrSurfaceFlags flags, bool isMipMapped, - SkDestinationSurfaceColorMode mipColorMode); + SkDestinationSurfaceColorMode mipColorMode, const GrUniqueKey*); // For wrapped resources, 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always be filled in // from the wrapped resource. diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 9db2bb2e50..3634ce4d0a 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -12,6 +12,7 @@ #include "GrSurfaceProxy.h" class GrCaps; +class GrResourceCache; class GrResourceProvider; class GrTextureOpList; @@ -38,6 +39,31 @@ public: bool isMipMapped() const { return fIsMipMapped; } + /** + * Return the texture proxy's unique key. It will be invalid if the proxy doesn't have one. + */ + const GrUniqueKey& getUniqueKey() const { +#ifdef SK_DEBUG + if (fTarget && fUniqueKey.isValid()) { + SkASSERT(fTarget->getUniqueKey().isValid()); + // It is possible for a non-keyed proxy to have a uniquely keyed resource assigned to + // it. This just means that a future user of the resource will be filling it with unique + // data. However, if the proxy has a unique key its attached resource should also + // have that key. + SkASSERT(fUniqueKey == fTarget->getUniqueKey()); + } +#endif + + return fUniqueKey; + } + + /** + * Internal-only helper class used for manipulations of the resource by the cache. + */ + class CacheAccess; + inline CacheAccess cacheAccess(); + inline const CacheAccess cacheAccess() const; + protected: friend class GrSurfaceProxy; // for ctors @@ -47,6 +73,8 @@ protected: // Wrapped version GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin); + ~GrTextureProxy() override; + SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; } sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; @@ -55,8 +83,15 @@ private: bool fIsMipMapped; SkDestinationSurfaceColorMode fMipColorMode; + GrUniqueKey fUniqueKey; + GrResourceCache* fCache; // only set when fUniqueKey is valid + size_t onUninstantiatedGpuMemorySize() const override; + // Methods made available via GrTextureProxy::CacheAccess + void setUniqueKey(GrResourceCache*, const GrUniqueKey&); + void clearUniqueKey(); + // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy. // For deferred proxies that pointer will be filled in when we need to instantiate // the deferred resource |