SkImageFilter::onMakeColorSpace() - more overrides
Fills out most of the simple implementations.
Improves 22 gms in gbr-8888.
Bug: skia:
Change-Id: I881ade140993568263de75be51aed240d2de8cc6
Reviewed-on: https://skia-review.googlesource.com/13126
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 9c884b5..06f16f0 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -412,6 +412,23 @@
dst);
}
+sk_sp<SkImageFilter> SkDisplacementMapEffect::onMakeColorSpace(SkColorSpaceXformer* xformer) const {
+ SkASSERT(2 == this->countInputs());
+ if (!this->getInput(1)) {
+ return sk_ref_sp(const_cast<SkDisplacementMapEffect*>(this));
+ }
+
+ // Intentionally avoid xforming the displacement filter. The values will be used as
+ // offsets, not as colors.
+ sk_sp<SkImageFilter> displacement = sk_ref_sp(const_cast<SkImageFilter*>(this->getInput(0)));
+ sk_sp<SkImageFilter> color =
+ this->getInput(1) ? this->getInput(1)->makeColorSpace(xformer) : nullptr;
+
+ return SkDisplacementMapEffect::Make(fXChannelSelector, fYChannelSelector, fScale,
+ std::move(displacement), std::move(color),
+ this->getCropRectIfSet());
+}
+
SkRect SkDisplacementMapEffect::computeFastBounds(const SkRect& src) const {
SkRect bounds = this->getColorInput() ? this->getColorInput()->computeFastBounds(src) : src;
bounds.outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);