Add an SVG DM source

R=mtklein@google.com,robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2209593004

Review-Url: https://codereview.chromium.org/2209593004
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index a00f468..f821616 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -34,6 +34,7 @@
 #include "SkSVGCanvas.h"
 #include "SkStream.h"
 #include "SkTLogic.h"
+#include "SkSVGDOM.h"
 #include "SkSwizzler.h"
 #include <functional>
 
@@ -1025,6 +1026,36 @@
 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#if defined(SK_XML)
+// Should we try to use the SVG intrinsic size instead?
+static const SkSize kSVGSize = SkSize::Make(1000, 1000);
+
+SVGSrc::SVGSrc(Path path) : fPath(path) {}
+
+Error SVGSrc::draw(SkCanvas* canvas) const {
+    SkFILEStream stream(fPath.c_str());
+    if (!stream.isValid()) {
+        return SkStringPrintf("Unable to open file: %s", fPath.c_str());
+    }
+
+    sk_sp<SkSVGDOM> dom = SkSVGDOM::MakeFromStream(stream, kSVGSize);
+    if (!dom) {
+        return SkStringPrintf("Unable to parse file: %s", fPath.c_str());
+    }
+
+    dom->render(canvas);
+
+    return "";
+}
+
+SkISize SVGSrc::size() const {
+    return kSVGSize.toRound();
+}
+
+Name SVGSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
+
+#endif // defined(SK_XML)
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
 MSKPSrc::MSKPSrc(Path path) : fPath(path) {
     std::unique_ptr<SkStreamAsset> stream(SkStream::NewFromFile(fPath.c_str()));