ccpr: Don't do coverage count transformations on literal coverage atlases

Previously we would just run coverage count transformations on
everything, including cached literal coverage atlases. This was
wasteful since it isn't necessary if the atlas already has literal
coverage. MSAA mode will introduce even more atlases that don't need
coverage count transformations, so it's definitely time to clean this
up.

Bug: skia:
Change-Id: Ifc72eaa7cbd4ab5e4ef4acb5610117ae9f54e4c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/227144
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 7a5d8f6..ac97fd8 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -13,6 +13,7 @@
 #include "src/gpu/GrCaps.h"
 #include "src/gpu/GrGeometryProcessor.h"
 #include "src/gpu/GrPipeline.h"
+#include "src/gpu/ccpr/GrCCAtlas.h"
 #include "src/gpu/ccpr/GrOctoBounds.h"
 
 class GrCCPathCacheEntry;
@@ -53,11 +54,26 @@
     static sk_sp<const GrGpuBuffer> FindVertexBuffer(GrOnFlushResourceProvider*);
     static sk_sp<const GrGpuBuffer> FindIndexBuffer(GrOnFlushResourceProvider*);
 
-    GrCCPathProcessor(const GrTexture* atlasTexture, const GrSwizzle&, GrSurfaceOrigin atlasOrigin,
-                      const SkMatrix& viewMatrixIfUsingLocalCoords = SkMatrix::I());
+    enum class CoverageMode : bool {
+        kCoverageCount,
+        kLiteral
+    };
+
+    static CoverageMode GetCoverageMode(GrCCAtlas::CoverageType coverageType) {
+        return (GrCCAtlas::CoverageType::kFP16_CoverageCount == coverageType)
+                ? CoverageMode::kCoverageCount
+                : CoverageMode::kLiteral;
+    }
+
+    GrCCPathProcessor(
+            CoverageMode, const GrTexture* atlasTexture, const GrSwizzle&,
+            GrSurfaceOrigin atlasOrigin,
+            const SkMatrix& viewMatrixIfUsingLocalCoords = SkMatrix::I());
 
     const char* name() const override { return "GrCCPathProcessor"; }
-    void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
+    void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override {
+        b->add32((uint32_t)fCoverageMode);
+    }
     GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
 
     void drawPaths(GrOpFlushState*, const GrPipeline&, const GrPipeline::FixedDynamicState*,
@@ -67,6 +83,7 @@
 private:
     const TextureSampler& onTextureSampler(int) const override { return fAtlasAccess; }
 
+    const CoverageMode fCoverageMode;
     const TextureSampler fAtlasAccess;
     SkISize fAtlasSize;
     GrSurfaceOrigin fAtlasOrigin;