Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index dd54f00e2bd1a8d68996177103644b2e79c55334..17714fb04642ec874705ec68ae25c12f115f19fa 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -1098,46 +1098,43 @@ static const SkSize kDefaultSVGSize = SkSize::Make(1000, 1000); |
// Used to force-scale tiny fixed-size images. |
static const SkSize kMinimumSVGSize = SkSize::Make(128, 128); |
-SVGSrc::SVGSrc(Path path) : fPath(path), fScale(1) {} |
- |
-Error SVGSrc::ensureDom() const { |
- if (!fDom) { |
- SkFILEStream stream(fPath.c_str()); |
- if (!stream.isValid()) { |
- return SkStringPrintf("Unable to open file: %s", fPath.c_str()); |
- } |
- fDom = SkSVGDOM::MakeFromStream(stream); |
- if (!fDom) { |
- return SkStringPrintf("Unable to parse file: %s", fPath.c_str()); |
- } |
- |
- const SkSize& sz = fDom->containerSize(); |
- if (sz.isEmpty()) { |
- // no intrinsic size |
- fDom->setContainerSize(kDefaultSVGSize); |
- } else { |
- fScale = SkTMax(1.f, SkTMax(kMinimumSVGSize.width() / sz.width(), |
- kMinimumSVGSize.height() / sz.height())); |
- } |
- } |
- |
- return ""; |
+SVGSrc::SVGSrc(Path path) |
+ : fName(SkOSPath::Basename(path.c_str())) |
+ , fScale(1) { |
+ |
+ SkFILEStream stream(path.c_str()); |
+ if (!stream.isValid()) { |
+ return; |
+ } |
+ fDom = SkSVGDOM::MakeFromStream(stream); |
+ if (!fDom) { |
+ return; |
+ } |
+ |
+ const SkSize& sz = fDom->containerSize(); |
+ if (sz.isEmpty()) { |
+ // no intrinsic size |
+ fDom->setContainerSize(kDefaultSVGSize); |
+ } else { |
+ fScale = SkTMax(1.f, SkTMax(kMinimumSVGSize.width() / sz.width(), |
+ kMinimumSVGSize.height() / sz.height())); |
+ } |
} |
Error SVGSrc::draw(SkCanvas* canvas) const { |
- Error err = this->ensureDom(); |
- if (err.isEmpty()) { |
- SkAutoCanvasRestore acr(canvas, true); |
- canvas->scale(fScale, fScale); |
- fDom->render(canvas); |
+ if (!fDom) { |
+ return SkStringPrintf("Unable to parse file: %s", fName.c_str()); |
} |
- return err; |
+ SkAutoCanvasRestore acr(canvas, true); |
+ canvas->scale(fScale, fScale); |
+ fDom->render(canvas); |
+ |
+ return ""; |
} |
SkISize SVGSrc::size() const { |
- Error err = this->ensureDom(); |
- if (!err.isEmpty()) { |
+ if (!fDom) { |
return SkISize::Make(0, 0); |
} |
@@ -1145,7 +1142,7 @@ SkISize SVGSrc::size() const { |
fDom->containerSize().height() * fScale).toRound(); |
} |
-Name SVGSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } |
+Name SVGSrc::name() const { return fName; } |
bool SVGSrc::veto(SinkFlags flags) const { |
// No need to test to non-(raster||gpu) or indirect backends. |