Index: experimental/PdfViewer/pdf_viewer_main.cpp |
=================================================================== |
--- experimental/PdfViewer/pdf_viewer_main.cpp (revision 11671) |
+++ experimental/PdfViewer/pdf_viewer_main.cpp (working copy) |
@@ -12,6 +12,7 @@ |
#include "SkImageDecoder.h" |
#include "SkImageEncoder.h" |
#include "SkOSFile.h" |
+#include "SkPdfRenderer.h" |
#include "SkPicture.h" |
#include "SkStream.h" |
#include "SkTypeface.h" |
@@ -24,8 +25,6 @@ |
#include "SkGpuDevice.h" |
#endif |
-#include "SkPdfRenderer.h" |
- |
DEFINE_string2(readPath, r, "", "pdf files or directories of pdf files to process."); |
DEFINE_string2(writePath, w, "", "Directory to write the rendered pages."); |
DEFINE_bool2(noExtensionForOnePagePdf, n, false, "No page extension if only one page."); |
@@ -43,7 +42,6 @@ |
DEFINE_int32(benchRender, 0, "Render the pdf content N times. Default 0 (disabled)"); |
DEFINE_string2(config, c, "8888", "Canvas to render:\n" |
"\t8888 - argb\n" |
- |
#if SK_SUPPORT_GPU |
"\tgpu: use the gpu\n" |
#endif |
@@ -51,9 +49,6 @@ |
); |
DEFINE_bool2(transparentBackground, t, false, "Make background transparent instead of white."); |
- |
-// TODO(edisonn): add config for device target(gpu, raster, pdf), + ability not to render at all |
- |
/** |
* 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 |
@@ -203,9 +198,11 @@ |
SkColor background = FLAGS_transparentBackground ? SK_ColorTRANSPARENT : SK_ColorWHITE; |
#ifdef PDF_DEBUG_3X |
- setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScalarToDouble(height), background); |
+ setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScalarToDouble(height), |
+ background); |
#else |
- setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height), background); |
+ setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height), |
+ background); |
#endif |
SkAutoTUnref<SkBaseDevice> device; |
if (strcmp(FLAGS_config[0], "8888") == 0) { |
@@ -251,7 +248,8 @@ |
SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100); |
if (FLAGS_showMemoryUsage) { |
- SkDebugf("Memory usage after page %i rendered: %u\n", page < 0 ? 0 : page, (unsigned int)renderer.bytesUsed()); |
+ SkDebugf("Memory usage after page %i rendered: %u\n", |
+ page < 0 ? 0 : page, (unsigned int)renderer.bytesUsed()); |
} |
} |
return true; |
@@ -281,7 +279,8 @@ |
for (int i = 0 ; i < FLAGS_benchLoad; i++) { |
success = renderer.load(inputPath) && success; |
if (FLAGS_showMemoryUsage) { |
- SkDebugf("Memory usage after load %i number : %u\n", i, (unsigned int)renderer.bytesUsed()); |
+ SkDebugf("Memory usage after load %i number : %u\n", i, |
+ (unsigned int)renderer.bytesUsed()); |
} |
} |
} |
@@ -296,19 +295,43 @@ |
// TODO(edisonn) if (i == 1) start timer |
if (strcmp(FLAGS_pages[0], "all") == 0) { |
for (int pn = 0; pn < renderer.pages(); ++pn) { |
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : pn) && success; |
+ success = render_page( |
+ outputDir, |
+ inputFilename, |
+ renderer, |
+ FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : |
+ pn) && |
+ success; |
} |
} else if (strcmp(FLAGS_pages[0], "reverse") == 0) { |
for (int pn = renderer.pages() - 1; pn >= 0; --pn) { |
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : pn) && success; |
+ success = render_page( |
+ outputDir, |
+ inputFilename, |
+ renderer, |
+ FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : |
+ pn) && |
+ success; |
} |
} else if (strcmp(FLAGS_pages[0], "first") == 0) { |
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : 0) && success; |
+ success = render_page( |
+ outputDir, |
+ inputFilename, |
+ renderer, |
+ FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : 0) && |
+ success; |
} else if (strcmp(FLAGS_pages[0], "last") == 0) { |
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : renderer.pages() - 1) && success; |
+ success = render_page( |
+ outputDir, |
+ inputFilename, |
+ renderer, |
+ FLAGS_noExtensionForOnePagePdf && |
+ renderer.pages() == 1 ? -1 : renderer.pages() - 1) && success; |
} else { |
int pn = atoi(FLAGS_pages[0]); |
- success = render_page(outputDir, inputFilename, renderer, FLAGS_noExtensionForOnePagePdf && renderer.pages() == 1 ? -1 : pn) && success; |
+ success = render_page(outputDir, inputFilename, renderer, |
+ FLAGS_noExtensionForOnePagePdf && |
+ renderer.pages() == 1 ? -1 : pn) && success; |
} |
} |
} |