stroke-and-fill is deprecated, introduce simpler api

baby step for https://skia-review.googlesource.com/c/skia/+/158020/

Bug: skia:8428
Change-Id: I0411c52a4fb97755e1b06b2aba8cb969776309bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290717
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index 77d0db7..eeed7d6 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -38,7 +38,7 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
         paint.setStrokeWidth(15);
 
         const SkScalar inset = paint.getStrokeWidth() + 4;
@@ -82,7 +82,7 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         SkPaint measPaint;
         measPaint.setAntiAlias(true);
@@ -129,7 +129,7 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
         paint.setStrokeWidth(SK_Scalar1 / 2);
 
         const SkScalar delta = paint.getStrokeWidth() * 3 / 2;
@@ -179,7 +179,7 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
         paint.setStrokeWidth(SK_Scalar1 / 2);
 
         const SkScalar strokeWidth = paint.getStrokeWidth();
@@ -188,7 +188,7 @@
         SkRandom rand;
 
         // Reset style to fill. We only need stroke stype for producing delta and strokeWidth
-        paint.setStyle(SkPaint::kFill_Style);
+        paint.setStroke(false);
 
         SkScalar sign = 1;
         while (r.width() > strokeWidth * 2) {
@@ -229,7 +229,7 @@
 DEF_SIMPLE_GM(manyarcs, canvas, 620, 330) {
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         canvas->translate(10, 10);
 
@@ -274,7 +274,7 @@
 DEF_SIMPLE_GM(tinyanglearcs, canvas, 620, 330) {
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         canvas->translate(50, 50);
 
diff --git a/gm/circles.cpp b/gm/circles.cpp
index 52d54d2..bec7d6b 100644
--- a/gm/circles.cpp
+++ b/gm/circles.cpp
@@ -97,7 +97,7 @@
         // AA with stroke style
         SkPaint p;
         p.setAntiAlias(true);
-        p.setStyle(SkPaint::kStroke_Style);
+        p.setStroke(true);
         p.setStrokeWidth(SkIntToScalar(3));
         fPaints.push_back(p);
         }
@@ -106,7 +106,7 @@
         // AA with stroke style, width = 0
         SkPaint p;
         p.setAntiAlias(true);
-        p.setStyle(SkPaint::kStroke_Style);
+        p.setStroke(true);
         fPaints.push_back(p);
         }
 
diff --git a/gm/circulararcs.cpp b/gm/circulararcs.cpp
index fbe3fe8..262519f 100644
--- a/gm/circulararcs.cpp
+++ b/gm/circulararcs.cpp
@@ -77,13 +77,13 @@
 #define DEF_ARC_GM(name) DEF_SIMPLE_GM(circular_arcs_##name, canvas, kW, kH)
 
 DEF_ARC_GM(fill) {
-    auto setFill = [] (SkPaint*p) { p->setStyle(SkPaint::kFill_Style); };
+    auto setFill = [] (SkPaint*p) { p->setStroke(false); };
     draw_arcs(canvas, setFill);
 }
 
 DEF_ARC_GM(hairline) {
     auto setHairline = [] (SkPaint* p) {
-        p->setStyle(SkPaint::kStroke_Style);
+        p->setStroke(true);
         p->setStrokeWidth(0.f);
     };
     draw_arcs(canvas, setHairline);
@@ -91,7 +91,7 @@
 
 DEF_ARC_GM(stroke_butt) {
     auto setStroke = [](SkPaint* p) {
-        p->setStyle(SkPaint::kStroke_Style);
+        p->setStroke(true);
         p->setStrokeCap(SkPaint::kButt_Cap);
     };
     draw_arcs(canvas, setStroke);
@@ -99,7 +99,7 @@
 
 DEF_ARC_GM(stroke_square) {
     auto setStroke = [] (SkPaint* p) {
-        p->setStyle(SkPaint::kStroke_Style);
+        p->setStroke(true);
         p->setStrokeCap(SkPaint::kSquare_Cap);
     };
     draw_arcs(canvas, setStroke);
@@ -107,7 +107,7 @@
 
 DEF_ARC_GM(stroke_round) {
     auto setStroke = [] (SkPaint* p) {
-        p->setStyle(SkPaint::kStroke_Style);
+        p->setStroke(true);
         p->setStrokeCap(SkPaint::kRound_Cap);
     };
     draw_arcs(canvas, setStroke);
@@ -174,16 +174,16 @@
     // fill
     paints.push_back();
     // stroke
-    paints.push_back().setStyle(SkPaint::kStroke_Style);
+    paints.push_back().setStroke(true);
     paints.back().setStrokeWidth(kS / 6.f);
     // hairline
-    paints.push_back().setStyle(SkPaint::kStroke_Style);
+    paints.push_back().setStroke(true);
     paints.back().setStrokeWidth(0.f);
     // stroke and fill
     paints.push_back().setStyle(SkPaint::kStrokeAndFill_Style);
     paints.back().setStrokeWidth(kS / 6.f);
     // dash effect
-    paints.push_back().setStyle(SkPaint::kStroke_Style);
+    paints.push_back().setStroke(true);
     paints.back().setStrokeWidth(kS / 6.f);
     constexpr SkScalar kDashIntervals[] = {kS / 15, 2 * kS / 15};
     paints.back().setPathEffect(SkDashPathEffect::Make(kDashIntervals, 2, 0.f));
@@ -235,7 +235,7 @@
     SkPaint p0;
     p0.setColor(SK_ColorRED);
     p0.setStrokeWidth(15.f);
-    p0.setStyle(SkPaint::kStroke_Style);
+    p0.setStroke(true);
     p0.setAlpha(100);
     canvas->translate(20, 0);
     canvas->drawPath(path, p0);
@@ -251,7 +251,7 @@
     SkPaint fill;
     fill.setAntiAlias(true);
     SkPaint hairline = fill;
-    hairline.setStyle(SkPaint::kStroke_Style);
+    hairline.setStroke(true);
     SkPaint stroke = hairline;
     stroke.setStrokeWidth(2.0f);
     int x = 4;
@@ -323,7 +323,7 @@
             SkPaint paint;
             paint.setStrokeCap(cap);
             paint.setAntiAlias(true);
-            paint.setStyle(SkPaint::kStroke_Style);
+            paint.setStroke(true);
             paint.setStrokeWidth(kStrokeWidth);
             canvas->save();
                 canvas->translate(x * (2*kRadius + kPad), y * (2*kRadius + kPad));
diff --git a/gm/conicpaths.cpp b/gm/conicpaths.cpp
index 1ba8b44..1375726 100644
--- a/gm/conicpaths.cpp
+++ b/gm/conicpaths.cpp
@@ -112,7 +112,7 @@
                 for (int aa = 0; aa < 2; ++aa) {
                     paint.setAntiAlias(SkToBool(aa));
                     for (int fh = 0; fh < 2; ++fh) {
-                        paint.setStyle(fh ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
+                        paint.setStroke(fh != 0);
 
                         const SkRect& bounds = fPaths[p].getBounds();
                         canvas->save();
@@ -148,7 +148,7 @@
     SkScalar radius = 1096.702150363923f;
     SkPaint paint;
     paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     canvas->drawCircle(c, radius, paint);
     SkPath path;
     path.moveTo(288.88884710654133f, -280.26680862609f);
@@ -164,7 +164,7 @@
     SkScalar radius = 1096.702150363923f;
     SkPaint paint;
     paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     canvas->drawCircle(c, radius, paint);
 }
 
@@ -174,7 +174,7 @@
     SkRect r = SkRect::MakeXYWH(-520, -520, 5000, 4000);
     SkPaint paint;
     paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     paint.setStrokeWidth(100);
     canvas->drawOval(r, paint);
     r.offset(-15, -15);
@@ -188,7 +188,7 @@
     canvas->rotate(1.0f);
     r.offset(55, 55);
     paint.setColor(SK_ColorGRAY);
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     paint.setStrokeWidth(100);
     canvas->drawOval(r, paint);
     r.offset(-15, -15);
diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp
index c6d0304..bbfddeb 100644
--- a/gm/dashcircle.cpp
+++ b/gm/dashcircle.cpp
@@ -50,7 +50,7 @@
         SkPaint refPaint;
         refPaint.setAntiAlias(true);
         refPaint.setColor(0xFFbf3f7f);
-        refPaint.setStyle(SkPaint::kStroke_Style);
+        refPaint.setStroke(true);
         refPaint.setStrokeWidth(1);
         const SkScalar radius = 125;
         SkRect oval = SkRect::MakeLTRB(-radius - 20, -radius - 20, radius + 20, radius + 20);
@@ -85,7 +85,7 @@
                 canvas->restore();
                 SkPaint p;
                 p.setAntiAlias(true);
-                p.setStyle(SkPaint::kStroke_Style);
+                p.setStroke(true);
                 p.setStrokeWidth(10);
                 SkScalar intervals[4];
                 int intervalCount = dashExample.length;
@@ -188,7 +188,7 @@
         SkPaint paint;
         paint.setAntiAlias(true);
         paint.setStrokeWidth(kStrokeWidth);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         // Compute the union of bounds of all of our test cases.
         SkRect bounds = SkRect::MakeEmpty();
@@ -242,7 +242,7 @@
     SkPaint p;
     p.setColor(SK_ColorRED);
     p.setAntiAlias(true);
-    p.setStyle(SkPaint::kStroke_Style);
+    p.setStroke(true);
     p.setStrokeWidth(380);
 
     SkScalar intvls[] = { 2.5, 10 /* 1200 */ };
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index 2d2157f..03bfe90 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -31,7 +31,7 @@
                    SkPaint::Join join) {
     SkPaint paint;
     paint.setAntiAlias(true);
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     paint.setStrokeJoin(join);
     paint.setStrokeWidth(42);
     canvas->drawPath(path, paint);
@@ -119,7 +119,7 @@
 
         SkPaint hairlinePaint;
         hairlinePaint.setAntiAlias(true);
-        hairlinePaint.setStyle(SkPaint::kStroke_Style);
+        hairlinePaint.setStroke(true);
         hairlinePaint.setStrokeCap(SkPaint::kRound_Cap);
         hairlinePaint.setStrokeWidth(2);
         SkPaint normalPaint = hairlinePaint;
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index a8a3e03..578572c 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -54,7 +54,7 @@
     SkPaint paint;
 
     drawline(canvas, 2, 2, paint, SkIntToScalar(0));
-    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setStroke(true);
     paint.setStrokeWidth(SkIntToScalar(2));
     canvas->translate(0, SkIntToScalar(20));
     drawline(canvas, 4, 4, paint, SkIntToScalar(0));
@@ -72,7 +72,7 @@
         };
 
         SkPaint paint;
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
         canvas->translate(0, SK_ScalarHalf);
@@ -156,7 +156,7 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
         paint.setStrokeWidth(SkIntToScalar(6));
 
         SkRect bounds = SkRect::MakeWH(SkIntToScalar(120), SkIntToScalar(120));
@@ -204,7 +204,7 @@
                          bool circles) {
         SkPaint p;
         p.setColor(SK_ColorBLACK);
-        p.setStyle(SkPaint::kStroke_Style);
+        p.setStroke(true);
         p.setStrokeWidth(SkIntToScalar(strokeWidth));
 
         if (circles) {
@@ -324,7 +324,7 @@
         };
 
         SkPaint paint;
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
         canvas->translate(SK_ScalarHalf, SK_ScalarHalf);
@@ -430,7 +430,7 @@
         };
 
         SkPaint paint;
-        paint.setStyle(SkPaint::kStroke_Style);
+        paint.setStroke(true);
 
         paint.setAntiAlias(fDoAA);
 
@@ -489,7 +489,7 @@
     }
     SkPaint p;
     p.setAntiAlias(true);
-    p.setStyle(SkPaint::kStroke_Style);
+    p.setStroke(true);
     p.setStrokeWidth(1);
     const SkScalar intervals[] = { 1, 1 };
     p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
@@ -501,7 +501,7 @@
 DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) {
     SkPaint p;
     p.setAntiAlias(true);
-    p.setStyle(SkPaint::kStroke_Style);
+    p.setStroke(true);
     p.setStrokeWidth(80);
 
     const SkScalar intervals[] = { 2, 2 };
@@ -512,7 +512,7 @@
 DEF_SIMPLE_GM(longwavyline, canvas, 512, 512) {
     SkPaint p;
     p.setAntiAlias(true);
-    p.setStyle(SkPaint::kStroke_Style);
+    p.setStroke(true);
     p.setStrokeWidth(2);
 
     SkPath wavy;
@@ -527,7 +527,7 @@
 DEF_SIMPLE_GM(dashtextcaps, canvas, 512, 512) {
     SkPaint p;
     p.setAntiAlias(true);
-    p.setStyle(SkPaint::kStroke_Style);
+    p.setStroke(true);
     p.setStrokeWidth(10);
     p.setStrokeCap(SkPaint::kRound_Cap);
     p.setStrokeJoin(SkPaint::kRound_Join);
@@ -546,7 +546,7 @@
     SkPaint dashPaint;
     dashPaint.setPathEffect(SkDashPathEffect::Make(kIntervals, SK_ARRAY_COUNT(kIntervals), 0.f));
     SkASSERT(dashPaint.getPathEffect());
-    dashPaint.setStyle(SkPaint::kStroke_Style);
+    dashPaint.setStroke(true);
     dashPaint.setStrokeWidth(20.f);
     static constexpr struct {
         SkPoint fA, fB;
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index cdbc650..cd2b637 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -235,6 +235,11 @@
     */
     void setStyle(Style style);
 
+    /**
+     *  Set paint's style to kStroke if true, or kFill if false.
+     */
+    void setStroke(bool);
+
     /** Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
         Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract
         a color component.
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index f294dbe..11661b7 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -109,6 +109,10 @@
     }
 }
 
+void SkPaint::setStroke(bool isStroke) {
+    fBitfields.fStyle = isStroke ? kStroke_Style : kFill_Style;
+}
+
 void SkPaint::setColor(SkColor color) {
     fColor4f = SkColor4f::FromColor(color);
 }