Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Side by Side Diff: experimental/svg/skp2svg.cpp

Issue 892533002: Initial SVG backend stubbing (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: optional output file arg Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/svg/SkSVGDevice.cpp ('k') | gyp/tools.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "LazyDecodeBitmap.h"
9 #include "SkCommandLineFlags.h"
10 #include "SkPicture.h"
11 #include "SkStream.h"
12 #include "SkSVGDevice.h"
13
14 DEFINE_string2(input, i, "", "input skp file");
15 DEFINE_string2(output, o, "", "output svg file (optional)");
16
17 // return codes:
18 static const int kSuccess = 0;
19 static const int kInvalidArgs = 1;
20 static const int kIOError = 2;
21 static const int kNotAnSKP = 3;
22
23 int tool_main(int argc, char** argv);
24 int tool_main(int argc, char** argv) {
25 SkCommandLineFlags::SetUsage("Converts an SKP file to SVG.");
26 SkCommandLineFlags::Parse(argc, argv);
27
28 if (FLAGS_input.count() != 1) {
29 SkDebugf("Missing input file\n");
30 return kInvalidArgs;
31 }
32
33 SkFILEStream stream(FLAGS_input[0]);
34 if (!stream.isValid()) {
35 SkDebugf("Couldn't open file: %s\n", FLAGS_input[0]);
36 return kIOError;
37 }
38
39 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(&stream, &sk_tools:: LazyDecodeBitmap));
40 if (!SkToBool(pic.get())) {
41 SkDebugf("Could not load SKP: %s\n", FLAGS_input[0]);
42 return kNotAnSKP;
43 }
44
45 SkAutoTDelete<SkWStream> outStream;
46 if (FLAGS_output.count() > 0) {
47 SkFILEWStream* fileStream = SkNEW_ARGS(SkFILEWStream, (FLAGS_output[0])) ;
48 if (!fileStream->isValid()) {
49 SkDebugf("Couldn't open output file for writing: %s\n", FLAGS_output [0]);
50 return kIOError;
51 }
52 outStream.reset(fileStream);
53 } else {
54 outStream.reset(SkNEW(SkDebugWStream));
55 }
56
57 SkISize size = pic->cullRect().roundOut().size();
58 SkAutoTUnref<SkBaseDevice> svgDevice(SkSVGDevice::Create(size, outStream));
59 SkCanvas svgCanvas(svgDevice.get());
60
61 pic->playback(&svgCanvas);
62
63 return kSuccess;
64 }
65
66 #if !defined SK_BUILD_FOR_IOS
67 int main(int argc, char * const argv[]) {
68 return tool_main(argc, (char**) argv);
69 }
70 #endif
OLDNEW
« no previous file with comments | « experimental/svg/SkSVGDevice.cpp ('k') | gyp/tools.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698