| OLD | NEW |
| 1 #include "SkCanvas.h" | 1 #include "SkCanvas.h" |
| 2 #include "SkDevice.h" | 2 #include "SkDevice.h" |
| 3 #include "SkForceLinking.h" | 3 #include "SkForceLinking.h" |
| 4 #include "SkGraphics.h" | 4 #include "SkGraphics.h" |
| 5 #include "SkImageDecoder.h" | 5 #include "SkImageDecoder.h" |
| 6 #include "SkImageEncoder.h" | 6 #include "SkImageEncoder.h" |
| 7 #include "SkOSFile.h" | 7 #include "SkOSFile.h" |
| 8 #include "SkPicture.h" | 8 #include "SkPicture.h" |
| 9 #include "SkStream.h" | 9 #include "SkStream.h" |
| 10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 90 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 91 | 91 |
| 92 bitmap->allocPixels(); | 92 bitmap->allocPixels(); |
| 93 bitmap->eraseColor(color); | 93 bitmap->eraseColor(color); |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** Write the output of pdf renderer to a file. | 96 /** Write the output of pdf renderer to a file. |
| 97 * @param outputDir Output dir. | 97 * @param outputDir Output dir. |
| 98 * @param inputFilename The skp file that was read. | 98 * @param inputFilename The skp file that was read. |
| 99 * @param renderer The object responsible to write the pdf file. | 99 * @param renderer The object responsible to write the pdf file. |
| 100 * @param page -1 means there is only one page (0), and render in a file without
page extension |
| 100 */ | 101 */ |
| 101 | 102 |
| 102 static bool render_page(const SkString& outputDir, | 103 static bool render_page(const SkString& outputDir, |
| 103 const SkString& inputFilename, | 104 const SkString& inputFilename, |
| 104 const SkPdfRenderer& renderer, | 105 const SkPdfRenderer& renderer, |
| 105 int page) { | 106 int page) { |
| 106 if (outputDir.isEmpty()) { | 107 if (outputDir.isEmpty()) { |
| 107 SkBitmap bitmap; | 108 SkBitmap bitmap; |
| 108 setup_bitmap(&bitmap, 1, 1); | 109 setup_bitmap(&bitmap, 1, 1); |
| 109 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); | 110 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(rect.width()), 3 * (int)SkSc
alarToDouble(rect.height())); | 124 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(rect.width()), 3 * (int)SkSc
alarToDouble(rect.height())); |
| 124 #else | 125 #else |
| 125 setup_bitmap(&bitmap, (int)SkScalarToDouble(rect.width()), (int)SkScalarToDo
uble(rect.height())); | 126 setup_bitmap(&bitmap, (int)SkScalarToDouble(rect.width()), (int)SkScalarToDo
uble(rect.height())); |
| 126 #endif | 127 #endif |
| 127 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); | 128 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); |
| 128 SkCanvas canvas(device); | 129 SkCanvas canvas(device); |
| 129 | 130 |
| 130 gDumpBitmap = &bitmap; | 131 gDumpBitmap = &bitmap; |
| 131 | 132 |
| 132 gDumpCanvas = &canvas; | 133 gDumpCanvas = &canvas; |
| 133 renderer.renderPage(page, &canvas); | 134 renderer.renderPage(page < 0 ? 0 : page, &canvas); |
| 134 | 135 |
| 135 SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::kPNG_
Type, 100); | 136 SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::kPNG_
Type, 100); |
| 136 | 137 |
| 137 return true; | 138 return true; |
| 138 } | 139 } |
| 139 | 140 |
| 140 /** Reads an skp file, renders it to pdf and writes the output to a pdf file | 141 /** Reads an skp file, renders it to pdf and writes the output to a pdf file |
| 141 * @param inputPath The skp file to be read. | 142 * @param inputPath The skp file to be read. |
| 142 * @param outputDir Output dir. | 143 * @param outputDir Output dir. |
| 143 * @param renderer The object responsible to render the skp object into pdf. | 144 * @param renderer The object responsible to render the skp object into pdf. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 260 } |
| 260 | 261 |
| 261 return 0; | 262 return 0; |
| 262 } | 263 } |
| 263 | 264 |
| 264 #if !defined SK_BUILD_FOR_IOS | 265 #if !defined SK_BUILD_FOR_IOS |
| 265 int main(int argc, char * const argv[]) { | 266 int main(int argc, char * const argv[]) { |
| 266 return tool_main(argc, (char**) argv); | 267 return tool_main(argc, (char**) argv); |
| 267 } | 268 } |
| 268 #endif | 269 #endif |
| OLD | NEW |