Don't use color type derived from GrPixelConfig to determine proxy texture swizzle.

Change-Id: Ib19e378d7dd8243cbbee68e97bcb3b6159943500
Bug: skia:6718
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233898
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index 016b907..48ff321 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -44,7 +44,9 @@
     sk_sp<GrTextureProxy> proxy;
 
     if (fOriginalKey.isValid()) {
-        proxy = proxyProvider->findOrCreateProxyByUniqueKey(fOriginalKey, kTopLeft_GrSurfaceOrigin);
+        auto colorType = SkColorTypeToGrColorType(fBitmap.colorType());
+        proxy = proxyProvider->findOrCreateProxyByUniqueKey(fOriginalKey, colorType,
+                                                            kTopLeft_GrSurfaceOrigin);
         if (proxy && (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped())) {
             return proxy;
         }
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 10f1d16..6a08f6f 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -80,7 +80,8 @@
 
     if (key.isValid()) {
         // TODO: this cache look up is duplicated in draw_shape_with_mask_filter for gpu
-        filteredMask = proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
+        filteredMask = proxyProvider->findOrCreateProxyByUniqueKey(key, GrColorType::kAlpha_8,
+                                                                   kTopLeft_GrSurfaceOrigin);
     }
 
     SkIRect drawRect;
@@ -389,7 +390,7 @@
         if (maskKey.isValid()) {
             // TODO: this cache look up is duplicated in sw_draw_with_mask_filter for raster
             filteredMask = proxyProvider->findOrCreateProxyByUniqueKey(
-                                                maskKey, kTopLeft_GrSurfaceOrigin);
+                    maskKey, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
         }
 
         if (!filteredMask) {
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index c29e63e..90c3e64 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -350,7 +350,7 @@
                          reducedClip.numAnalyticFPs(), &key);
 
     sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey(
-                                                                key, kTopLeft_GrSurfaceOrigin));
+            key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
     if (proxy) {
         return proxy;
     }
@@ -473,7 +473,7 @@
     const GrCaps* caps = context->priv().caps();
 
     sk_sp<GrTextureProxy> proxy(proxyProvider->findOrCreateProxyByUniqueKey(
-                                                                  key, kTopLeft_GrSurfaceOrigin));
+            key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
     if (proxy) {
         return proxy;
     }
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index ab5dcc9..244a0db 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -57,9 +57,9 @@
 }
 
 sk_sp<GrTextureProxy> GrOnFlushResourceProvider::findOrCreateProxyByUniqueKey(
-        const GrUniqueKey& key, GrSurfaceOrigin origin) {
+        const GrUniqueKey& key, GrColorType colorType, GrSurfaceOrigin origin) {
     auto proxyProvider = fDrawingMgr->getContext()->priv().proxyProvider();
-    return proxyProvider->findOrCreateProxyByUniqueKey(key, origin);
+    return proxyProvider->findOrCreateProxyByUniqueKey(key, colorType, origin);
 }
 
 bool GrOnFlushResourceProvider::instatiateProxy(GrSurfaceProxy* proxy) {
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index 6cf0055..40a8afd 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -75,7 +75,9 @@
     bool assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*);
     void removeUniqueKeyFromProxy(GrTextureProxy*);
     void processInvalidUniqueKey(const GrUniqueKey&);
-    sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
+    // GrColorType is necessary to set the proxy's texture swizzle.
+    sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrColorType,
+                                                       GrSurfaceOrigin);
 
     bool instatiateProxy(GrSurfaceProxy*);
 
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 1148e76..bfa6a63 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -158,7 +158,7 @@
         return nullptr;
     }
 
-    return this->createWrapped(std::move(tex), origin);
+    return this->createWrapped(std::move(tex), colorType, origin);
 }
 
 sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy(
@@ -183,18 +183,19 @@
 }
 
 sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createWrapped(sk_sp<GrTexture> tex,
+                                                                 GrColorType colorType,
                                                                  GrSurfaceOrigin origin) {
-    return this->createWrapped(std::move(tex), origin);
+    return this->createWrapped(std::move(tex), colorType, origin);
 }
 #endif
 
