Remove SkDrawFilter.

Change-Id: I0204a9522e828c87bb7c6c20ae34ce51161442af
Reviewed-on: https://skia-review.googlesource.com/137895
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h
index e2cedaa..5c4af03 100644
--- a/src/core/SkBitmapDevice.h
+++ b/src/core/SkBitmapDevice.h
@@ -74,8 +74,7 @@
 
     /** These are called inside the per-device-layer loop for each draw call.
      When these are called, we have already applied any saveLayer operations,
-     and are handling any looping from the paint, and any effects from the
-     DrawFilter.
+     and are handling any looping from the paint.
      */
     void drawPaint(const SkPaint& paint) override;
     void drawPoints(SkCanvas::PointMode mode, size_t count,
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 5b2a2cf..afdb4f9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -14,7 +14,6 @@
 #include "SkClipStack.h"
 #include "SkColorFilter.h"
 #include "SkDraw.h"
-#include "SkDrawFilter.h"
 #include "SkDrawLooper.h"
 #include "SkDrawable.h"
 #include "SkGlyphCache.h"
@@ -219,7 +218,6 @@
 */
 class SkCanvas::MCRec {
 public:
-    SkDrawFilter*   fFilter;    // the current filter (or null)
     DeviceCM*       fLayer;
     /*  If there are any layers in the stack, this points to the top-most
         one that is at or below this level in the stack (so we know what
@@ -233,7 +231,6 @@
     int                 fDeferredSaveCount;
 
     MCRec() {
-        fFilter     = nullptr;
         fLayer      = nullptr;
         fTopLayer   = nullptr;
         fMatrix.reset();
@@ -243,7 +240,6 @@
         inc_rec();
     }
     MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatrix) {
-        fFilter = SkSafeRef(prev.fFilter);
         fLayer = nullptr;
         fTopLayer = prev.fTopLayer;
         fDeferredSaveCount = 0;
@@ -252,7 +248,6 @@
         inc_rec();
     }
     ~MCRec() {
-        SkSafeUnref(fFilter);
         delete fLayer;
         dec_rec();
     }
@@ -371,11 +366,6 @@
     AutoDrawLooper(SkCanvas* canvas, const SkPaint& paint, bool skipLayerForImageFilter = false,
                    const SkRect* rawBounds = nullptr) : fOrigPaint(paint) {
         fCanvas = canvas;
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-        fFilter = canvas->getDrawFilter();
-#else
-        fFilter = nullptr;
-#endif
         fPaint = &fOrigPaint;
         fSaveCount = canvas->getSaveCount();
         fTempLayerForImageFilter = false;
@@ -425,7 +415,7 @@
         } else {
             fLooperContext = nullptr;
             // can we be marked as simple?
-            fIsSimple = !fFilter && !fTempLayerForImageFilter;
+            fIsSimple = !fTempLayerForImageFilter;
         }
     }
 
@@ -442,14 +432,14 @@
         return *fPaint;
     }
 
-    bool next(SkDrawFilter::Type drawType) {
+    bool next() {
         if (fDone) {
             return false;
         } else if (fIsSimple) {
             fDone = true;
             return !fPaint->nothingToDraw();
         } else {
-            return this->doNext(drawType);
+            return this->doNext();
         }
     }
 
@@ -458,7 +448,6 @@
     SkLazyPaint     fLazyPaintPerLooper;  // per-draw-looper storage, so the looper can modify it
     SkCanvas*       fCanvas;
     const SkPaint&  fOrigPaint;
-    SkDrawFilter*   fFilter;
     const SkPaint*  fPaint;
     int             fSaveCount;
     bool            fTempLayerForImageFilter;
@@ -467,13 +456,13 @@
     SkDrawLooper::Context* fLooperContext;
     SkSTArenaAlloc<48>     fAlloc;
 
-    bool doNext(SkDrawFilter::Type drawType);
+    bool doNext();
 };
 
-bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
+bool AutoDrawLooper::doNext() {
     fPaint = nullptr;
     SkASSERT(!fIsSimple);
-    SkASSERT(fLooperContext || fFilter || fTempLayerForImageFilter);
+    SkASSERT(fLooperContext || fTempLayerForImageFilter);
 
     SkPaint* paint = fLazyPaintPerLooper.set(fLazyPaintInit.isValid() ?
                                              *fLazyPaintInit.get() : fOrigPaint);
@@ -489,20 +478,10 @@
         fDone = true;
         return false;
     }
-    if (fFilter) {
-        if (!fFilter->filter(paint, drawType)) {
-            fDone = true;
-            return false;   // can we really do this, if we haven't finished fLooperContext?
-        }
-        if (nullptr == fLooperContext) {
-            // no looper means we only draw once
-            fDone = true;
-        }
-    }
     fPaint = paint;
 
     // if we only came in here for the imagefilter, mark us as done
-    if (!fLooperContext && !fFilter) {
+    if (!fLooperContext) {
         fDone = true;
     }
     return true;
@@ -513,26 +492,26 @@
 #define LOOPER_BEGIN_DRAWBITMAP(paint, skipLayerForFilter, bounds)  \
     this->predrawNotify();                                          \
     AutoDrawLooper looper(this, paint, skipLayerForFilter, bounds); \
-    while (looper.next(SkDrawFilter::kBitmap_Type)) {               \
+    while (looper.next()) {                                         \
         SkDrawIter iter(this);
 
 
-#define LOOPER_BEGIN_DRAWDEVICE(paint, type)                        \
+#define LOOPER_BEGIN_DRAWDEVICE(paint)                              \
     this->predrawNotify();                                          \
     AutoDrawLooper  looper(this, paint, true);                      \
-    while (looper.next(type)) {                                     \
+    while (looper.next()) {                                         \
         SkDrawIter          iter(this);
 
-#define LOOPER_BEGIN(paint, type, bounds)                           \
+#define LOOPER_BEGIN(paint, bounds)                                 \
     this->predrawNotify();                                          \
     AutoDrawLooper  looper(this, paint, false, bounds);             \
-    while (looper.next(type)) {                                     \
+    while (looper.next()) {                                         \
         SkDrawIter          iter(this);
 
-#define LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, type, bounds, auxOpaque)  \
+#define LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, bounds, auxOpaque)  \
     this->predrawNotify(bounds, &paint, auxOpaque);                 \
     AutoDrawLooper  looper(this, paint, false, bounds);             \
-    while (looper.next(type)) {                                     \
+    while (looper.next()) {                                         \
         SkDrawIter          iter(this);
 
 #define LOOPER_END    }
@@ -692,18 +671,6 @@
     dec_canvas();
 }
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-SkDrawFilter* SkCanvas::getDrawFilter() const {
-    return fMCRec->fFilter;
-}
-
-SkDrawFilter* SkCanvas::setDrawFilter(SkDrawFilter* filter) {
-    this->checkForDeferredSave();
-    SkRefCnt_SafeAssign(fMCRec->fFilter, filter);
-    return filter;
-}
-#endif
-
 SkMetaData& SkCanvas::getMetaData() {
     // metadata users are rare, so we lazily allocate it. If that changes we
     // can decide to just make it a field in the device (rather than a ptr)
@@ -1255,7 +1222,7 @@
         paint = &tmp;
     }
 
-    LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
+    LOOPER_BEGIN_DRAWDEVICE(*paint)
 
     while (iter.next()) {
         SkBaseDevice* dstDev = iter.fDevice;
@@ -1945,7 +1912,7 @@
     SkPaint paint;
     const SkRect& pathBounds = path.getBounds();
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, &pathBounds)
+    LOOPER_BEGIN(paint, &pathBounds)
     while (iter.next()) {
         iter.fDevice->drawShadow(path, rec);
     }
@@ -1967,7 +1934,7 @@
 }
 
 void SkCanvas::internalDrawPaint(const SkPaint& paint) {
-    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, SkDrawFilter::kPaint_Type, nullptr, false)
+    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, nullptr, false)
 
     while (iter.next()) {
         iter.fDevice->drawPaint(looper.paint());
@@ -2003,7 +1970,7 @@
 
     SkASSERT(pts != nullptr);
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kPoint_Type, bounds)
+    LOOPER_BEGIN(paint, bounds)
 
     while (iter.next()) {
         iter.fDevice->drawPoints(mode, count, pts, looper.paint());
@@ -2014,9 +1981,6 @@
 
 static bool needs_autodrawlooper(SkCanvas* canvas, const SkPaint& paint) {
     return ((intptr_t)paint.getImageFilter()    |
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-            (intptr_t)canvas->getDrawFilter()   |
-#endif
             (intptr_t)paint.getLooper()         ) != 0;
 }
 
@@ -2030,7 +1994,7 @@
     }
 
     if (needs_autodrawlooper(this, paint)) {
-        LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, SkDrawFilter::kRect_Type, &r, false)
+        LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(paint, &r, false)
 
         while (iter.next()) {
             iter.fDevice->drawRect(r, looper.paint());
@@ -2055,7 +2019,7 @@
         }
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kRect_Type, &regionRect)
+    LOOPER_BEGIN(paint, &regionRect)
 
     while (iter.next()) {
         iter.fDevice->drawRegion(region, looper.paint());
@@ -2073,7 +2037,7 @@
         }
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kOval_Type, &oval)
+    LOOPER_BEGIN(paint, &oval)
 
     while (iter.next()) {
         iter.fDevice->drawOval(oval, looper.paint());
@@ -2094,7 +2058,7 @@
         }
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kOval_Type, &oval)
+    LOOPER_BEGIN(paint, &oval)
 
     while (iter.next()) {
         iter.fDevice->drawArc(oval, startAngle, sweepAngle, useCenter, looper.paint());
@@ -2121,7 +2085,7 @@
         return;
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kRRect_Type, &rrect.getBounds())
+    LOOPER_BEGIN(paint, &rrect.getBounds())
 
     while (iter.next()) {
         iter.fDevice->drawRRect(rrect, looper.paint());
@@ -2138,7 +2102,7 @@
         }
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kRRect_Type, &outer.getBounds())
+    LOOPER_BEGIN(paint, &outer.getBounds())
 
     while (iter.next()) {
         iter.fDevice->drawDRRect(outer, inner, looper.paint());
@@ -2167,7 +2131,7 @@
         }
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, &pathBounds)
+    LOOPER_BEGIN(paint, &pathBounds)
 
     while (iter.next()) {
         iter.fDevice->drawPath(path, looper.paint());
@@ -2275,8 +2239,7 @@
     }
     paint = &realPaint;
 
-    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &dst,
-                                          image->isOpaque())
+    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, &dst, image->isOpaque())
 
     while (iter.next()) {
         iter.fDevice->drawImageRect(image, src, dst, looper.paint(), constraint);
@@ -2356,8 +2319,7 @@
         paint = lazy.init();
     }
 
-    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, SkDrawFilter::kBitmap_Type, &dst,
-                                          bitmap.isOpaque())
+    LOOPER_BEGIN_CHECK_COMPLETE_OVERWRITE(*paint, &dst, bitmap.isOpaque())
 
     while (iter.next()) {
         iter.fDevice->drawBitmapRect(bitmap, src, dst, looper.paint(), constraint);
@@ -2385,7 +2347,7 @@
     }
     paint = &realPaint;
 
-    LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
+    LOOPER_BEGIN(*paint, &dst)
 
     while (iter.next()) {
         iter.fDevice->drawImageNine(image, center, dst, looper.paint());
@@ -2408,7 +2370,7 @@
     }
     paint = &realPaint;
 
-    LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
+    LOOPER_BEGIN(*paint, &dst)
 
     while (iter.next()) {
         iter.fDevice->drawBitmapNine(bitmap, center, dst, looper.paint());
@@ -2430,7 +2392,7 @@
     }
     paint = &realPaint;
 
-    LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
+    LOOPER_BEGIN(*paint, &dst)
 
     while (iter.next()) {
         iter.fDevice->drawImageLattice(image, lattice, dst, looper.paint());
@@ -2452,7 +2414,7 @@
     }
     paint = &realPaint;
 
-    LOOPER_BEGIN(*paint, SkDrawFilter::kBitmap_Type, &dst)
+    LOOPER_BEGIN(*paint, &dst)
 
     while (iter.next()) {
         iter.fDevice->drawBitmapLattice(bitmap, lattice, dst, looper.paint());
@@ -2464,7 +2426,7 @@
 void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
                           const SkPaint& paint) {
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         fScratchGlyphRunBuilder->prepareDrawText(
@@ -2479,7 +2441,7 @@
 void SkCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
                              const SkPaint& paint) {
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         fScratchGlyphRunBuilder->prepareDrawPosText(looper.paint(), text, byteLength, pos);
@@ -2493,7 +2455,7 @@
 void SkCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
                               SkScalar constY, const SkPaint& paint) {
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         fScratchGlyphRunBuilder->prepareDrawPosTextH(
@@ -2507,7 +2469,7 @@
 
 void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
                                 const SkMatrix* matrix, const SkPaint& paint) {
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         iter.fDevice->drawTextOnPath(text, byteLength, path, matrix, looper.paint());
@@ -2522,7 +2484,7 @@
         return;
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         iter.fDevice->drawTextRSXform(text, byteLength, xform, looper.paint());
@@ -2546,18 +2508,13 @@
 
     // We cannot filter in the looper as we normally do, because the paint is
     // incomplete at this point (text-related attributes are embedded within blob run paints).
-    SkDrawFilter* drawFilter = fMCRec->fFilter;
-    fMCRec->fFilter = nullptr;
-
-    LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, bounds)
+    LOOPER_BEGIN(paint, bounds)
 
     while (iter.next()) {
-        iter.fDevice->drawTextBlob(blob, x, y, looper.paint(), drawFilter);
+        iter.fDevice->drawTextBlob(blob, x, y, looper.paint());
     }
 
     LOOPER_END
-
-    fMCRec->fFilter = drawFilter;
 }
 
 void SkCanvas::drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint) {
@@ -2615,7 +2572,7 @@
 
 void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, const SkMatrix* bones,
                                     int boneCount, SkBlendMode bmode, const SkPaint& paint) {
-    LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         // In the common case of one iteration we could std::move vertices here.
@@ -2647,7 +2604,7 @@
         return;
     }
 
-    LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
 
     while (iter.next()) {
         iter.fDevice->drawPatch(cubics, colors, texCoords, bmode, paint);
@@ -2698,7 +2655,7 @@
         pnt = *paint;
     }
 
-    LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, nullptr)
+    LOOPER_BEGIN(pnt, nullptr)
     while (iter.next()) {
         iter.fDevice->drawAtlas(atlas, xform, tex, colors, count, bmode, pnt);
     }
@@ -2709,7 +2666,7 @@
     SkASSERT(key);
 
     SkPaint paint;
-    LOOPER_BEGIN(paint, SkDrawFilter::kRect_Type, nullptr)
+    LOOPER_BEGIN(paint, nullptr)
     while (iter.next()) {
         iter.fDevice->drawAnnotation(rect, key, value);
     }
diff --git a/src/core/SkColorSpaceXformCanvas.cpp b/src/core/SkColorSpaceXformCanvas.cpp
index caf07fb..949dd4a 100644
--- a/src/core/SkColorSpaceXformCanvas.cpp
+++ b/src/core/SkColorSpaceXformCanvas.cpp
@@ -267,13 +267,6 @@
         return kNoLayer_SaveLayerStrategy;
     }
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-    SkDrawFilter* setDrawFilter(SkDrawFilter* filter) override {
-        SkCanvas::setDrawFilter(filter);
-        return fTarget->setDrawFilter(filter);
-    }
-#endif
-
     // Everything from here on should be uninteresting strictly proxied state-change calls.
     void willSave()    override { fTarget->save(); }
     void willRestore() override { fTarget->restore(); }
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 2b7fef6..b6f5291 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -9,7 +9,6 @@
 
 #include "SkColorFilter.h"
 #include "SkDraw.h"
-#include "SkDrawFilter.h"
 #include "SkGlyphRun.h"
 #include "SkImageFilter.h"
 #include "SkImageFilterCache.h"
@@ -141,7 +140,7 @@
 }
 
 void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
-                                const SkPaint &paint, SkDrawFilter* drawFilter) {
+                                const SkPaint &paint) {
 
     SkPaint runPaint = paint;
 
@@ -153,12 +152,6 @@
         // so it is safe to not re-seed the paint for this reason.
         it.applyFontToPaint(&runPaint);
 
-        if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) {
-            // A false return from filter() means we should abort the current draw.
-            runPaint = paint;
-            continue;
-        }
-
         switch (it.positioning()) {
         case SkTextBlob::kDefault_Positioning: {
             auto origin = SkPoint::Make(x + offset.x(), y + offset.y());
@@ -179,11 +172,6 @@
         default:
             SK_ABORT("unhandled positioning mode");
         }
-
-        if (drawFilter) {
-            // A draw filter may change the paint arbitrarily, so we must re-seed in this case.
-            runPaint = paint;
-        }
     }
 }
 
diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h
index 4959f1f..2173d91 100644
--- a/src/core/SkDevice.h
+++ b/src/core/SkDevice.h
@@ -15,7 +15,6 @@
 #include "SkSurfaceProps.h"
 
 class SkBitmap;
-class SkDrawFilter;
 struct SkDrawShadowRec;
 class SkGlyphRun;
 class SkGlyphRunBuilder;
@@ -155,8 +154,7 @@
 
     /** These are called inside the per-device-layer loop for each draw call.
      When these are called, we have already applied any saveLayer operations,
-     and are handling any looping from the paint, and any effects from the
-     DrawFilter.
+     and are handling any looping from the paint.
      */
     virtual void drawPaint(const SkPaint& paint) = 0;
     virtual void drawPoints(SkCanvas::PointMode mode, size_t count,
@@ -230,8 +228,7 @@
     virtual void drawShadow(const SkPath&, const SkDrawShadowRec&);
 
     // default implementation unrolls the blob runs.
-    virtual void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y,
-                              const SkPaint& paint, SkDrawFilter* drawFilter);
+    virtual void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint& paint);
     // default implementation calls drawVertices
     virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
                            const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint);
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index 4240055..ea3ca6d 100644
--- a/src/core/SkLiteDL.cpp
+++ b/src/core/SkLiteDL.cpp
@@ -7,7 +7,6 @@
 
 #include "SkCanvas.h"
 #include "SkData.h"
