Revert x2 "Assert that all GrCaps colortype/format -> swizzle queries are legal."

This reverts commit b16f30bb92efcbb6a15db9c39e651f4c1412934e.

Bug: chromium:1066850

Change-Id: I57e233d370a7248867f709d52012726d19959379
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280900
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index b6cbdf8..4d084f9 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -31,12 +31,6 @@
     return clipBounds.isEmpty() || rect.isEmpty() || !SkIRect::Intersects(clipBounds, rect);
 }
 
-static constexpr auto kMaskOrigin = kTopLeft_GrSurfaceOrigin;
-
-static GrSurfaceProxyView find_filtered_mask(GrProxyProvider* provider, const GrUniqueKey& key) {
-    return provider->findCachedProxyWithColorTypeFallback(key, kMaskOrigin, GrColorType::kAlpha_8);
-}
-
 // Draw a mask using the supplied paint. Since the coverage/geometry
 // is already burnt into the mask this boils down to a rect draw.
 // Return true if the mask was successfully drawn.
@@ -87,11 +81,18 @@
                                                     : SkStrokeRec::kFill_InitStyle;
 
     if (key.isValid()) {
-        filteredMaskView = find_filtered_mask(proxyProvider, key);
+        // TODO: this cache look up is duplicated in draw_shape_with_mask_filter for gpu
+        static const GrSurfaceOrigin kCacheOrigin = kTopLeft_GrSurfaceOrigin;
+        auto filteredMask = proxyProvider->findOrCreateProxyByUniqueKey(key);
+        if (filteredMask) {
+            GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(
+                    filteredMask->backendFormat(), GrColorType::kAlpha_8);
+            filteredMaskView = GrSurfaceProxyView(std::move(filteredMask), kCacheOrigin, swizzle);
+        }
     }
 
     SkIRect drawRect;
-    if (filteredMaskView) {
+    if (filteredMaskView.proxy()) {
         SkRect devBounds = shape.bounds();
         viewMatrix.mapRect(&devBounds);
 
@@ -156,7 +157,7 @@
             return false;
         }
 
-        SkASSERT(kMaskOrigin == filteredMaskView.origin());
+        SkASSERT(kTopLeft_GrSurfaceOrigin == filteredMaskView.origin());
 
         drawRect = dstM.fBounds;
 
@@ -187,7 +188,7 @@
     auto approxSize = GrResourceProvider::MakeApprox(maskRect.size());
     auto rtContext = GrRenderTargetContext::MakeWithFallback(
             context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, approxSize, sampleCnt,
-            GrMipMapped::kNo, GrProtected::kNo, kMaskOrigin);
+            GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
     if (!rtContext) {
         return nullptr;
     }
@@ -201,8 +202,8 @@
     const SkIRect clipRect = SkIRect::MakeWH(maskRect.width(), maskRect.height());
     GrFixedClip clip(clipRect);
 
-    // Draw the mask into maskTexture with the path's integerized top-left at the origin using
-    // maskPaint.
+    // Draw the mask into maskTexture with the path's integerized top-left at
+    // the origin using maskPaint.
     SkMatrix viewMatrix = origViewMatrix;
     viewMatrix.postTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
     rtContext->drawShape(clip, std::move(maskPaint), GrAA::kYes, viewMatrix, shape);
@@ -397,10 +398,18 @@
         GrProxyProvider* proxyProvider = context->priv().proxyProvider();
 
         if (maskKey.isValid()) {
-            filteredMaskView = find_filtered_mask(proxyProvider, maskKey);
+            // TODO: this cache look up is duplicated in sw_draw_with_mask_filter for raster
+            static const GrSurfaceOrigin kCacheOrigin = kTopLeft_GrSurfaceOrigin;
+            auto filteredMask = proxyProvider->findOrCreateProxyByUniqueKey(maskKey);
+            if (filteredMask) {
+                GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(
+                        filteredMask->backendFormat(), GrColorType::kAlpha_8);
+                filteredMaskView = GrSurfaceProxyView(std::move(filteredMask), kCacheOrigin,
+                                                      swizzle);
+            }
         }
 
-        if (!filteredMaskView) {
+        if (!filteredMaskView.proxy()) {
             std::unique_ptr<GrRenderTargetContext> maskRTC(create_mask_GPU(
                                                            context,
                                                            maskRect,
@@ -422,7 +431,7 @@
             }
         }
 
-        if (filteredMaskView) {
+        if (filteredMaskView.proxy()) {
             if (draw_mask(renderTargetContext, clip, viewMatrix, maskRect, std::move(paint),
                           std::move(filteredMaskView))) {
                 // This path is completely drawn