[viewer] Context option and UI toggle for compute MSAAx16

It's now possible to trigger the MSAAx16 mode using the path renderer
strategy toggles in viewer. The PathAtlas continues to select analytic
area AA unless MSAA16 is selected via ContextOptions.

Bug: b/285420658
Change-Id: I6f5c647ff3cb33d8ca36aa6ef363f7f883e614d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/801377
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/include/private/gpu/graphite/ContextOptionsPriv.h b/include/private/gpu/graphite/ContextOptionsPriv.h
index e79f494..08af61a 100644
--- a/include/private/gpu/graphite/ContextOptionsPriv.h
+++ b/include/private/gpu/graphite/ContextOptionsPriv.h
@@ -27,6 +27,12 @@
     kComputeAnalyticAA,
 
     /**
+     * All paths are rasterized into coverage masks using a GPU compute approach. This method
+     * always uses 16sample multi-sampled anti-aliasing.
+     */
+    kComputeMSAA16,
+
+    /**
      * All paths are rasterized into coverage masks using the CPU raster backend.
      */
     kRasterAA,
diff --git a/src/gpu/graphite/Context.cpp b/src/gpu/graphite/Context.cpp
index 9bf39a2..e1f897b 100644
--- a/src/gpu/graphite/Context.cpp
+++ b/src/gpu/graphite/Context.cpp
@@ -893,6 +893,7 @@
         case PathRendererStrategy::kDefault:
             return true;
         case PathRendererStrategy::kComputeAnalyticAA:
+        case PathRendererStrategy::kComputeMSAA16:
             return SkToBool(pathAtlasFlags & AtlasProvider::PathAtlasFlags::kCompute);
         case PathRendererStrategy::kRasterAA:
             return SkToBool(pathAtlasFlags & AtlasProvider::PathAtlasFlags::kRaster);
diff --git a/src/gpu/graphite/Device.cpp b/src/gpu/graphite/Device.cpp
index 8a3a87f..6fd128d2 100644
--- a/src/gpu/graphite/Device.cpp
+++ b/src/gpu/graphite/Device.cpp
@@ -1366,6 +1366,7 @@
     AtlasProvider* atlasProvider = fRecorder->priv().atlasProvider();
     if (atlasProvider->isAvailable(AtlasProvider::PathAtlasFlags::kCompute) &&
         (strategy == PathRendererStrategy::kComputeAnalyticAA ||
+         strategy == PathRendererStrategy::kComputeMSAA16 ||
          strategy == PathRendererStrategy::kDefault)) {
         pathAtlas = fDC->getComputePathAtlas(fRecorder);
     // Only use CPU rendered paths when multisampling is disabled
diff --git a/src/gpu/graphite/PathAtlas.cpp b/src/gpu/graphite/PathAtlas.cpp
index 84d9000..c2600c0 100644
--- a/src/gpu/graphite/PathAtlas.cpp
+++ b/src/gpu/graphite/PathAtlas.cpp
@@ -183,8 +183,16 @@
     }
 
     SkASSERT(recorder);
+    // Unless the analytic area AA mode unless caps say otherwise.
+    VelloAaConfig config = VelloAaConfig::kAnalyticArea;
+#if defined(GRAPHITE_TEST_UTILS)
+    PathRendererStrategy strategy = recorder->priv().caps()->requestedPathRendererStrategy();
+    if (strategy == PathRendererStrategy::kComputeMSAA16) {
+        config = VelloAaConfig::kMSAA16;
+    }
+#endif
     return recorder->priv().rendererProvider()->velloRenderer()->renderScene(
-            {fOccuppiedWidth, fOccuppiedHeight, SkColors::kBlack, VelloAaConfig::kAnalyticArea},
+            {fOccuppiedWidth, fOccuppiedHeight, SkColors::kBlack, config},
             fScene,
             sk_ref_sp(this->texture()),
             recorder);
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 0152215..be7c99e 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -302,6 +302,8 @@
             return "Default";
         case Strategy::kComputeAnalyticAA:
             return "GPU Compute AA (Analytic)";
+        case Strategy::kComputeMSAA16:
+            return "GPU Compute AA (16xMSAA)";
         case Strategy::kRasterAA:
             return "CPU Raster AA";
         case Strategy::kTessellation:
@@ -2227,6 +2229,7 @@
 
                         PathRendererStrategy strategies[] = {
                                 PathRendererStrategy::kComputeAnalyticAA,
+                                PathRendererStrategy::kComputeMSAA16,
                                 PathRendererStrategy::kRasterAA,
                                 PathRendererStrategy::kTessellation,
                         };