Tune up tessellated stroke gms

* Make sure to actually use hardware tessellation on the *_tess_segs_5
  gms. These had started using the fixed count tessellator.

* Add a trickycubicstrokes version with round caps to test upcoming
  coverage AA modes.

* Make the colors more appealing since I spend all day looking at
  these gms.

Bug: skia:10419
Change-Id: Ie7ab4e936ffa3ccffe4999e51fac4c3d4ab97f06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406976
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/gm/trickycubicstrokes.cpp b/gm/trickycubicstrokes.cpp
index 5a2cd55..3017fb3 100644
--- a/gm/trickycubicstrokes.cpp
+++ b/gm/trickycubicstrokes.cpp
@@ -99,14 +99,25 @@
     kScale
 };
 
-static void draw_test(SkCanvas* canvas, const SkColor strokeColor) {
+static void draw_test(SkCanvas* canvas, SkPaint::Cap cap, SkPaint::Join join) {
+    SkRandom rand;
+
+    if (canvas->recordingContext() &&
+        canvas->recordingContext()->priv().caps()->shaderCaps()->tessellationSupport() &&
+        canvas->recordingContext()->priv().caps()->shaderCaps()->maxTessellationSegments() < 64) {
+        // There are fewer tessellation segments than the spec minimum. It must have been overriden
+        // for testing. Indicate this in the background color.
+        canvas->clear(SkColorSetARGB(255, 64, 0, 0));
+    } else {
+        canvas->clear(SK_ColorBLACK);
+    }
+
     SkPaint strokePaint;
     strokePaint.setAntiAlias(true);
     strokePaint.setStrokeWidth(kStrokeWidth);
-    strokePaint.setColor(strokeColor);
     strokePaint.setStyle(SkPaint::kStroke_Style);
-
-    canvas->clear(SK_ColorBLACK);
+    strokePaint.setStrokeCap(cap);
+    strokePaint.setStrokeJoin(join);
 
     for (size_t i = 0; i < SK_ARRAY_COUNT(kTrickyCubics); ++i) {
         auto [originalPts, numPts, fillMode, scale] = kTrickyCubics[i];
@@ -145,6 +156,7 @@
         SkAutoCanvasRestore acr(canvas, true);
         canvas->concat(matrix);
         strokePaint.setStrokeWidth(kStrokeWidth / matrix.getMaxScale());
+        strokePaint.setColor(rand.nextU() | 0xff808080);
         SkPath path = SkPath().moveTo(p[0]);
         if (numPts == 4) {
             path.cubicTo(p[1], p[2], p[3]);
@@ -160,7 +172,11 @@
 }
 
 DEF_SIMPLE_GM(trickycubicstrokes, canvas, kTestWidth, kTestHeight) {
-    draw_test(canvas, SK_ColorGREEN);
+    draw_test(canvas, SkPaint::kButt_Cap, SkPaint::kMiter_Join);
+}
+
+DEF_SIMPLE_GM(trickycubicstrokes_roundcaps, canvas, kTestWidth, kTestHeight) {
+    draw_test(canvas, SkPaint::kRound_Cap, SkPaint::kRound_Join);
 }
 
 class TrickyCubicStrokes_tess_segs_5 : public skiagm::GpuGM {
@@ -208,7 +224,7 @@
         }
         // Suppress a tessellator warning message that caps.maxTessellationSegments is too small.
         GrRecordingContextPriv::AutoSuppressWarningMessages aswm(context);
-        draw_test(canvas, SK_ColorRED);
+        draw_test(canvas, SkPaint::kButt_Cap, SkPaint::kMiter_Join);
         return DrawResult::kOk;
     }
 };