[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:
parent
bffe80a29d
commit
3a92f776b0
@ -29,6 +29,8 @@ protected:
|
||||
|
||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||
|
||||
SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
|
||||
|
||||
private:
|
||||
SkSVGCircle();
|
||||
|
||||
|
@ -25,6 +25,8 @@ protected:
|
||||
|
||||
SkPath onAsPath(const SkSVGRenderContext&) const override;
|
||||
|
||||
SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
|
||||
|
||||
private:
|
||||
SkSVGPath();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -48,6 +48,5 @@ SkRect SkSVGContainer::onObjectBoundingBox(const SkSVGRenderContext& ctx) const
|
||||
bounds.join(childBounds);
|
||||
}
|
||||
|
||||
this->mapToParent(&bounds);
|
||||
return bounds;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user