[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>
This commit is contained in:
Tyler Denniston 2021-01-12 09:28:22 -05:00 committed by Skia Commit-Bot
parent bffe80a29d
commit 3a92f776b0
5 changed files with 13 additions and 1 deletions

View File

@ -29,6 +29,8 @@ protected:
SkPath onAsPath(const SkSVGRenderContext&) const override;
SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
private:
SkSVGCircle();

View File

@ -25,6 +25,8 @@ protected:
SkPath onAsPath(const SkSVGRenderContext&) const override;
SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
private:
SkSVGPath();

View File

@ -74,3 +74,8 @@ SkPath SkSVGCircle::onAsPath(const SkSVGRenderContext& ctx) const {
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);
}

View File

@ -48,6 +48,5 @@ SkRect SkSVGContainer::onObjectBoundingBox(const SkSVGRenderContext& ctx) const
bounds.join(childBounds);
}
this->mapToParent(&bounds);
return bounds;
}

View File

@ -39,3 +39,7 @@ SkPath SkSVGPath::onAsPath(const SkSVGRenderContext& ctx) const {
this->mapToParent(&path);
return path;
}
SkRect SkSVGPath::onObjectBoundingBox(const SkSVGRenderContext& ctx) const {
return fPath.computeTightBounds();
}