| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 static bool render_page(const SkString& outputDir, | 180 static bool render_page(const SkString& outputDir, |
| 181 const SkString& inputFilename, | 181 const SkString& inputFilename, |
| 182 const SkPdfRenderer& renderer, | 182 const SkPdfRenderer& renderer, |
| 183 int page) { | 183 int page) { |
| 184 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 184 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
| 185 | 185 |
| 186 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. | 186 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. |
| 187 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { | 187 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { |
| 188 SkBitmap bitmap; | 188 SkBitmap bitmap; |
| 189 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); | 189 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); |
| 190 SkNulCanvas canvas(device); | 190 SkNulCanvas canvas(device); |
| 191 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); | 191 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); |
| 192 } else { | 192 } else { |
| 193 // 8888 | 193 // 8888 |
| 194 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 194 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
| 195 | 195 |
| 196 SkBitmap bitmap; | 196 SkBitmap bitmap; |
| 197 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(sqrt(FLAGS_
DPI / 72.0))); | 197 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(sqrt(FLAGS_
DPI / 72.0))); |
| 198 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(sqrt(FLAG
S_DPI / 72.0))); | 198 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(sqrt(FLAG
S_DPI / 72.0))); |
| 199 | 199 |
| 200 rect = SkRect::MakeWH(width, height); | 200 rect = SkRect::MakeWH(width, height); |
| 201 | 201 |
| 202 #ifdef PDF_DEBUG_3X | 202 #ifdef PDF_DEBUG_3X |
| 203 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height)); | 203 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height)); |
| 204 #else | 204 #else |
| 205 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height)); | 205 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height)); |
| 206 #endif | 206 #endif |
| 207 SkAutoTUnref<SkDevice> device; | 207 SkAutoTUnref<SkBaseDevice> device; |
| 208 if (strcmp(FLAGS_config[0], "8888") == 0) { | 208 if (strcmp(FLAGS_config[0], "8888") == 0) { |
| 209 device.reset(SkNEW_ARGS(SkDevice, (bitmap))); | 209 device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap))); |
| 210 } | 210 } |
| 211 #if SK_SUPPORT_GPU | 211 #if SK_SUPPORT_GPU |
| 212 else if (strcmp(FLAGS_config[0], "gpu") == 0) { | 212 else if (strcmp(FLAGS_config[0], "gpu") == 0) { |
| 213 SkAutoTUnref<GrSurface> target; | 213 SkAutoTUnref<GrSurface> target; |
| 214 GrContext* gr = gContextFactory.get(GrContextFactory::kNative_GLCont
extType); | 214 GrContext* gr = gContextFactory.get(GrContextFactory::kNative_GLCont
extType); |
| 215 if (gr) { | 215 if (gr) { |
| 216 // create a render target to back the device | 216 // create a render target to back the device |
| 217 GrTextureDesc desc; | 217 GrTextureDesc desc; |
| 218 desc.fConfig = kSkia8888_GrPixelConfig; | 218 desc.fConfig = kSkia8888_GrPixelConfig; |
| 219 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 219 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 379 } |
| 380 | 380 |
| 381 return 0; | 381 return 0; |
| 382 } | 382 } |
| 383 | 383 |
| 384 #if !defined SK_BUILD_FOR_IOS | 384 #if !defined SK_BUILD_FOR_IOS |
| 385 int main(int argc, char * const argv[]) { | 385 int main(int argc, char * const argv[]) { |
| 386 return tool_main(argc, (char**) argv); | 386 return tool_main(argc, (char**) argv); |
| 387 } | 387 } |
| 388 #endif | 388 #endif |
| OLD | NEW |