-sk_sp<GrTextureProxy> GrProxyProvider::createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) {
+sk_sp<GrTextureProxy> GrProxyProvider::createWrapped(sk_sp<GrTexture> tex, GrColorType colorType,
+                                                     GrSurfaceOrigin origin) {
 #ifdef SK_DEBUG
     if (tex->getUniqueKey().isValid()) {
         SkASSERT(!this->findProxyByUniqueKey(tex->getUniqueKey(), origin));
     }
 #endif
-    GrColorType colorType = GrPixelConfigToColorType(tex->config());
     GrSwizzle texSwizzle = this->caps()->getTextureSwizzle(tex->backendFormat(), colorType);
 
     if (tex->asRenderTarget()) {
@@ -207,6 +208,7 @@
 }
 
 sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
+                                                                    GrColorType colorType,
                                                                     GrSurfaceOrigin origin) {
     ASSERT_SINGLE_OWNER
 
@@ -234,10 +236,12 @@
     sk_sp<GrTexture> texture(static_cast<GrSurface*>(resource)->asTexture());
     SkASSERT(texture);
 
-    result = this->createWrapped(std::move(texture), origin);
+    result = this->createWrapped(std::move(texture), colorType, origin);
     SkASSERT(result->getUniqueKey() == key);
     // createWrapped should've added this for us
     SkASSERT(fUniquelyKeyedProxies.find(key));
+    SkASSERT(result->textureSwizzle() ==
+             this->caps()->getTextureSwizzle(result->backendFormat(), colorType));
     return result;
 }
 
@@ -255,10 +259,9 @@
     }
 
     const SkImageInfo& info = srcImage->imageInfo();
-    SkColorType ct = info.colorType();
-    GrColorType grCT = SkColorTypeToGrColorType(ct);
+    GrColorType ct = SkColorTypeToGrColorType(info.colorType());
 
-    GrBackendFormat format = this->caps()->getDefaultBackendFormat(grCT, renderable);
+    GrBackendFormat format = this->caps()->getDefaultBackendFormat(ct, renderable);
 
     if (!format.isValid()) {
         SkBitmap copy8888;
@@ -268,9 +271,8 @@
         }
         copy8888.setImmutable();
         srcImage = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
-        ct = kRGBA_8888_SkColorType;
-        grCT = GrColorType::kRGBA_8888;
-        format = this->caps()->getDefaultBackendFormat(grCT, renderable);
+        ct = GrColorType::kRGBA_8888;
+        format = this->caps()->getDefaultBackendFormat(ct, renderable);
         if (!format.isValid()) {
             return nullptr;
         }
@@ -283,7 +285,7 @@
         }
     }
 
-    GrPixelConfig config = SkColorType2GrPixelConfig(ct);
+    GrPixelConfig config = GrColorTypeToPixelConfig(ct);
     if (kUnknown_GrPixelConfig == config) {
         return nullptr;
     }
@@ -294,14 +296,14 @@
     desc.fConfig = config;
 
     sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