-#include "SkDrawFilter.h"
 #include "SkDrawShadowInfo.h"
 #include "SkImage.h"
 #include "SkImageFilter.h"
@@ -47,8 +46,8 @@
 }
 
 namespace {
-#define TYPES(M)                                                               \
-    M(SetDrawFilter) M(Flush) M(Save) M(Restore) M(SaveLayer)                   \
+#define TYPES(M)                                                                \
+    M(Flush) M(Save) M(Restore) M(SaveLayer)                                    \
     M(Concat) M(SetMatrix) M(Translate)                                         \
     M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion)                          \
     M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc)   \
@@ -68,19 +67,6 @@
     };
     static_assert(sizeof(Op) == 4, "");
 
-    struct SetDrawFilter final : Op {
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-        static const auto kType = Type::SetDrawFilter;
-        SetDrawFilter(SkDrawFilter* df) : drawFilter(sk_ref_sp(df)) {}
-        sk_sp<SkDrawFilter> drawFilter;
-#endif
-        void draw(SkCanvas* c, const SkMatrix&) const {
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-            c->setDrawFilter(drawFilter.get());
-#endif
-        }
-    };
-
     struct Flush final : Op {
         static const auto kType = Type::Flush;
         void draw(SkCanvas* c, const SkMatrix&) const { c->flush(); }
@@ -542,12 +528,6 @@
     }
 }
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-void SkLiteDL::setDrawFilter(SkDrawFilter* df) {
-    this->push<SetDrawFilter>(0, df);
-}
-#endif
-
 void SkLiteDL::flush() { this->push<Flush>(0); }
 
 void SkLiteDL::   save() { this->push   <Save>(0); }
