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 "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkForceLinking.h" | 11 #include "SkForceLinking.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
14 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
16 #include "SkPixelRef.h" | 16 #include "SkPixelRef.h" |
17 #include "SkStream.h" | 17 #include "SkStream.h" |
18 #include "SkTArray.h" | 18 #include "SkTArray.h" |
19 #include "SkTSort.h" | 19 #include "SkTSort.h" |
20 #include "PdfRenderer.h" | 20 #include "PdfRenderer.h" |
21 #include "ProcStats.h" | |
22 #include "picture_utils.h" | 21 #include "picture_utils.h" |
23 | 22 |
24 __SK_FORCE_IMAGE_DECODER_LINKING; | 23 __SK_FORCE_IMAGE_DECODER_LINKING; |
25 | 24 |
26 #ifdef SK_USE_CDB | 25 #ifdef SK_USE_CDB |
27 #include "win_dbghelp.h" | 26 #include "win_dbghelp.h" |
28 #endif | 27 #endif |
29 | 28 |
30 /** | 29 /** |
31 * render_pdfs | 30 * render_pdfs |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 files.push_back( | 212 files.push_back( |
214 SkOSPath::Join(input, inputFilename.c_str())); | 213 SkOSPath::Join(input, inputFilename.c_str())); |
215 } | 214 } |
216 } | 215 } |
217 } else { | 216 } else { |
218 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, input)) { | 217 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, input)) { |
219 files.push_back(SkString(input)); | 218 files.push_back(SkString(input)); |
220 } | 219 } |
221 } | 220 } |
222 } | 221 } |
223 if (files.count() > 0) { | 222 SkTQSort<SkString>(files.begin(), files.end() - 1); |
224 SkTQSort<SkString>(files.begin(), files.end() - 1); | |
225 } | |
226 int failures = 0; | 223 int failures = 0; |
227 for (int i = 0; i < files.count(); i ++) { | 224 for (int i = 0; i < files.count(); i ++) { |
228 if (!render_pdf(files[i], outputDir, renderer)) { | 225 if (!render_pdf(files[i], outputDir, renderer)) { |
229 ++failures; | 226 ++failures; |
230 } | 227 } |
231 } | 228 } |
232 return failures; | 229 return failures; |
233 } | 230 } |
234 | 231 |
235 int tool_main_core(int argc, char** argv); | 232 int tool_main_core(int argc, char** argv); |
236 int tool_main_core(int argc, char** argv) { | 233 int tool_main_core(int argc, char** argv) { |
237 SkCommandLineFlags::Parse(argc, argv); | 234 SkCommandLineFlags::Parse(argc, argv); |
238 | 235 |
239 SkAutoGraphics ag; | 236 SkAutoGraphics ag; |
240 | 237 |
241 SkAutoTUnref<sk_tools::PdfRenderer> | 238 SkAutoTUnref<sk_tools::PdfRenderer> |
242 renderer(SkNEW_ARGS(sk_tools::SimplePdfRenderer, (encode_to_dct_data))); | 239 renderer(SkNEW_ARGS(sk_tools::SimplePdfRenderer, (encode_to_dct_data))); |
243 SkASSERT(renderer.get()); | 240 SkASSERT(renderer.get()); |
244 | 241 |
245 SkString outputDir; | 242 SkString outputDir; |
246 if (FLAGS_outputDir.count() > 0) { | 243 if (FLAGS_outputDir.count() > 0) { |
247 outputDir = FLAGS_outputDir[0]; | 244 outputDir = FLAGS_outputDir[0]; |
248 } | 245 } |
249 | 246 |
250 int failures = process_input(FLAGS_inputPaths, outputDir, *renderer); | 247 int failures = process_input(FLAGS_inputPaths, outputDir, *renderer); |
251 | 248 |
252 int max_rss_kb = sk_tools::getMaxResidentSetSizeKB(); | |
253 if (max_rss_kb >= 0) { | |
254 SkDebugf("%4dM peak ResidentSetSize\n", max_rss_kb / 1024); | |
255 } | |
256 | |
257 if (failures != 0) { | 249 if (failures != 0) { |
258 SkDebugf("Failed to render %i PDFs.\n", failures); | 250 SkDebugf("Failed to render %i PDFs.\n", failures); |
259 return 1; | 251 return 1; |
260 } | 252 } |
261 | 253 |
262 return 0; | 254 return 0; |
263 } | 255 } |
264 | 256 |
265 int tool_main(int argc, char** argv); | 257 int tool_main(int argc, char** argv); |
266 int tool_main(int argc, char** argv) { | 258 int tool_main(int argc, char** argv) { |
(...skipping 10 matching lines...) Expand all Loading... |
277 } | 269 } |
278 #endif | 270 #endif |
279 return 0; | 271 return 0; |
280 } | 272 } |
281 | 273 |
282 #if !defined SK_BUILD_FOR_IOS | 274 #if !defined SK_BUILD_FOR_IOS |
283 int main(int argc, char * const argv[]) { | 275 int main(int argc, char * const argv[]) { |
284 return tool_main(argc, (char**) argv); | 276 return tool_main(argc, (char**) argv); |
285 } | 277 } |
286 #endif | 278 #endif |
OLD | NEW |