| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmapDevice.h" | |
| 9 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 10 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 11 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| 12 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
| 13 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
| 14 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
| 15 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
| 16 #include "SkPdfConfig.h" | 15 #include "SkPdfConfig.h" |
| 17 #include "SkPdfRenderer.h" | 16 #include "SkPdfRenderer.h" |
| 18 #include "SkPicture.h" | 17 #include "SkPicture.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 113 |
| 115 static bool render_page(const SkString& outputDir, | 114 static bool render_page(const SkString& outputDir, |
| 116 const SkString& inputFilename, | 115 const SkString& inputFilename, |
| 117 const SkPdfRenderer& renderer, | 116 const SkPdfRenderer& renderer, |
| 118 int page) { | 117 int page) { |
| 119 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 118 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
| 120 | 119 |
| 121 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. | 120 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. |
| 122 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { | 121 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { |
| 123 SkBitmap bitmap; | 122 SkBitmap bitmap; |
| 124 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); | 123 SkNulCanvas canvas(bitmap); |
| 125 SkNulCanvas canvas(device); | |
| 126 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); | 124 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); |
| 127 } else { | 125 } else { |
| 128 // 8888 | 126 // 8888 |
| 129 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 127 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
| 130 | 128 |
| 131 SkBitmap bitmap; | 129 SkBitmap bitmap; |
| 132 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(FLAGS_DPI /
72.0)); | 130 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(FLAGS_DPI /
72.0)); |
| 133 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(FLAGS_DPI
/ 72.0)); | 131 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(FLAGS_DPI
/ 72.0)); |
| 134 | 132 |
| 135 rect = SkRect::MakeWH(width, height); | 133 rect = SkRect::MakeWH(width, height); |
| 136 | 134 |
| 137 SkColor background = FLAGS_transparentBackground ? SK_ColorTRANSPARENT :
SK_ColorWHITE; | 135 SkColor background = FLAGS_transparentBackground ? SK_ColorTRANSPARENT :
SK_ColorWHITE; |
| 138 | 136 |
| 139 #ifdef PDF_DEBUG_3X | 137 #ifdef PDF_DEBUG_3X |
| 140 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height), | 138 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height), |
| 141 background); | 139 background); |
| 142 #else | 140 #else |
| 143 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height), | 141 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height), |
| 144 background); | 142 background); |
| 145 #endif | 143 #endif |
| 146 SkAutoTUnref<SkBaseDevice> device; | 144 if (strcmp(FLAGS_config[0], "8888") != 0) { |
| 147 if (strcmp(FLAGS_config[0], "8888") == 0) { | |
| 148 device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap))); | |
| 149 } else { | |
| 150 SkDebugf("unknown --config: %s\n", FLAGS_config[0]); | 145 SkDebugf("unknown --config: %s\n", FLAGS_config[0]); |
| 151 return false; | 146 return false; |
| 152 } | 147 } |
| 153 SkCanvas canvas(device); | 148 SkCanvas canvas(bitmap); |
| 154 | 149 |
| 155 #ifdef PDF_TRACE_DIFF_IN_PNG | 150 #ifdef PDF_TRACE_DIFF_IN_PNG |
| 156 gDumpBitmap = &bitmap; | 151 gDumpBitmap = &bitmap; |
| 157 gDumpCanvas = &canvas; | 152 gDumpCanvas = &canvas; |
| 158 #endif | 153 #endif |
| 159 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); | 154 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); |
| 160 | 155 |
| 161 SkString outputPath; | 156 SkString outputPath; |
| 162 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page))
{ | 157 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page))
{ |
| 163 return false; | 158 return false; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 294 } |
| 300 | 295 |
| 301 return 0; | 296 return 0; |
| 302 } | 297 } |
| 303 | 298 |
| 304 #if !defined SK_BUILD_FOR_IOS | 299 #if !defined SK_BUILD_FOR_IOS |
| 305 int main(int argc, char * const argv[]) { | 300 int main(int argc, char * const argv[]) { |
| 306 return tool_main(argc, (char**) argv); | 301 return tool_main(argc, (char**) argv); |
| 307 } | 302 } |
| 308 #endif | 303 #endif |
| OLD | NEW |