-            [desc, format, renderable, sampleCnt, budgeted, srcImage,
-             fit](GrResourceProvider* resourceProvider) {
+            [desc, format, renderable, sampleCnt, budgeted, srcImage, fit,
+             ct](GrResourceProvider* resourceProvider) {
                 SkPixmap pixMap;
                 SkAssertResult(srcImage->peekPixels(&pixMap));
                 GrMipLevel mipLevel = { pixMap.addr(), pixMap.rowBytes() };
 
                 return LazyInstantiationResult(resourceProvider->createTexture(
-                        desc, format, renderable, sampleCnt, budgeted, fit, GrProtected::kNo,
+                        desc, format, renderable, sampleCnt, budgeted, fit, GrProtected::kNo, ct,
                         mipLevel, GrResourceProvider::Flags::kNoPendingIO));
             },
             format, desc, renderable, sampleCnt, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 76c8e56..58c884e 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -52,9 +52,12 @@
 
     /*
      * Finds a proxy by unique key or creates a new one that wraps a resource matching the unique
-     * key.
+     * key. GrColorType is required to set the proxy's texture swizzle on creation. For any key,
+     * each call that might result in a cache hit must provide the same colorType as the call that
+     * caused a cache miss and created the proxy.
      */
-    sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
+    sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrColorType colorType,
+                                                       GrSurfaceOrigin);
 
     /*
      * Create an un-mipmapped texture proxy with data. The SkImage must be a raster backend image.
@@ -268,7 +271,7 @@
                                                               SkBudgeted budgeted,
                                                               GrProtected isProtected);
 
-    sk_sp<GrTextureProxy> testingOnly_createWrapped(sk_sp<GrTexture>, GrSurfaceOrigin);
+    sk_sp<GrTextureProxy> testingOnly_createWrapped(sk_sp<GrTexture>, GrColorType, GrSurfaceOrigin);
 #endif
 
 private:
@@ -277,7 +280,8 @@
 
     bool isAbandoned() const;
 
-    sk_sp<GrTextureProxy> createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin);
+    // GrColorType is used to determine the proxy's texture swizzle.
+    sk_sp<GrTextureProxy> createWrapped(sk_sp<GrTexture> tex, GrColorType, GrSurfaceOrigin origin);
 
     struct UniquelyKeyedProxyHashTraits {
         static const GrUniqueKey& GetKey(const GrTextureProxy& p) { return p.getUniqueKey(); }
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index cff3fcf..1269498 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -79,9 +79,11 @@
 sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
                                                    const GrBackendFormat& format,
                                                    GrRenderable renderable,
-                                                   int renderTargetSampleCnt, SkBudgeted budgeted,
+                                                   int renderTargetSampleCnt,
+                                                   SkBudgeted budgeted,
                                                    GrProtected isProtected,
-                                                   const GrMipLevel texels[], int mipLevelCount) {
+                                                   const GrMipLevel texels[],
+                                                   int mipLevelCount) {
     ASSERT_SINGLE_OWNER
 
     SkASSERT(mipLevelCount > 0);
@@ -141,6 +143,7 @@
                                                    SkBudgeted budgeted,
                                                    SkBackingFit fit,
                                                    GrProtected isProtected,
+                                                   GrColorType srcColorType,
                                                    const GrMipLevel& mipLevel,
                                                    Flags flags) {
     ASSERT_SINGLE_OWNER
@@ -172,7 +175,6 @@
         return nullptr;
     }
 
-    GrColorType colorType = GrPixelConfigToColorType(desc.fConfig);
     sk_sp<GrTexture> tex =
             (SkBackingFit::kApprox == fit)
                     ? this->createApproxTexture(desc, format, renderable, renderTargetSampleCnt,
@@ -183,20 +185,21 @@
         return nullptr;
     }
 
-    sk_sp<GrTextureProxy> proxy = proxyProvider->createWrapped(tex, kTopLeft_GrSurfaceOrigin);
+    sk_sp<GrTextureProxy> proxy =
+            proxyProvider->createWrapped(tex, srcColorType, kTopLeft_GrSurfaceOrigin);
     if (!proxy) {
         return nullptr;
     }
     // Here we don't really know the alpha type of the data we want to upload. All we really
     // care about is that it is not converted. So we use the same alpha type for the data
     // and the surface context.
-    static constexpr auto kAlphaType = kPremul_SkAlphaType;
+    static constexpr auto kAlphaType = kUnpremul_SkAlphaType;
     sk_sp<GrSurfaceContext> sContext =
-            context->priv().makeWrappedSurfaceContext(std::move(proxy), colorType, kAlphaType);
+            context->priv().makeWrappedSurfaceContext(std::move(proxy), srcColorType, kAlphaType);
     if (!sContext) {
         return nullptr;
     }
-    GrPixelInfo srcInfo(colorType, kAlphaType, nullptr, desc.fWidth, desc.fHeight);
+    GrPixelInfo srcInfo(srcColorType, kAlphaType, nullptr, desc.fWidth, desc.fHeight);
     SkAssertResult(sContext->writePixels(srcInfo, tmpLevel.fPixels, tmpLevel.fRowBytes, {0, 0}));
     return tex;
 }
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 7df4b6b..c6bcef2 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -108,6 +108,7 @@
                                    SkBudgeted budgeted,
                                    SkBackingFit fit,
                                    GrProtected isProtected,
+                                   GrColorType srcColorType,
                                    const GrMipLevel& mipLevel,
                                    Flags flags);
 
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index d43775e..a3d3f49 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -324,7 +324,8 @@
 
     sk_sp<GrTextureProxy> proxy;
     if (useCache) {
-        proxy = fProxyProvider->findOrCreateProxyByUniqueKey(maskKey, kTopLeft_GrSurfaceOrigin);
+        proxy = fProxyProvider->findOrCreateProxyByUniqueKey(maskKey, GrColorType::kAlpha_8,
+                                                             kTopLeft_GrSurfaceOrigin);
     }
     if (!proxy) {
         SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 05f8396..18d72a3 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -44,7 +44,7 @@
     this->makeCopyKey(copyParams, &key);
     sk_sp<GrTextureProxy> cachedCopy;
     if (key.isValid()) {
-        cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(key,
+        cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(key, this->colorType(),
                                                                  this->originalProxy()->origin());
         if (cachedCopy && (!willBeMipped || GrMipMapped::kYes == cachedCopy->mipMapped())) {
             return cachedCopy;
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index ca25e00..fa428ed 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -54,7 +54,8 @@
     this->makeCopyKey(copyParams, &copyKey);
     sk_sp<GrTextureProxy> cachedProxy;
     if (copyKey.isValid()) {
-        cachedProxy = proxyProvider->findOrCreateProxyByUniqueKey(copyKey, origOrigin);
+        cachedProxy =
+                proxyProvider->findOrCreateProxyByUniqueKey(copyKey, this->colorType(), origOrigin);
         if (cachedProxy && (!willBeMipped || GrMipMapped::kYes == cachedProxy->mipMapped())) {
             return cachedProxy;
         }
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 668448b..6db4e37 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -189,7 +189,9 @@
     create_unique_key_for_image(srcImage.get(), &originalKey);
 
     if (originalKey.isValid()) {
-        proxy = proxyProvider->findOrCreateProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin);
+        proxy = proxyProvider->findOrCreateProxyByUniqueKey(
+                originalKey, SkColorTypeToGrColorType(srcImage->colorType()),
+                kTopLeft_GrSurfaceOrigin);
     }
     if (!proxy) {
         proxy = proxyProvider->createTextureProxy(srcImage, GrRenderable::kNo, 1, SkBudgeted::kYes,
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index 89eff1a..aff4644 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -55,21 +55,19 @@
     GrPixelConfig pixelConfig;
     int sampleCount;
 
-    GrBackendFormat format;
+    auto colorType = CoverageTypeToColorType(coverageType);
+    GrBackendFormat format = caps.getDefaultBackendFormat(colorType, GrRenderable::kYes);
     switch (coverageType) {
         case CoverageType::kFP16_CoverageCount:
-            format = caps.getDefaultBackendFormat(GrColorType::kAlpha_F16, GrRenderable::kYes);
             pixelConfig = kAlpha_half_GrPixelConfig;
             sampleCount = 1;
             break;
         case CoverageType::kA8_Multisample:
-            format = caps.getDefaultBackendFormat(GrColorType::kAlpha_8, GrRenderable::kYes);
             SkASSERT(caps.internalMultisampleCount(format) > 1);
             pixelConfig = kAlpha_8_GrPixelConfig;
             sampleCount = (caps.mixedSamplesSupport()) ? 1 : caps.internalMultisampleCount(format);
             break;
         case CoverageType::kA8_LiteralCoverage:
-            format = caps.getDefaultBackendFormat(GrColorType::kAlpha_8, GrRenderable::kYes);
             pixelConfig = kAlpha_8_GrPixelConfig;
             sampleCount = 1;
             break;
diff --git a/src/gpu/ccpr/GrCCAtlas.h b/src/gpu/ccpr/GrCCAtlas.h
index 125f41a..724a017 100644
--- a/src/gpu/ccpr/GrCCAtlas.h
+++ b/src/gpu/ccpr/GrCCAtlas.h
@@ -53,6 +53,17 @@
         kA8_LiteralCoverage
     };
 
+    static constexpr GrColorType CoverageTypeToColorType(CoverageType coverageType) {
+        switch (coverageType) {
+            case CoverageType::kFP16_CoverageCount:
+                return GrColorType::kAlpha_F16;
+            case CoverageType::kA8_Multisample:
+            case CoverageType::kA8_LiteralCoverage:
+                return GrColorType::kAlpha_8;
+        }
+        SkUNREACHABLE;
+    }
+
     using LazyInstantiateAtlasCallback = std::function<sk_sp<GrTexture>(
             GrResourceProvider*, GrPixelConfig, const GrBackendFormat&, int sampleCount)>;
 
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index 30400cb..5c5237d 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -229,8 +229,9 @@
             SkASSERT(SkToBool(entry->fCachedAtlas->peekOnFlushRefCnt()) ==
                      SkToBool(entry->fCachedAtlas->getOnFlushProxy()));
             if (!entry->fCachedAtlas->getOnFlushProxy()) {
+                auto ct = GrCCAtlas::CoverageTypeToColorType(entry->fCachedAtlas->coverageType());
                 if (sk_sp<GrTextureProxy> onFlushProxy = onFlushRP->findOrCreateProxyByUniqueKey(
-                        entry->fCachedAtlas->textureKey(), GrCCAtlas::kTextureOrigin)) {
+                            entry->fCachedAtlas->textureKey(), ct, GrCCAtlas::kTextureOrigin)) {
                     onFlushProxy->priv().setIgnoredByResourceAllocator();
                     entry->fCachedAtlas->setOnFlushProxy(std::move(onFlushProxy));
                 }
diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
index c969249..9fe9295 100644
--- a/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
+++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.fp
@@ -226,8 +226,8 @@
         builder[0] = sigmaToCircleRRatioFixed;
         builder.finish();
 
-        sk_sp<GrTextureProxy> blurProfile =
-                      proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
+        sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
+                key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
         if (!blurProfile) {
             static constexpr int kProfileTextureWidth = 512;
 
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index 1ecc95d..cf23511 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -51,7 +51,7 @@
         GrProxyProvider* proxyProvider = context->priv().proxyProvider();
 
         sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey(
-                                                                 key, kBottomLeft_GrSurfaceOrigin));
+                key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
         if (!mask) {
             // TODO: this could be approx but the texture coords will need to be updated
             sk_sp<GrRenderTargetContext> rtc(
diff --git a/src/gpu/effects/GrRectBlurEffect.fp b/src/gpu/effects/GrRectBlurEffect.fp
index 0eb4bdb..12e3614 100644
--- a/src/gpu/effects/GrRectBlurEffect.fp
+++ b/src/gpu/effects/GrRectBlurEffect.fp
@@ -52,7 +52,7 @@
         builder.finish();
 
         sk_sp<GrTextureProxy> blurProfile(proxyProvider->findOrCreateProxyByUniqueKey(
-                                                                    key, kTopLeft_GrSurfaceOrigin));
+                key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
         if (!blurProfile) {
             SkImageInfo ii = SkImageInfo::MakeA8(profileSize, 1);
 
diff --git a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
index 8211f61..9445a5a 100644
--- a/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
+++ b/src/gpu/effects/generated/GrCircleBlurFragmentProcessor.cpp
@@ -203,8 +203,8 @@
     builder[0] = sigmaToCircleRRatioFixed;
     builder.finish();
 
-    sk_sp<GrTextureProxy> blurProfile =
-            proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
+    sk_sp<GrTextureProxy> blurProfile = proxyProvider->findOrCreateProxyByUniqueKey(
+            key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin);
     if (!blurProfile) {
         static constexpr int kProfileTextureWidth = 512;
 
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h
index aa00554..ffec0a3 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.h
@@ -51,8 +51,8 @@
 
         GrProxyProvider* proxyProvider = context->priv().proxyProvider();
 
-        sk_sp<GrTextureProxy> mask(
-                proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
+        sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey(
+                key, GrColorType::kAlpha_8, kBottomLeft_GrSurfaceOrigin));
         if (!mask) {
             // TODO: this could be approx but the texture coords will need to be updated
             sk_sp<GrRenderTargetContext> rtc(
diff --git a/src/gpu/effects/generated/GrRectBlurEffect.h b/src/gpu/effects/generated/GrRectBlurEffect.h
index eee6b71..361aa26 100644
--- a/src/gpu/effects/generated/GrRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRectBlurEffect.h
@@ -31,8 +31,8 @@
         builder[0] = profileSize;
         builder.finish();
 
-        sk_sp<GrTextureProxy> blurProfile(
-                proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin));
+        sk_sp<GrTextureProxy> blurProfile(proxyProvider->findOrCreateProxyByUniqueKey(
+                key, GrColorType::kAlpha_8, kTopLeft_GrSurfaceOrigin));
         if (!blurProfile) {
             SkImageInfo ii = SkImageInfo::MakeA8(profileSize, 1);
 
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index b31063e..fbccdc2 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -396,7 +396,8 @@
 
     // 1. Check the cache for a pre-existing one
     if (key.isValid()) {
-        proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, kTopLeft_GrSurfaceOrigin);
+        auto ct = SkColorTypeToGrColorType(this->colorType());
+        proxy = proxyProvider->findOrCreateProxyByUniqueKey(key, ct, kTopLeft_GrSurfaceOrigin);
         if (proxy) {
             SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath,
                                      kLockTexturePathCount);