diff --git a/src/core/SkLiteDL.h b/src/core/SkLiteDL.h
index b63ed0d..aa32e02 100644
--- a/src/core/SkLiteDL.h
+++ b/src/core/SkLiteDL.h
@@ -25,10 +25,6 @@
     void reset();
     bool empty() const { return fUsed == 0; }
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-    void setDrawFilter(SkDrawFilter*);
-#endif
-
     void flush();
 
     void save();
diff --git a/src/core/SkLiteRecorder.cpp b/src/core/SkLiteRecorder.cpp
index 0891508..971e62c 100644
--- a/src/core/SkLiteRecorder.cpp
+++ b/src/core/SkLiteRecorder.cpp
@@ -22,13 +22,6 @@
     return nullptr;
 }
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-SkDrawFilter* SkLiteRecorder::setDrawFilter(SkDrawFilter* df) {
-    fDL->setDrawFilter(df);
-    return this->INHERITED::setDrawFilter(df);
-}
-#endif
-
 void SkLiteRecorder::onFlush() { fDL->flush(); }
 
 void SkLiteRecorder::willSave() { fDL->save(); }
diff --git a/src/core/SkLiteRecorder.h b/src/core/SkLiteRecorder.h
index af538ee..bc37546 100644
--- a/src/core/SkLiteRecorder.h
+++ b/src/core/SkLiteRecorder.h
@@ -20,10 +20,6 @@
 
     sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
 
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-    SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
-#endif
-
     void willSave() override;
     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
     void willRestore() override;
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 774a1eb..d2c0cf8 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -240,12 +240,10 @@
     }
 
 protected:
