Starting to hide setFilterQuality

Bug: skia:7650
Change-Id: I511859e9b34af21d351db87b658dad970f0802a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345171
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index 4cd4862..f6bf6aa 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -26,6 +26,7 @@
 #include "include/svg/SkSVGCanvas.h"
 #include "include/utils/SkNullCanvas.h"
 #include "src/core/SkOSFile.h"
+#include "src/core/SkPaintPriv.h"
 #include "src/core/SkPicturePriv.h"
 #include "tools/debugger/DebugCanvas.h"
 
@@ -856,7 +857,7 @@
     paint->setDither(       make_fuzz_t<bool>(fuzz));
     paint->setColor(        make_fuzz_t<SkColor>(fuzz));
     paint->setBlendMode(    make_fuzz_enum_range<SkBlendMode>(fuzz, SkBlendMode::kLastMode));
-    paint->setFilterQuality(make_fuzz_enum_range<SkFilterQuality>(fuzz, kLast_SkFilterQuality));
+    SkPaintPriv::SetFQ(paint, make_fuzz_enum_range<SkFilterQuality>(fuzz, kLast_SkFilterQuality));
     paint->setStyle(        make_fuzz_enum_range<SkPaint::Style>(fuzz,
                                                  SkPaint::Style::kStrokeAndFill_Style));
     paint->setShader(       make_fuzz_shader(fuzz, depth - 1));
diff --git a/fuzz/FuzzDrawFunctions.cpp b/fuzz/FuzzDrawFunctions.cpp
index 9a4d428..fb1d89c 100644
--- a/fuzz/FuzzDrawFunctions.cpp
+++ b/fuzz/FuzzDrawFunctions.cpp
@@ -15,6 +15,7 @@
 #include "include/core/SkTextBlob.h"
 #include "include/core/SkTypeface.h"
 #include "src/core/SkClipOpPriv.h"
+#include "src/core/SkPaintPriv.h"
 
 static const int kBmpSize = 24;
 static const int kMaxX = 250;
@@ -47,7 +48,7 @@
     p->setDither(b);
 
     fuzz->nextRange(&tmp_u8, 0, (int)kHigh_SkFilterQuality);
-    p->setFilterQuality(static_cast<SkFilterQuality>(tmp_u8));
+    SkPaintPriv::SetFQ(p, static_cast<SkFilterQuality>(tmp_u8));
 
     fuzz->nextRange(&tmp_u8, 0, (int)SkPaint::kLast_Cap);
     p->setStrokeCap(static_cast<SkPaint::Cap>(tmp_u8));
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index bfcf587..9cbb766 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -23,6 +23,9 @@
 class SkPathEffect;
 class SkShader;
 
+// WIP to eventually remove filter-quality
+#define SK_SUPPORT_LEGACY_SETFILTERQUALITY
+
 /** \class SkPaint
     SkPaint controls options applied when drawing. SkPaint collects all
     options outside of the SkCanvas clip and SkCanvas matrix.
@@ -196,6 +199,9 @@
         return (SkFilterQuality)fBitfields.fFilterQuality;
     }
 
+#ifndef SK_SUPPORT_LEGACY_SETFILTERQUALITY
+private:
+#endif
     /** Sets SkFilterQuality, the image filtering level. A lower setting
         draws faster; a higher setting looks better when the image is scaled.
         Does not check to see if quality is valid.
@@ -204,6 +210,9 @@
         example: https://fiddle.skia.org/c/@Paint_setFilterQuality
     */
     void setFilterQuality(SkFilterQuality quality);
