pdfviewer: render in the same way regadless if we write the result to a file or not.
Review URL: https://codereview.chromium.org/18503013
git-svn-id: http://skia.googlecode.com/svn/trunk@10008 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp
index 14c29ca..a28e561 100644
--- a/experimental/PdfViewer/pdf_viewer_main.cpp
+++ b/experimental/PdfViewer/pdf_viewer_main.cpp
@@ -28,7 +28,6 @@
// TODO(edisonn): add config for device target(gpu, raster, pdf), + ability not to render at all
// TODO(edisonn): add ability to do the op N times, bench (either load N times, render n times or load + render n times)
-
/**
* Given list of directories and files to use as input, expects to find .pdf
* files and it will convert them to .png files writing them in the same directory
@@ -98,23 +97,13 @@
* @param page -1 means there is only one page (0), and render in a file without page extension
*/
+extern "C" SkBitmap* gDumpBitmap;
+extern "C" SkCanvas* gDumpCanvas;
+
static bool render_page(const SkString& outputDir,
const SkString& inputFilename,
const SkPdfRenderer& renderer,
int page) {
- if (outputDir.isEmpty()) {
- SkBitmap bitmap;
- setup_bitmap(&bitmap, 1, 1);
- SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap)));
- SkCanvas canvas(device);
- return renderer.renderPage(page < 0 ? 0 : page, &canvas);
- }
-
- SkString outputPath;
- if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) {
- return false;
- }
-
SkRect rect = renderer.MediaBox(page < 0 ? 0 :page);
SkBitmap bitmap;
@@ -131,6 +120,10 @@
gDumpCanvas = &canvas;
renderer.renderPage(page < 0 ? 0 : page, &canvas);
+ SkString outputPath;
+ if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) {
+ return false;
+ }
SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
if (FLAGS_showMemoryUsage) {