-    void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint,
-                      SkDrawFilter* drawFilter) override {
+    void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+                      const SkPaint& paint) override {
         // The looper should be applied by the SkCanvas.
         SkASSERT(paint.getDrawLooper() == nullptr);
-        // We don't support SkDrawFilter.
-        SkASSERT(drawFilter == nullptr);
 
         SkPoint position{x, y};
         SkPaint runPaint{paint};
diff --git a/src/effects/SkPaintFlagsDrawFilter.cpp b/src/effects/SkPaintFlagsDrawFilter.cpp
deleted file mode 100644
index 12b8fbb..0000000
--- a/src/effects/SkPaintFlagsDrawFilter.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkPaintFlagsDrawFilter.h"
-
-#include "SkPaint.h"
-#include "SkTo.h"
-
-SkPaintFlagsDrawFilter::SkPaintFlagsDrawFilter(uint32_t clearFlags,
-                                               uint32_t setFlags) {
-    fClearFlags = SkToU16(clearFlags & SkPaint::kAllFlags);
-    fSetFlags = SkToU16(setFlags & SkPaint::kAllFlags);
-}
-
-bool SkPaintFlagsDrawFilter::filter(SkPaint* paint, Type) {
-    paint->setFlags((paint->getFlags() & ~fClearFlags) | fSetFlags);
-    return true;
-}
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 058d48e..1357fa2 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -241,8 +241,7 @@
 
 void GrRenderTargetContext::drawTextBlob(const GrClip& clip, const SkPaint& paint,
                                          const SkMatrix& viewMatrix, const SkTextBlob* blob,
-                                         SkScalar x, SkScalar y, SkDrawFilter* filter,
-                                         const SkIRect& clipBounds) {
+                                         SkScalar x, SkScalar y, const SkIRect& clipBounds) {
     ASSERT_SINGLE_OWNER
     RETURN_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
@@ -250,7 +249,7 @@
 
     GrTextContext* atlasTextContext = this->drawingManager()->getTextContext();
     atlasTextContext->drawTextBlob(fContext, fTextTarget.get(), clip, paint, viewMatrix,
-                                   fSurfaceProps, blob, x, y, filter, clipBounds);
+                                   fSurfaceProps, blob, x, y, clipBounds);
 }
 
 void GrRenderTargetContext::discard() {
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 376fe10..bdeb688 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -36,7 +36,6 @@
 class GrStyle;
 class GrTextureProxy;
 struct GrUserStencilSettings;
-class SkDrawFilter;
 struct SkDrawShadowRec;
 struct SkIPoint;
 struct SkIRect;
@@ -70,8 +69,7 @@
                              const SkIRect& clipBounds);
     virtual void drawTextBlob(const GrClip&, const SkPaint&,
                               const SkMatrix& viewMatrix, const SkTextBlob*,
-                              SkScalar x, SkScalar y,
-                              SkDrawFilter*, const SkIRect& clipBounds);
+                              SkScalar x, SkScalar y, const SkIRect& clipBounds);
 
     /**
      * Provides a perfomance hint that the render target's contents are allowed
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index c9cda0d..cc21397 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1638,12 +1638,12 @@
 }
 
 void SkGpuDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
-                               const SkPaint& paint, SkDrawFilter* drawFilter) {
+                               const SkPaint& paint) {
     ASSERT_SINGLE_OWNER
     GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawTextBlob", fContext.get());
     SkDEBUGCODE(this->validate();)
 
-    fRenderTargetContext->drawTextBlob(this->clip(), paint, this->ctm(), blob, x, y, drawFilter,
+    fRenderTargetContext->drawTextBlob(this->clip(), paint, this->ctm(), blob, x, y,
                                        this->devClipBounds());
 }
 
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index c31e624..8d360c2 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -89,8 +89,7 @@
                     const SkPaint& paint) override;
     void drawPosText(const void* text, size_t len, const SkScalar pos[],
                      int scalarsPerPos, const SkPoint& offset, const SkPaint&) override;
-    void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y,
-                      const SkPaint& paint, SkDrawFilter* drawFilter) override;
+    void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint& paint) override;
     void drawVertices(const SkVertices*, const SkMatrix bones[], int boneCount, SkBlendMode,
                       const SkPaint&) override;
     void drawShadow(const SkPath&, const SkDrawShadowRec&) override;
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 62f7d74..7b4507e 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -11,7 +11,6 @@
 #include "GrContext.h"
 #include "GrTextUtils.h"
 #include "SkColorFilter.h"
-#include "SkDrawFilter.h"
 #include "SkGlyphCache.h"
 #include "SkMaskFilterBase.h"
 #include "SkPaintPriv.h"
@@ -303,7 +302,7 @@
     // GrTextBlob::makeOp only takes uint16_t values for run and subRun indices.
     // Encountering something larger than this is highly unlikely, so we'll just not draw it.
     int lastRun = SkTMin(fRunCount, (1 << 16)) - 1;
-    GrTextUtils::RunPaint runPaint(&paint, nullptr);
+    GrTextUtils::RunPaint runPaint(&paint);
     for (int runIndex = 0; runIndex <= lastRun; runIndex++) {
         Run& run = fRuns[runIndex];
 
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index 19128ab..686dac4 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -25,7 +25,6 @@
 struct GrDistanceFieldAdjustTable;
 struct GrGlyph;
 
-class SkDrawFilter;
 class SkTextBlob;
 class SkTextBlobRunIterator;
 
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 16f164c..28204eb 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -14,7 +14,6 @@
 #include "GrTextBlobCache.h"
 #include "SkDistanceFieldGen.h"
 #include "SkDraw.h"
-#include "SkDrawFilter.h"
 #include "SkDrawProcs.h"
 #include "SkFindAndPlaceGlyph.h"
 #include "SkGlyphRun.h"
@@ -102,7 +101,7 @@
                                  const GrClip& clip, const SkPaint& skPaint,
                                  const SkMatrix& viewMatrix, const SkSurfaceProps& props,
                                  const SkTextBlob* blob, SkScalar x, SkScalar y,
-                                 SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
+                                 const SkIRect& clipBounds) {
     // If we have been abandoned, then don't draw
     if (context->abandoned()) {
         return;
@@ -114,9 +113,7 @@
     // It might be worth caching these things, but its not clear at this time
     // TODO for animated mask filters, this will fill up our cache.  We need a safeguard here
     const SkMaskFilter* mf = skPaint.getMaskFilter();
-    bool canCache = !(skPaint.getPathEffect() ||
-                      (mf && !as_MFB(mf)->asABlur(&blurRec)) ||
-                      drawFilter);
+    bool canCache = !(skPaint.getPathEffect() || (mf && !as_MFB(mf)->asABlur(&blurRec)));
     SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
 
     auto glyphCache = context->contextPriv().getGlyphCache();
@@ -154,7 +151,7 @@
             cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint);
             this->regenerateTextBlob(cacheBlob.get(), glyphCache,
                                      *context->contextPriv().caps()->shaderCaps(), paint,
-                                     scalerContextFlags, viewMatrix, props, blob, x, y, drawFilter);
+                                     scalerContextFlags, viewMatrix, props, blob, x, y);
         } else {
             textBlobCache->makeMRU(cacheBlob.get());
 
@@ -166,7 +163,7 @@
                 sanityBlob->setupKey(key, blurRec, skPaint);
                 this->regenerateTextBlob(
                         sanityBlob.get(), glyphCache, *context->contextPriv().caps()->shaderCaps(),
-                        paint, scalerContextFlags, viewMatrix, props, blob, x, y, drawFilter);
+                        paint, scalerContextFlags, viewMatrix, props, blob, x, y);
                 GrTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
             }
         }
@@ -178,7 +175,7 @@
         }
         this->regenerateTextBlob(cacheBlob.get(), glyphCache,
                                  *context->contextPriv().caps()->shaderCaps(), paint,
-                                 scalerContextFlags, viewMatrix, props, blob, x, y, drawFilter);
+                                 scalerContextFlags, viewMatrix, props, blob, x, y);
     }
 
     cacheBlob->flush(target, props, fDistanceAdjustTable.get(), paint,
@@ -192,13 +189,12 @@
                                        SkScalerContextFlags scalerContextFlags,
                                        const SkMatrix& viewMatrix,
                                        const SkSurfaceProps& props, const SkTextBlob* blob,
-                                       SkScalar x, SkScalar y,
-                                       SkDrawFilter* drawFilter) const {
+                                       SkScalar x, SkScalar y) const {
     cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, x, y);
 
     // Regenerate textblob
     SkTextBlobRunIterator it(blob);
-    GrTextUtils::RunPaint runPaint(&paint, drawFilter);
+    GrTextUtils::RunPaint runPaint(&paint);
     for (int run = 0; !it.done(); it.next(), run++) {
         int glyphCount = it.glyphCount();
         size_t textLen = glyphCount * sizeof(uint16_t);
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
index dd82b3c..50ec0ab 100644
--- a/src/gpu/text/GrTextContext.h
+++ b/src/gpu/text/GrTextContext.h
@@ -50,7 +50,7 @@
                      const SkPoint& offset, const SkIRect& regionClipBounds);
     void drawTextBlob(GrContext*, GrTextUtils::Target*, const GrClip&, const SkPaint&,
                       const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkTextBlob*,
-                      SkScalar x, SkScalar y, SkDrawFilter*, const SkIRect& clipBounds);
+                      SkScalar x, SkScalar y, const SkIRect& clipBounds);
 
     std::unique_ptr<GrDrawOp> createOp_TestingOnly(GrContext*,
                                                    GrTextContext*,
@@ -122,8 +122,7 @@
                             SkScalerContextFlags scalerContextFlags,
                             const SkMatrix& viewMatrix,
                             const SkSurfaceProps&,
-                            const SkTextBlob* blob, SkScalar x, SkScalar y,
-                            SkDrawFilter* drawFilter) const;
+                            const SkTextBlob* blob, SkScalar x, SkScalar y) const;
 
     static bool HasLCD(const SkTextBlob*);
 
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index bd3647e..6f043e1 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -7,7 +7,6 @@
 
 #include "GrTextUtils.h"
 #include "GrContext.h"
-#include "SkDrawFilter.h"
 #include "SkGlyphCache.h"
 #include "SkGr.h"
 #include "SkPaint.h"
@@ -27,21 +26,8 @@
     if (!fModifiedPaint.isValid()) {
         fModifiedPaint.init(fOriginalPaint->skPaint());
         fPaint = fModifiedPaint.get();
-    } else if (fFilter) {
-        // We have to reset before applying the run because the filter could have arbitrary
-        // changed the paint.
-        *fModifiedPaint.get() = fOriginalPaint->skPaint();
     }
     paintModFunc(fModifiedPaint.get());
-
-    if (fFilter) {
-        if (!fFilter->filter(fModifiedPaint.get(), SkDrawFilter::kText_Type)) {
-            // A false return from filter() means we should abort the current draw.
-            return false;
-        }
-        // The draw filter could have changed either the paint color or color filter.
-        this->initFilteredColor();
-    }
     return true;
 }
 
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 363a91e..05fbf6f 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -26,7 +26,6 @@
 class GrPaint;
 class GrShaderCaps;
 class SkColorSpace;
-class SkDrawFilter;
 class SkGlyph;
 class SkMatrix;
 struct SkIRect;
@@ -110,8 +109,7 @@
      */
     class RunPaint : public Paint {
     public:
-        RunPaint(const Paint* paint, SkDrawFilter* filter)
-                : fOriginalPaint(paint), fFilter(filter) {
+        RunPaint(const Paint* paint) : fOriginalPaint(paint) {
             // Initially we represent the original paint.
             fPaint = &fOriginalPaint->skPaint();
             fDstColorSpaceInfo = fOriginalPaint->dstColorSpaceInfo();
@@ -123,7 +121,6 @@
     private:
         SkTLazy<SkPaint> fModifiedPaint;
         const Paint* fOriginalPaint;
-        SkDrawFilter* fFilter;
     };
 
     class PathTextIter : SkTextBaseIter {
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 6868aef..a933972 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -17,7 +17,6 @@
 #include "SkColor.h"
 #include "SkColorFilter.h"
 #include "SkDraw.h"
-#include "SkDrawFilter.h"
 #include "SkGlyphCache.h"
 #include "SkImageFilterCache.h"
 #include "SkJpegEncoder.h"
@@ -1459,13 +1458,10 @@
 }
 
 void SkPDFDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
-                               const SkPaint &paint, SkDrawFilter* drawFilter) {
+                               const SkPaint &paint) {
     for (SkTextBlobRunIterator it(blob); !it.done(); it.next()) {
         SkPaint runPaint(paint);
         it.applyFontToPaint(&runPaint);
-        if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) {
-            continue;
-        }
         SkPoint offset = it.offset() + SkPoint{x, y};
         this->internalDrawText(it.glyphs(), sizeof(SkGlyphID) * it.glyphCount(),
                                it.pos(), it.positioning(), offset, runPaint,
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 4c9c9c8..6077aaf 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -68,8 +68,7 @@
     /**
      *  These are called inside the per-device-layer loop for each draw call.
      *  When these are called, we have already applied any saveLayer
-     *  operations, and are handling any looping from the paint, and any
-     *  effects from the DrawFilter.
+     *  operations, and are handling any looping from the paint.
      */
     void drawPaint(const SkPaint& paint) override;
     void drawPoints(SkCanvas::PointMode mode,
@@ -98,8 +97,7 @@
     void drawPosText(const void* text, size_t len,
                      const SkScalar pos[], int scalarsPerPos,
                      const SkPoint& offset, const SkPaint&) override;
-    void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y,
-                      const SkPaint &, SkDrawFilter*) override;
+    void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint &) override;
     void drawVertices(const SkVertices*, const SkMatrix* bones, int boneCount, SkBlendMode,
                       const SkPaint&) override;
     void drawDevice(SkBaseDevice*, int x, int y,
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 017ec05..7d1e981 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -366,13 +366,3 @@
         iter->flush();
     }
 }
-
-#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
-SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) {
-    Iter iter(fList);
-    while (iter.next()) {
-        iter->setDrawFilter(filter);
-    }
-    return this->INHERITED::setDrawFilter(filter);
-}
-#endif