| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * Given a SkPicture, write a one-page PDF document to the given | 161 * Given a SkPicture, write a one-page PDF document to the given |
| 162 * output, using the provided encoder. | 162 * output, using the provided encoder. |
| 163 */ | 163 */ |
| 164 static bool pdf_to_stream(SkPicture* picture, | 164 static bool pdf_to_stream(SkPicture* picture, |
| 165 SkWStream* output, | 165 SkWStream* output, |
| 166 SkPicture::EncodeBitmap encoder) { | 166 SkPicture::EncodeBitmap encoder) { |
| 167 SkAutoTUnref<SkDocument> pdfDocument( | 167 SkAutoTUnref<SkDocument> pdfDocument( |
| 168 SkDocument::CreatePDF(output, NULL, encoder)); | 168 SkDocument::CreatePDF(output, NULL, encoder)); |
| 169 SkCanvas* canvas = pdfDocument->beginPage( | 169 SkCanvas* canvas = pdfDocument->beginPage(picture->cullRect().width(), |
| 170 SkIntToScalar(picture->width()), | 170 picture->cullRect().height()); |
| 171 SkIntToScalar(picture->height())); | |
| 172 canvas->drawPicture(picture); | 171 canvas->drawPicture(picture); |
| 173 canvas->flush(); | 172 canvas->flush(); |
| 174 return pdfDocument->close(); | 173 return pdfDocument->close(); |
| 175 } | 174 } |
| 176 | 175 |
| 177 static bool operator<(const SkString& a, const SkString& b) { | 176 static bool operator<(const SkString& a, const SkString& b) { |
| 178 return strcmp(a.c_str(), b.c_str()) < 0; | 177 return strcmp(a.c_str(), b.c_str()) < 0; |
| 179 } | 178 } |
| 180 | 179 |
| 181 /** | 180 /** |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 247 } |
| 249 | 248 |
| 250 SkAutoTUnref<SkPicture> picture( | 249 SkAutoTUnref<SkPicture> picture( |
| 251 SkPicture::CreateFromStream(&inputStream)); | 250 SkPicture::CreateFromStream(&inputStream)); |
| 252 if (NULL == picture.get()) { | 251 if (NULL == picture.get()) { |
| 253 SkDebugf("Could not read an SkPicture from %s\n", | 252 SkDebugf("Could not read an SkPicture from %s\n", |
| 254 files[i].c_str()); | 253 files[i].c_str()); |
| 255 ++failures; | 254 ++failures; |
| 256 continue; | 255 continue; |
| 257 } | 256 } |
| 258 SkDebugf("[%-4i %6i] %-*s", picture->width(), picture->height(), | 257 SkDebugf("[%f,%f,%f,%f] %-*s", |
| 259 maximumPathLength, basename.c_str()); | 258 picture->cullRect().fLeft, picture->cullRect().fTop, |
| 259 picture->cullRect().fRight, picture->cullRect().fBottom, |
| 260 maximumPathLength, basename.c_str()); |
| 260 | 261 |
| 261 SkAutoTDelete<SkWStream> stream(open_stream(outputDir, files[i])); | 262 SkAutoTDelete<SkWStream> stream(open_stream(outputDir, files[i])); |
| 262 if (!stream.get()) { | 263 if (!stream.get()) { |
| 263 ++failures; | 264 ++failures; |
| 264 continue; | 265 continue; |
| 265 } | 266 } |
| 266 if (!pdf_to_stream(picture, stream.get(), encode_to_dct_data)) { | 267 if (!pdf_to_stream(picture, stream.get(), encode_to_dct_data)) { |
| 267 SkDebugf("Error in PDF Serialization."); | 268 SkDebugf("Error in PDF Serialization."); |
| 268 ++failures; | 269 ++failures; |
| 269 } | 270 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 297 return -1; | 298 return -1; |
| 298 } | 299 } |
| 299 #endif | 300 #endif |
| 300 return 0; | 301 return 0; |
| 301 } | 302 } |
| 302 #if !defined SK_BUILD_FOR_IOS | 303 #if !defined SK_BUILD_FOR_IOS |
| 303 int main(int argc, char * const argv[]) { | 304 int main(int argc, char * const argv[]) { |
| 304 return tool_main(argc, (char**) argv); | 305 return tool_main(argc, (char**) argv); |
| 305 } | 306 } |
| 306 #endif | 307 #endif |
| OLD | NEW |