OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
11 #include "SkStream.h" | 11 #include "SkStream.h" |
12 #include "SkSVGDevice.h" | 12 #include "SkSVGCanvas.h" |
| 13 #include "SkXMLWriter.h" |
13 | 14 |
14 DEFINE_string2(input, i, "", "input skp file"); | 15 DEFINE_string2(input, i, "", "input skp file"); |
15 DEFINE_string2(output, o, "", "output svg file (optional)"); | 16 DEFINE_string2(output, o, "", "output svg file (optional)"); |
16 | 17 |
17 // return codes: | 18 // return codes: |
18 static const int kSuccess = 0; | 19 static const int kSuccess = 0; |
19 static const int kInvalidArgs = 1; | 20 static const int kInvalidArgs = 1; |
20 static const int kIOError = 2; | 21 static const int kIOError = 2; |
21 static const int kNotAnSKP = 3; | 22 static const int kNotAnSKP = 3; |
22 | 23 |
(...skipping 24 matching lines...) Expand all Loading... |
47 SkFILEWStream* fileStream = SkNEW_ARGS(SkFILEWStream, (FLAGS_output[0]))
; | 48 SkFILEWStream* fileStream = SkNEW_ARGS(SkFILEWStream, (FLAGS_output[0]))
; |
48 if (!fileStream->isValid()) { | 49 if (!fileStream->isValid()) { |
49 SkDebugf("Couldn't open output file for writing: %s\n", FLAGS_output
[0]); | 50 SkDebugf("Couldn't open output file for writing: %s\n", FLAGS_output
[0]); |
50 return kIOError; | 51 return kIOError; |
51 } | 52 } |
52 outStream.reset(fileStream); | 53 outStream.reset(fileStream); |
53 } else { | 54 } else { |
54 outStream.reset(SkNEW(SkDebugWStream)); | 55 outStream.reset(SkNEW(SkDebugWStream)); |
55 } | 56 } |
56 | 57 |
57 SkISize size = pic->cullRect().roundOut().size(); | 58 SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (outStrea
m.get()))); |
58 SkAutoTUnref<SkBaseDevice> svgDevice(SkSVGDevice::Create(size, outStream)); | 59 SkAutoTUnref<SkCanvas> svgCanvas(SkSVGCanvas::Create(pic->cullRect(), xmlWri
ter.get())); |
59 SkCanvas svgCanvas(svgDevice.get()); | |
60 | 60 |
61 pic->playback(&svgCanvas); | 61 pic->playback(svgCanvas); |
62 | 62 |
63 return kSuccess; | 63 return kSuccess; |
64 } | 64 } |
65 | 65 |
66 #if !defined SK_BUILD_FOR_IOS | 66 #if !defined SK_BUILD_FOR_IOS |
67 int main(int argc, char * const argv[]) { | 67 int main(int argc, char * const argv[]) { |
68 return tool_main(argc, (char**) argv); | 68 return tool_main(argc, (char**) argv); |
69 } | 69 } |
70 #endif | 70 #endif |
OLD | NEW |