OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
11 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
12 #include "SkImageDecoder.h" | |
13 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
14 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
15 #include "SkPicture.h" | 14 #include "SkPicture.h" |
16 #include "SkStream.h" | 15 #include "SkStream.h" |
17 #include "SkTArray.h" | 16 #include "SkTArray.h" |
18 #include "PdfRenderer.h" | 17 #include "PdfRenderer.h" |
19 #include "picture_utils.h" | 18 #include "picture_utils.h" |
20 | 19 |
21 __SK_FORCE_IMAGE_DECODER_LINKING; | 20 __SK_FORCE_IMAGE_DECODER_LINKING; |
22 | 21 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 SkString inputFilename; | 161 SkString inputFilename; |
163 sk_tools::get_basename(&inputFilename, inputPath); | 162 sk_tools::get_basename(&inputFilename, inputPath); |
164 | 163 |
165 SkFILEStream inputStream; | 164 SkFILEStream inputStream; |
166 inputStream.setPath(inputPath.c_str()); | 165 inputStream.setPath(inputPath.c_str()); |
167 if (!inputStream.isValid()) { | 166 if (!inputStream.isValid()) { |
168 SkDebugf("Could not open file %s\n", inputPath.c_str()); | 167 SkDebugf("Could not open file %s\n", inputPath.c_str()); |
169 return false; | 168 return false; |
170 } | 169 } |
171 | 170 |
172 bool success = false; | 171 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream)); |
173 SkAutoTUnref<SkPicture> | |
174 picture(SkNEW_ARGS(SkPicture, (&inputStream, &success, &SkImageDecoder::
DecodeMemory))); | |
175 | 172 |
176 if (!success) { | 173 if (NULL == picture.get()) { |
177 SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); | 174 SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); |
178 return false; | 175 return false; |
179 } | 176 } |
180 | 177 |
181 SkDebugf("exporting... [%i %i] %s\n", picture->width(), picture->height(), | 178 SkDebugf("exporting... [%i %i] %s\n", picture->width(), picture->height(), |
182 inputPath.c_str()); | 179 inputPath.c_str()); |
183 | 180 |
184 renderer.init(picture); | 181 renderer.init(picture); |
185 | 182 |
186 renderer.render(); | 183 renderer.render(); |
187 | 184 |
188 success = write_output(outputDir, inputFilename, renderer); | 185 bool success = write_output(outputDir, inputFilename, renderer); |
189 | 186 |
190 renderer.end(); | 187 renderer.end(); |
191 return success; | 188 return success; |
192 } | 189 } |
193 | 190 |
194 /** For each file in the directory or for the file passed in input, call | 191 /** For each file in the directory or for the file passed in input, call |
195 * render_pdf. | 192 * render_pdf. |
196 * @param input A directory or an skp file. | 193 * @param input A directory or an skp file. |
197 * @param outputDir Output dir. | 194 * @param outputDir Output dir. |
198 * @param renderer The object responsible to render the skp object into pdf. | 195 * @param renderer The object responsible to render the skp object into pdf. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 298 } |
302 #endif | 299 #endif |
303 return 0; | 300 return 0; |
304 } | 301 } |
305 | 302 |
306 #if !defined SK_BUILD_FOR_IOS | 303 #if !defined SK_BUILD_FOR_IOS |
307 int main(int argc, char * const argv[]) { | 304 int main(int argc, char * const argv[]) { |
308 return tool_main(argc, (char**) argv); | 305 return tool_main(argc, (char**) argv); |
309 } | 306 } |
310 #endif | 307 #endif |
OLD | NEW |