[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/SkSVGFeDisplacementMap.cpp b/modules/svg/src/SkSVGFeDisplacementMap.cpp
index 966faa5..9698a55 100644
--- a/modules/svg/src/SkSVGFeDisplacementMap.cpp
+++ b/modules/svg/src/SkSVGFeDisplacementMap.cpp
@@ -36,10 +36,9 @@
SkScalar scale = fScale;
if (fctx.primitiveUnits().type() == SkSVGObjectBoundingBoxUnits::Type::kObjectBoundingBox) {
- SkASSERT(ctx.node());
- const SkRect objBounds = ctx.node()->objectBoundingBox(ctx);
- const SkSVGLengthContext lctx({objBounds.width(), objBounds.height()});
- scale = lctx.resolve(SkSVGLength(scale, SkSVGLength::Unit::kPercentage),
+ const auto obbt = ctx.transformForCurrentOBB(fctx.primitiveUnits());
+ scale = SkSVGLengthContext({obbt.scale.x, obbt.scale.y})
+ .resolve(SkSVGLength(scale, SkSVGLength::Unit::kPercentage),
SkSVGLengthContext::LengthType::kOther);
}