Ensure default SkPaints w/ dither don't get dithered

Skipping dithering of const paints was originally added in:

https://skia-review.googlesource.com/c/skia/+/19880/

Change-Id: Icebca1c3ef779bb103030deac12621619f5ce248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437116
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp
index e6d4f94..3767411 100644
--- a/src/core/SkPaintPriv.cpp
+++ b/src/core/SkPaintPriv.cpp
@@ -61,8 +61,8 @@
     }
 
     // Otherwise, dither is only needed for non-const paints.
-    return p.getImageFilter() || p.getMaskFilter()
-        || !p.getShader() || !as_SB(p.getShader())->isConstant();
+    return p.getImageFilter() || p.getMaskFilter() ||
+           (p.getShader() && !as_SB(p.getShader())->isConstant());
 }
 
 // return true if the paint is just a single color (i.e. not a shader). If its
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index 2db0ed6..f221003 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -230,3 +230,12 @@
         }
     }
 }
+
+DEF_TEST(Paint_dither, reporter) {
+    SkPaint p;
+    p.setDither(true);
+
+    bool shouldDither = SkPaintPriv::ShouldDither(p, kBGRA_8888_SkColorType);
+
+    REPORTER_ASSERT(reporter, !shouldDither);
+}