From e908b94d2f4642b25b2154eae2217d1a2eedcae9 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 25 Apr 2017 13:09:40 -0400 Subject: [PATCH] xform saveLayer() backdrop Just noticed this TODO is easy now. This doesn't seem to change any GMs, and definitely isn't used by Chrome or Android... this is just for completeness. It's also definitely correct to unfurl pictures. Change-Id: Ida6e43788d1de7a9452dad47aea8a5fbe41a1f46 Reviewed-on: https://skia-review.googlesource.com/14276 Commit-Queue: Mike Klein Reviewed-by: Matt Sarett --- src/core/SkColorSpaceXformCanvas.cpp | 7 ++++--- src/core/SkColorSpaceXformer.cpp | 6 +++++- src/core/SkColorSpaceXformer.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) 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);