Restore lazy image cache key logic
This was removed in https://skia-review.googlesource.com/c/skia/+/151661
It appears to be a no-op, but wrapping the original key means that images
and bitmaps with the same unique ID won't hit the same proxies in the
cache.
Change-Id: I9af0594349f22e56af1404c5bcb9e926ded8753e
Reviewed-on: https://skia-review.googlesource.com/153005
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index 6b2fb4a..454c867 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -117,6 +117,9 @@
bool willBeMipped,
SkColorSpace* dstColorSpace,
GrTextureMaker::AllowedTexGenType genType) override;
+
+ // TODO: Need to pass in dstColorSpace to fold into key here?
+ void makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) override;
#endif
private:
@@ -431,6 +434,15 @@
#if SK_SUPPORT_GPU
+void SkImage_Lazy::makeCacheKeyFromOrigKey(const GrUniqueKey& origKey, GrUniqueKey* cacheKey) {
+ // TODO: Take dstColorSpace, include hash in key
+ SkASSERT(!cacheKey->isValid());
+ if (origKey.isValid()) {
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey::Builder builder(cacheKey, origKey, kDomain, 0, "Image");
+ }
+}
+
class Generator_GrYUVProvider : public GrYUVProvider {
SkImageGenerator* fGen;
@@ -473,7 +485,7 @@
* 4. Ask the generator to return RGB(A) data, which the GPU can convert
*/
sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
- const GrUniqueKey& key,
+ const GrUniqueKey& origKey,
SkImage::CachingHint chint,
bool willBeMipped,
SkColorSpace* dstColorSpace,
@@ -491,7 +503,10 @@
enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 };
- // TODO: When implementing decode-to-dst, fold dstColorSpace hash into key
+ // Build our texture key.
+ // TODO: This needs to include the dstColorSpace.
+ GrUniqueKey key;
+ this->makeCacheKeyFromOrigKey(origKey, &key);
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
sk_sp<GrTextureProxy> proxy;