diff --git a/src/core/SkColorSpaceXformCanvas.cpp b/src/core/SkColorSpaceXformCanvas.cpp index e85d4d02df..9486a4ed56 100644 --- a/src/core/SkColorSpaceXformCanvas.cpp +++ b/src/core/SkColorSpaceXformCanvas.cpp @@ -9,8 +9,9 @@ #include "SkColorSpaceXformCanvas.h" #include "SkColorSpaceXformer.h" #include "SkGradientShader.h" -#include "SkImage_Base.h" +#include "SkImageFilter.h" #include "SkImagePriv.h" +#include "SkImage_Base.h" #include "SkMakeUnique.h" #include "SkNoDrawCanvas.h" #include "SkSurface.h" @@ -208,7 +209,6 @@ public: fXformer->apply(paint)); } - // TODO: May not be ideal to unfurl pictures. void onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) override { @@ -219,10 +219,11 @@ public: } SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& rec) override { + sk_sp backdrop = rec.fBackdrop ? fXformer->apply(rec.fBackdrop) : nullptr; fTarget->saveLayer({ rec.fBounds, fXformer->apply(rec.fPaint), - rec.fBackdrop, // TODO: this is an image filter + backdrop.get(), rec.fSaveLayerFlags, }); return kNoLayer_SaveLayerStrategy; diff --git a/src/core/SkColorSpaceXformer.cpp b/src/core/SkColorSpaceXformer.cpp index 779fe81cad..0db303b41c 100644 --- a/src/core/SkColorSpaceXformer.cpp +++ b/src/core/SkColorSpaceXformer.cpp @@ -63,6 +63,10 @@ sk_sp SkColorSpaceXformer::apply(const SkColorFilter* colorFilter return sk_ref_sp(const_cast(colorFilter)); } +sk_sp SkColorSpaceXformer::apply(const SkImageFilter* imageFilter) { + return imageFilter->makeColorSpace(this); +} + void SkColorSpaceXformer::apply(SkColor* xformed, const SkColor* srgb, int n) { SkAssertResult(fFromSRGB->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, xformed, SkColorSpaceXform::kBGRA_8888_ColorFormat, srgb, @@ -112,7 +116,7 @@ const SkPaint& SkColorSpaceXformer::apply(const SkPaint& src) { } if (auto imageFilter = src.getImageFilter()) { - auto replacement = imageFilter->makeColorSpace(this); + auto replacement = this->apply(imageFilter); if (replacement.get() != imageFilter) { get_dst()->setImageFilter(std::move(replacement)); } diff --git a/src/core/SkColorSpaceXformer.h b/src/core/SkColorSpaceXformer.h index 61a0c027c8..d357743d22 100644 --- a/src/core/SkColorSpaceXformer.h +++ b/src/core/SkColorSpaceXformer.h @@ -19,6 +19,7 @@ public: sk_sp apply(const SkImage* src); sk_sp apply(const SkBitmap& bitmap); sk_sp apply(const SkColorFilter* filter); + sk_sp apply(const SkImageFilter* filter); const SkPaint* apply(const SkPaint* src); const SkPaint& apply(const SkPaint& src); void apply(SkColor dst[], const SkColor src[], int n);