Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: experimental/PdfViewer/pdf_viewer_main.cpp

Issue 18503013: pdfviewer: render in the same way regadless if we write the result to a file or not. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/pdf_viewer_main.cpp
===================================================================
--- experimental/PdfViewer/pdf_viewer_main.cpp (revision 10006)
+++ experimental/PdfViewer/pdf_viewer_main.cpp (working copy)
@@ -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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698