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/core/SkCanvas.cpp | |
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/core/SkCanvas.cpp')
-rw-r--r-- | src/core/SkCanvas.cpp | 127 |
1 files changed, 42 insertions, 85 deletions
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); } |