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 "SkDocument.h" | 10 #include "SkDocument.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 * @param renderer The object responsible to write the pdf file. | 113 * @param renderer The object responsible to write the pdf file. |
114 */ | 114 */ |
115 static SkWStream* open_stream(const SkString& outputDir, | 115 static SkWStream* open_stream(const SkString& outputDir, |
116 const SkString& inputFilename) { | 116 const SkString& inputFilename) { |
117 if (outputDir.isEmpty()) { | 117 if (outputDir.isEmpty()) { |
118 return new NullWStream; | 118 return new NullWStream; |
119 } | 119 } |
120 | 120 |
121 SkString outputPath; | 121 SkString outputPath; |
122 if (!make_output_filepath(&outputPath, outputDir, inputFilename)) { | 122 if (!make_output_filepath(&outputPath, outputDir, inputFilename)) { |
123 return NULL; | 123 return nullptr; |
124 } | 124 } |
125 | 125 |
126 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(outputPath.c_str())); | 126 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(outputPath.c_str())); |
127 if (!stream.get() || !stream->isValid()) { | 127 if (!stream.get() || !stream->isValid()) { |
128 SkDebugf("Could not write to file %s\n", outputPath.c_str()); | 128 SkDebugf("Could not write to file %s\n", outputPath.c_str()); |
129 return NULL; | 129 return nullptr; |
130 } | 130 } |
131 | 131 |
132 return stream.detach(); | 132 return stream.detach(); |
133 } | 133 } |
134 | 134 |
135 /** | 135 /** |
136 * Given a SkPicture, write a one-page PDF document to the given | 136 * Given a SkPicture, write a one-page PDF document to the given |
137 * output, using the provided encoder. | 137 * output, using the provided encoder. |
138 */ | 138 */ |
139 static bool pdf_to_stream(SkPicture* picture, | 139 static bool pdf_to_stream(SkPicture* picture, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 SkFILEStream inputStream; | 215 SkFILEStream inputStream; |
216 inputStream.setPath(files[i].c_str()); | 216 inputStream.setPath(files[i].c_str()); |
217 if (!inputStream.isValid()) { | 217 if (!inputStream.isValid()) { |
218 SkDebugf("Could not open file %s\n", files[i].c_str()); | 218 SkDebugf("Could not open file %s\n", files[i].c_str()); |
219 ++failures; | 219 ++failures; |
220 continue; | 220 continue; |
221 } | 221 } |
222 | 222 |
223 SkAutoTUnref<SkPicture> picture( | 223 SkAutoTUnref<SkPicture> picture( |
224 SkPicture::CreateFromStream(&inputStream)); | 224 SkPicture::CreateFromStream(&inputStream)); |
225 if (NULL == picture.get()) { | 225 if (nullptr == picture.get()) { |
226 SkDebugf("Could not read an SkPicture from %s\n", | 226 SkDebugf("Could not read an SkPicture from %s\n", |
227 files[i].c_str()); | 227 files[i].c_str()); |
228 ++failures; | 228 ++failures; |
229 continue; | 229 continue; |
230 } | 230 } |
231 SkDebugf("[%6g %6g %6g %6g] %-*s", | 231 SkDebugf("[%6g %6g %6g %6g] %-*s", |
232 picture->cullRect().fLeft, picture->cullRect().fTop, | 232 picture->cullRect().fLeft, picture->cullRect().fTop, |
233 picture->cullRect().fRight, picture->cullRect().fBottom, | 233 picture->cullRect().fRight, picture->cullRect().fBottom, |
234 maximumPathLength, basename.c_str()); | 234 maximumPathLength, basename.c_str()); |
235 | 235 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 return -1; | 272 return -1; |
273 } | 273 } |
274 #endif | 274 #endif |
275 return 0; | 275 return 0; |
276 } | 276 } |
277 #if !defined SK_BUILD_FOR_IOS | 277 #if !defined SK_BUILD_FOR_IOS |
278 int main(int argc, char * const argv[]) { | 278 int main(int argc, char * const argv[]) { |
279 return tool_main(argc, (char**) argv); | 279 return tool_main(argc, (char**) argv); |
280 } | 280 } |
281 #endif | 281 #endif |
OLD | NEW |