[svg] Refactor object bounding box access
Introduce a helper (SkSVGRenderContext::obbTransform) and refactor all
obb clients to funnel their calls through it.
This will facilitate some follow up obb changes.
Bug: skia:11936
Change-Id: If0d81b0fc9148389c2cb4bff597057a2afa2fb1b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402956
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
diff --git a/modules/svg/src/SkSVGFeGaussianBlur.cpp b/modules/svg/src/SkSVGFeGaussianBlur.cpp
index 54ea011..1443845 100644
--- a/modules/svg/src/SkSVGFeGaussianBlur.cpp
+++ b/modules/svg/src/SkSVGFeGaussianBlur.cpp
@@ -20,17 +20,11 @@
sk_sp<SkImageFilter> SkSVGFeGaussianBlur::onMakeImageFilter(const SkSVGRenderContext& ctx,
const SkSVGFilterContext& fctx) const {
- SkScalar sigmaX = fStdDeviation.fX;
- SkScalar sigmaY = fStdDeviation.fY;
- if (fctx.primitiveUnits().type() == SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox) {
- SkASSERT(ctx.node());
- const SkRect objBounds = ctx.node()->objectBoundingBox(ctx);
- sigmaX *= objBounds.width();
- sigmaY *= objBounds.height();
- }
+ const auto sigma = SkV2{fStdDeviation.fX, fStdDeviation.fY}
+ * ctx.transformForCurrentOBB(fctx.primitiveUnits()).scale;
return SkImageFilters::Blur(
- sigmaX, sigmaY,
+ sigma.x, sigma.y,
fctx.resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)),
this->resolveFilterSubregion(ctx, fctx));
}