[SVGDom] Expose intrinsic size info
* expose intrinsic size info on <svg> nodes.
* tweak the SkSVGDOM constructor to no longer take an container size
param, but instead default to intrinsic size
* update clients to call SkSVGDOM::setContainerSize() explicitly, when
needed
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2345533002
Review-Url: https://codereview.chromium.org/2345533002
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index ef22dee..ca403f5 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -651,16 +651,21 @@
return nullptr;
}
- // TODO: use intrinsic size? make tunable via flag?
- static const SkSize kContainerSize = SkSize::Make(128, 128);
- sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream, kContainerSize);
+ sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream);
if (!svgDom) {
SkDebugf("Could not parse %s.\n", path);
return nullptr;
}
+ // Use the intrinsic SVG size if available, otherwise fall back to a default value.
+ static const SkSize kDefaultContainerSize = SkSize::Make(128, 128);
+ if (svgDom->containerSize().isEmpty()) {
+ svgDom->setContainerSize(kDefaultContainerSize);
+ }
+
SkPictureRecorder recorder;
- svgDom->render(recorder.beginRecording(kContainerSize.width(), kContainerSize.height()));
+ svgDom->render(recorder.beginRecording(svgDom->containerSize().width(),
+ svgDom->containerSize().height()));
return recorder.finishRecordingAsPicture();
}