aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-09-28 11:59:46 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-28 18:22:40 +0000
commitd4124bc232b80c87190d48d43bc98f95148347fd (patch)
treeaccf4c3e2fe0aecacede0db218c99c16d4f119e8 /samplecode
parentf7729c262076b88b2635e7f8d09e7f3340eea79b (diff)
Add svg support to pathfinder tool
Bug: skia: Change-Id: I9302491c983fae5e2e84edc4ee135a917b099a42 Reviewed-on: https://skia-review.googlesource.com/52360 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SamplePathFinder.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/samplecode/SamplePathFinder.cpp b/samplecode/SamplePathFinder.cpp
index 2cbfdc3ba2..18d200bad1 100644
--- a/samplecode/SamplePathFinder.cpp
+++ b/samplecode/SamplePathFinder.cpp
@@ -8,6 +8,8 @@
#include "SampleCode.h"
#include "SkCanvas.h"
#include "SkCommandLineFlags.h"
+#include "SkDOM.h"
+#include "SkSVGDOM.h"
#include "SkOSPath.h"
#include "SkPath.h"
#include "SkPicture.h"
@@ -32,15 +34,30 @@ public:
, fFilename(name) {
SkFILEStream stream(fFilename.c_str());
if (!stream.isValid()) {
- SkDebugf("couldn't load picture at \"%s\"\n", fFilename.c_str());
+ SkDebugf("invalid input file at \"%s\"\n", fFilename.c_str());
return;
}
- sk_sp<SkPicture> pic = SkPicture::MakeFromStream(&stream);
- if (!pic) {
- SkDebugf("couldn't load picture at \"%s\"\n", fFilename.c_str());
- return;
+ if (fFilename.endsWith(".svg")) {
+ SkDOM xml;
+ if (!xml.build(stream)) {
+ SkDebugf("XML parsing failed: \"%s\"\n", fFilename.c_str());
+ return;
+ }
+ sk_sp<SkSVGDOM> svg = SkSVGDOM::MakeFromDOM(xml);
+ if (!svg) {
+ SkDebugf("couldn't load svg at \"%s\"\n", fFilename.c_str());
+ return;
+ }
+ svg->setContainerSize(SkSize::Make(500, 500));
+ svg->render(this);
+ } else {
+ sk_sp<SkPicture> pic = SkPicture::MakeFromStream(&stream);
+ if (!pic) {
+ SkDebugf("couldn't load skp at \"%s\"\n", fFilename.c_str());
+ return;
+ }
+ pic->playback(this);
}
- pic->playback(this);
for (int i = 0; i < FLAGS_pathfinderTrail.count(); ++i) {
const char* key = FLAGS_pathfinderTrail[i];
while (*key) {