+#ifndef SK_SUPPORT_LEGACY_SETFILTERQUALITY
+public:
+#endif
 
     /** \enum SkPaint::Style
         Set Style to fill, stroke, or both fill and stroke geometry.
@@ -709,6 +718,8 @@
         } fBitfields;
         uint32_t fBitfieldsUInt;
     };
+
+    friend class SkPaintPriv;
 };
 
 #endif
diff --git a/modules/particles/src/SkParticleEffect.cpp b/modules/particles/src/SkParticleEffect.cpp
index 471045c..1f9534f 100644
--- a/modules/particles/src/SkParticleEffect.cpp
+++ b/modules/particles/src/SkParticleEffect.cpp
@@ -13,6 +13,7 @@
 #include "modules/particles/include/SkParticleDrawable.h"
 #include "modules/particles/include/SkReflected.h"
 #include "modules/skresources/include/SkResources.h"
+#include "src/core/SkPaintPriv.h"
 #include "src/sksl/SkSLByteCode.h"
 #include "src/sksl/SkSLCompiler.h"
 #include "src/sksl/SkSLUtil.h"
@@ -462,7 +463,7 @@
 void SkParticleEffect::draw(SkCanvas* canvas) {
     if (this->isAlive(false) && fParams->fDrawable) {
         SkPaint paint;
-        paint.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
+        SkPaintPriv::SetFQ(&paint, SkFilterQuality::kMedium_SkFilterQuality);
         fParams->fDrawable->draw(canvas, fParticles, fCount, paint);
     }
 
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index 3bd475e..f9bd925 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -63,17 +63,17 @@
 
         SkPaint paint;
         paint.setAntiAlias(true);
-        paint.setFilterQuality(kMedium_SkFilterQuality);
 
         canvas->save();
 
 #if SK_SUPPORT_GPU
         auto direct = GrAsDirectContext(canvas->recordingContext());
         if (direct) {
+            SkSamplingOptions sampling(SkFilterMode::kLinear, SkMipmapMode::kNearest);
             sk_sp<SkImage> image = direct->priv().testingOnly_getFontAtlasImage(
                                                                 GrMaskFormat::kA8_GrMaskFormat);
-            canvas->drawImageRect(image,
-                                  SkRect::MakeXYWH(512.0f, 10.0f, 512.0f, 512.0f), &paint);
+            const SkRect rect = SkRect::MakeXYWH(512.0f, 10.0f, 512.0f, 512.0f);
+            canvas->drawImageRect(image.get(), rect, rect, sampling, &paint);
         }
 #endif
         canvas->translate(180, 180);
diff --git a/samplecode/SampleAtlas.cpp b/samplecode/SampleAtlas.cpp
index d34c52f4..add15bf 100644
--- a/samplecode/SampleAtlas.cpp
+++ b/samplecode/SampleAtlas.cpp
@@ -13,6 +13,7 @@
 #include "include/utils/SkRandom.h"
 #include "include/utils/SkTextUtils.h"
 #include "samplecode/Sample.h"
+#include "src/core/SkPaintPriv.h"
 
 typedef void (*DrawAtlasProc)(SkCanvas*, SkImage*, const SkRSXform[], const SkRect[],
                               const SkColor[], int, const SkRect*, const SkPaint*);
@@ -183,7 +184,8 @@
             }
         }
         SkPaint paint;
-        paint.setFilterQuality(kLow_SkFilterQuality);
+        // TODO: add sampling options to drawAtlas
+        SkPaintPriv::SetFQ(&paint, kLow_SkFilterQuality);
 
         const SkRect cull = this->getBounds();
         const SkColor* colorsPtr = fUseColors ? colors : nullptr;
diff --git a/samplecode/SampleCamera.cpp b/samplecode/SampleCamera.cpp
index d150a63..c9bb1c9 100644
--- a/samplecode/SampleCamera.cpp
+++ b/samplecode/SampleCamera.cpp
@@ -6,6 +6,7 @@
  */
 
 #include "include/core/SkCanvas.h"
+#include "include/core/SkImage.h"
 #include "include/core/SkShader.h"
 #include "include/core/SkString.h"
 #include "include/utils/SkCamera.h"
diff --git a/samplecode/SampleFlutterAnimate.cpp b/samplecode/SampleFlutterAnimate.cpp
index 514d7f6..c823722 100644
--- a/samplecode/SampleFlutterAnimate.cpp
+++ b/samplecode/SampleFlutterAnimate.cpp
@@ -33,7 +33,6 @@
     void onDrawContent(SkCanvas* canvas) override {
         SkFont font(fTypeface, 50);
         SkPaint paint;
-        paint.setFilterQuality(kMedium_SkFilterQuality);
 
         // rough center of each glyph
         static constexpr auto kMidX = 35;
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 62f1b3a..4efc5e0 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -252,7 +252,9 @@
     packed >>= 2;
     paint->setStyle(safe.checkLE(packed & 0x3, SkPaint::kStrokeAndFill_Style));
     packed >>= 2;
+#ifdef SK_SUPPORT_LEGACY_SETFILTERQUALITY
     paint->setFilterQuality(safe.checkLE(packed & 0x3, kLast_SkFilterQuality));
+#endif
     packed >>= 2;
     return packed;
 }
diff --git a/src/core/SkPaintPriv.h b/src/core/SkPaintPriv.h
index 443e29a..a06540d 100644
--- a/src/core/SkPaintPriv.h
+++ b/src/core/SkPaintPriv.h
@@ -73,6 +73,9 @@
     // Since we may be filtering now, we need to know what color space to filter in,
     // typically the color space of the device we're drawing into.
     static void RemoveColorFilter(SkPaint*, SkColorSpace* dstCS);
+
+    static SkFilterQuality GetFQ(const SkPaint& paint) { return paint.getFilterQuality(); }
+    static void SetFQ(SkPaint* paint, SkFilterQuality fq) { paint->setFilterQuality(fq); }
 };
 
 #endif