diff options
author | Ben Wagner <bungeman@google.com> | 2018-06-27 14:46:46 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-12 02:36:44 +0000 |
commit | 2c312c4f58f9c151acab8ca2dd0d39fb77c5e74a (patch) | |
tree | 527d8ef60903f99e54cc83615a051c8b65e046bb /src | |
parent | 0859252397e0a771669d21d173a8a20f814b7ca0 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapDevice.h | 3 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 127 | ||||
-rw-r--r-- | src/core/SkColorSpaceXformCanvas.cpp | 7 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 14 | ||||
-rw-r--r-- | src/core/SkDevice.h | 7 | ||||
-rw-r--r-- | src/core/SkLiteDL.cpp | 24 | ||||
-rw-r--r-- | src/core/SkLiteDL.h | 4 | ||||
-rw-r--r-- | src/core/SkLiteRecorder.cpp | 7 | ||||
-rw-r--r-- | src/core/SkLiteRecorder.h | 4 | ||||
-rw-r--r-- | src/core/SkRemoteGlyphCache.cpp | 6 | ||||
-rw-r--r-- | src/effects/SkPaintFlagsDrawFilter.cpp | 22 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.h | 4 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 4 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 3 | ||||
-rw-r--r-- | src/gpu/text/GrTextBlob.cpp | 3 | ||||
-rw-r--r-- | src/gpu/text/GrTextBlob.h | 1 | ||||
-rw-r--r-- | src/gpu/text/GrTextContext.cpp | 18 | ||||
-rw-r--r-- | src/gpu/text/GrTextContext.h | 5 | ||||
-rw-r--r-- | src/gpu/text/GrTextUtils.cpp | 14 | ||||
-rw-r--r-- | src/gpu/text/GrTextUtils.h | 5 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.h | 6 | ||||
-rw-r--r-- | src/utils/SkNWayCanvas.cpp | 10 |
24 files changed, 70 insertions, 239 deletions
diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index e2cedaa7e1..5c4af03ab5 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -74,8 +74,7 @@ protected: /** 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 5b2a2cf3c2..afdb4f9940 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 @@ struct DeviceCM { */ 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 @@ public: int fDeferredSaveCount; MCRec() { - fFilter = nullptr; fLayer = nullptr; fTopLayer = nullptr; fMatrix.reset(); @@ -243,7 +240,6 @@ public: 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 @@ public: inc_rec(); } ~MCRec() { - SkSafeUnref(fFilter); delete fLayer; dec_rec(); } @@ -371,11 +366,6 @@ public: 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 @@ public: } else { fLooperContext = nullptr; // can we be marked as simple? - fIsSimple = !fFilter && !fTempLayerForImageFilter; + fIsSimple = !fTempLayerForImageFilter; } } @@ -442,14 +432,14 @@ public: 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 @@ private: 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 @@ private: 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 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { 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 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { #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 @@ SkCanvas::~SkCanvas() { 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 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, const SkPa paint = &tmp; } - LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) + LOOPER_BEGIN_DRAWDEVICE(*paint) while (iter.next()) { SkBaseDevice* dstDev = iter.fDevice; @@ -1945,7 +1912,7 @@ void SkCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) { 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::onDrawPaint(const SkPaint& paint) { } 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 @@ void SkCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], 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 @@ void SkCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], 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 @@ void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) { } 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 @@ void SkCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) { } } - LOOPER_BEGIN(paint, SkDrawFilter::kRect_Type, ®ionRect) + LOOPER_BEGIN(paint, ®ionRect) while (iter.next()) { iter.fDevice->drawRegion(region, looper.paint()); @@ -2073,7 +2037,7 @@ void SkCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) { } } - LOOPER_BEGIN(paint, SkDrawFilter::kOval_Type, &oval) + LOOPER_BEGIN(paint, &oval) while (iter.next()) { iter.fDevice->drawOval(oval, looper.paint()); @@ -2094,7 +2058,7 @@ void SkCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle, } } - 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 @@ void SkCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 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 @@ void SkCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const Sk } } - 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 @@ void SkCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { } } - LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, &pathBounds) + LOOPER_BEGIN(paint, &pathBounds) while (iter.next()) { iter.fDevice->drawPath(path, looper.paint()); @@ -2275,8 +2239,7 @@ void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk } 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 @@ void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 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 @@ void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons } 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 @@ void SkCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, c } 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 @@ void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, } 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 @@ void SkCanvas::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattic } 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::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattic 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::onDrawText(const void* text, size_t byteLength, SkScalar x, SkSca 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::onDrawPosText(const void* text, size_t byteLength, const SkPoint 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::onDrawPosTextH(const void* text, size_t byteLength, const SkScala 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 @@ void SkCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRS 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 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, // 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::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 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 @@ void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 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 @@ void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const 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 @@ void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* va 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 caf07fb5d9..949dd4a2e3 100644 --- a/src/core/SkColorSpaceXformCanvas.cpp +++ b/src/core/SkColorSpaceXformCanvas.cpp @@ -267,13 +267,6 @@ public: 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 2b7fef62fb..b6f52913eb 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::drawPatch(const SkPoint cubics[12], const SkColor colors[4], } 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 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, // 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 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 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 4959f1fec3..2173d91023 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 @@ protected: /** 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 @@ protected: 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 4240055480..ea3ca6d14b 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 @@ static const D* pod(const T* op, size_t offset = 0) { } 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 @@ namespace { }; 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 @@ inline void SkLiteDL::map(const Fn fns[], Args... args) const { } } -#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 b63ed0d514..aa32e0229f 100644 --- a/src/core/SkLiteDL.h +++ b/src/core/SkLiteDL.h @@ -25,10 +25,6 @@ public: 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 0891508c92..971e62c0d3 100644 --- a/src/core/SkLiteRecorder.cpp +++ b/src/core/SkLiteRecorder.cpp @@ -22,13 +22,6 @@ sk_sp<SkSurface> SkLiteRecorder::onNewSurface(const SkImageInfo&, const SkSurfac 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 af538ee3aa..bc37546add 100644 --- a/src/core/SkLiteRecorder.h +++ b/src/core/SkLiteRecorder.h @@ -20,10 +20,6 @@ public: 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 774a1eb77c..d2c0cf8ced 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -240,12 +240,10 @@ public: } 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 12b8fbbf94..0000000000 --- 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 058d48e49e..1357fa23c1 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -241,8 +241,7 @@ void GrRenderTargetContext::drawPosText(const GrClip& clip, const SkPaint& paint 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 @@ void GrRenderTargetContext::drawTextBlob(const GrClip& clip, const SkPaint& pain 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 376fe10735..bdeb688896 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -36,7 +36,6 @@ class GrShape; class GrStyle; class GrTextureProxy; struct GrUserStencilSettings; -class SkDrawFilter; struct SkDrawShadowRec; struct SkIPoint; struct SkIRect; @@ -70,8 +69,7 @@ public: 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 c9cda0de7d..cc21397e12 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1638,12 +1638,12 @@ void SkGpuDevice::drawPosText(const void* text, size_t byteLength, } 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 c31e6245b3..8d360c2813 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -89,8 +89,7 @@ public: 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 62f7d74f57..7b4507eab0 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 @@ void GrTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& props, // 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 19128ab98e..686dac4eb1 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -25,7 +25,6 @@ class GrAtlasManager; 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 16f164c9c8..28204eb7af 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 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target 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 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target // 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 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target 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 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target 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 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target } 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 @@ void GrTextContext::regenerateTextBlob(GrTextBlob* cacheBlob, 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 dd82b3ce7d..50ec0ab59e 100644 --- a/src/gpu/text/GrTextContext.h +++ b/src/gpu/text/GrTextContext.h @@ -50,7 +50,7 @@ public: 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 @@ private: 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 bd3647e7ad..6f043e108f 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 @@ bool GrTextUtils::RunPaint::modifyForRun(std::function<void(SkPaint*)> paintModF 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 363a91e065..05fbf6f35e 100644 --- a/src/gpu/text/GrTextUtils.h +++ b/src/gpu/text/GrTextUtils.h @@ -26,7 +26,6 @@ class GrGlyphCache; class GrPaint; class GrShaderCaps; class SkColorSpace; -class SkDrawFilter; class SkGlyph; class SkMatrix; struct SkIRect; @@ -110,8 +109,7 @@ public: */ 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 @@ public: 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 6868aefe5c..a933972009 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::drawPosText(const void* text, size_t len, } 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 4c9c9c88ac..6077aafd7a 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -68,8 +68,7 @@ public: /** * 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 @@ public: 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 017ec0551b..7d1e98106b 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -366,13 +366,3 @@ void SkNWayCanvas::onFlush() { 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 |