Disable CCPR everywhere except testing

Skia has an atlas clipping mode (historically called CCPR clipping) that
doesn't quite work. It will fail on blend modes that require a dst read
and is also drawing the complexclip_* tests wrong on several devices.
We plan to rewrite the clip atlas, but in the meantime we need to
disable the "CCPR" clipping.

Bug: b/188794626
Change-Id: I126030a2a81057ffca85fd8b8e7db97b716451ab
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408557
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index 624e31a..d840e38 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -35,7 +35,7 @@
         fChain.push_back(sk_make_sp<GrAAConvexPathRenderer>());
     }
     if (options.fGpuPathRenderers & GpuPathRenderers::kCoverageCounting) {
-        fCoverageCountingPathRenderer = GrCoverageCountingPathRenderer::CreateIfSupported(caps);
+        fCoverageCountingPathRenderer = GrCoverageCountingPathRenderer::CreateIfSupported(context);
         if (fCoverageCountingPathRenderer) {
             // Don't add to the chain. This is only for clips.
             // TODO: Remove from here.
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index e89eea7..b4326dd 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -14,7 +14,12 @@
 #include "src/gpu/GrSurfaceDrawContext.h"
 #include "src/gpu/ccpr/GrCCClipProcessor.h"
 
-bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) {
+bool GrCoverageCountingPathRenderer::IsSupported(const GrRecordingContext* ctx) {
+    if (ctx->backend() != GrBackendApi::kMock) {
+        // The atlas isn't ready for primetime. Disable it everywhere except for testing.
+        return false;
+    }
+    const GrCaps& caps = *ctx->priv().caps();
     const GrShaderCaps& shaderCaps = *caps.shaderCaps();
     GrBackendFormat defaultA8Format = caps.getDefaultBackendFormat(GrColorType::kAlpha_8,
                                                                    GrRenderable::kYes);
@@ -35,8 +40,8 @@
 }
 
 std::unique_ptr<GrCoverageCountingPathRenderer> GrCoverageCountingPathRenderer::CreateIfSupported(
-        const GrCaps& caps) {
-    if (IsSupported(caps)) {
+        const GrRecordingContext* ctx) {
+    if (IsSupported(ctx)) {
         return std::make_unique<GrCoverageCountingPathRenderer>();
     }
     return nullptr;
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index 19ca80f..b39f3d9 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -24,9 +24,10 @@
  */
 class GrCoverageCountingPathRenderer : public GrOnFlushCallbackObject {
 public:
-    static bool IsSupported(const GrCaps&);
+    static bool IsSupported(const GrRecordingContext*);
 
-    static std::unique_ptr<GrCoverageCountingPathRenderer> CreateIfSupported(const GrCaps&);
+    static std::unique_ptr<GrCoverageCountingPathRenderer> CreateIfSupported(
+            const GrRecordingContext*);
 
     using PendingPathsMap = std::map<uint32_t, sk_sp<GrCCPerOpsTaskPaths>>;
 
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp
index 5e080fc..f7d240f 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp
@@ -8,12 +8,12 @@
 #include <memory>
 #include "src/gpu/ccpr/GrCoverageCountingPathRenderer.h"
 
-bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) {
+bool GrCoverageCountingPathRenderer::IsSupported(const GrRecordingContext*) {
     return false;
 }
 
 std::unique_ptr<GrCoverageCountingPathRenderer> GrCoverageCountingPathRenderer::CreateIfSupported(
-        const GrCaps&) {
+        const GrRecordingContext*) {
     return nullptr;
 }
 
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 82a005e..e4eba39 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1938,7 +1938,7 @@
                             }
                         }
                         if (1 == fWindow->sampleCount()) {
-                            if (GrCoverageCountingPathRenderer::IsSupported(*caps)) {
+                            if (GrCoverageCountingPathRenderer::IsSupported(ctx)) {
                                 prButton(GpuPathRenderers::kCoverageCounting);
                             }
                             prButton(GpuPathRenderers::kSmall);
@@ -2772,7 +2772,7 @@
                     }
                 }
                 if (1 == fWindow->sampleCount()) {
-                    if(GrCoverageCountingPathRenderer::IsSupported(*caps)) {
+                    if(GrCoverageCountingPathRenderer::IsSupported(ctx)) {
                         writer.appendString(
                             gPathRendererNames[GpuPathRenderers::kCoverageCounting].c_str());
                     }