[svg] Implement onObjectBoundingBox for circle and path
Also removed an erroneous call to mapToRect() when returning bounds
for SkSVGContainer. The contexts in which we access object bounds are
always such that any transforms have already been applied.
Change-Id: Ieac488e1699d3ebff56038d6ada36737291671eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345117
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/modules/svg/src/SkSVGCircle.cpp b/modules/svg/src/SkSVGCircle.cpp
index 6b25f09..e74149c 100644
--- a/modules/svg/src/SkSVGCircle.cpp
+++ b/modules/svg/src/SkSVGCircle.cpp
@@ -74,3 +74,8 @@
return path;
}
+
+SkRect SkSVGCircle::onObjectBoundingBox(const SkSVGRenderContext& ctx) const {
+ const auto [pos, r] = this->resolve(ctx.lengthContext());
+ return SkRect::MakeXYWH(pos.fX - r, pos.fY - r, 2 * r, 2 * r);
+}
diff --git a/modules/svg/src/SkSVGContainer.cpp b/modules/svg/src/SkSVGContainer.cpp
index 72d2b7b..6eb7d88 100644
--- a/modules/svg/src/SkSVGContainer.cpp
+++ b/modules/svg/src/SkSVGContainer.cpp
@@ -48,6 +48,5 @@
bounds.join(childBounds);
}
- this->mapToParent(&bounds);
return bounds;
}
diff --git a/modules/svg/src/SkSVGPath.cpp b/modules/svg/src/SkSVGPath.cpp
index f839379..256feb8 100644
--- a/modules/svg/src/SkSVGPath.cpp
+++ b/modules/svg/src/SkSVGPath.cpp
@@ -39,3 +39,7 @@
this->mapToParent(&path);
return path;
}
+
+SkRect SkSVGPath::onObjectBoundingBox(const SkSVGRenderContext& ctx) const {
+ return fPath.computeTightBounds();
+}