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

Side by Side Diff: experimental/PdfViewer/pdf_viewer_main.cpp

Issue 80463005: Separate and update PDF_DIFF_TRACE_IN_PNG (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCommandLineFlags.h" 10 #include "SkCommandLineFlags.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkGraphics.h" 12 #include "SkGraphics.h"
13 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
14 #include "SkImageEncoder.h" 14 #include "SkImageEncoder.h"
15 #include "SkOSFile.h" 15 #include "SkOSFile.h"
16 #include "SkPdfConfig.h"
16 #include "SkPdfRenderer.h" 17 #include "SkPdfRenderer.h"
17 #include "SkPicture.h" 18 #include "SkPicture.h"
18 #include "SkStream.h" 19 #include "SkStream.h"
19 #include "SkTypeface.h" 20 #include "SkTypeface.h"
20 #include "SkTArray.h" 21 #include "SkTArray.h"
21 #include "SkNulCanvas.h" 22 #include "SkNulCanvas.h"
22 23
23 #if SK_SUPPORT_GPU 24 #if SK_SUPPORT_GPU
24 #include "GrContextFactory.h" 25 #include "GrContextFactory.h"
25 #include "GrContext.h" 26 #include "GrContext.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 bitmap->eraseColor(color); 116 bitmap->eraseColor(color);
116 } 117 }
117 118
118 /** Write the output of pdf renderer to a file. 119 /** Write the output of pdf renderer to a file.
119 * @param outputDir Output dir. 120 * @param outputDir Output dir.
120 * @param inputFilename The skp file that was read. 121 * @param inputFilename The skp file that was read.
121 * @param renderer The object responsible to write the pdf file. 122 * @param renderer The object responsible to write the pdf file.
122 * @param page -1 means there is only one page (0), and render in a file without page extension 123 * @param page -1 means there is only one page (0), and render in a file without page extension
123 */ 124 */
124 125
126 #ifdef PDF_TRACE_DIFF_IN_PNG
125 extern "C" SkBitmap* gDumpBitmap; 127 extern "C" SkBitmap* gDumpBitmap;
126 extern "C" SkCanvas* gDumpCanvas; 128 extern "C" SkCanvas* gDumpCanvas;
129 #endif
127 130
128 #if SK_SUPPORT_GPU 131 #if SK_SUPPORT_GPU
129 GrContextFactory gContextFactory; 132 GrContextFactory gContextFactory;
130 #endif 133 #endif
131 134
132 static bool render_page(const SkString& outputDir, 135 static bool render_page(const SkString& outputDir,
133 const SkString& inputFilename, 136 const SkString& inputFilename,
134 const SkPdfRenderer& renderer, 137 const SkPdfRenderer& renderer,
135 int page) { 138 int page) {
136 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); 139 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 188
186 device.reset(SkGpuDevice::Create(target)); 189 device.reset(SkGpuDevice::Create(target));
187 } 190 }
188 #endif 191 #endif
189 else { 192 else {
190 SkDebugf("unknown --config: %s\n", FLAGS_config[0]); 193 SkDebugf("unknown --config: %s\n", FLAGS_config[0]);
191 return false; 194 return false;
192 } 195 }
193 SkCanvas canvas(device); 196 SkCanvas canvas(device);
194 197
198 #ifdef PDF_TRACE_DIFF_IN_PNG
195 gDumpBitmap = &bitmap; 199 gDumpBitmap = &bitmap;
196
197 gDumpCanvas = &canvas; 200 gDumpCanvas = &canvas;
201 #endif
198 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); 202 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
199 203
200 SkString outputPath; 204 SkString outputPath;
201 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) { 205 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) {
202 return false; 206 return false;
203 } 207 }
204 SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::k PNG_Type, 100); 208 SkImageEncoder::EncodeFile(outputPath.c_str(), bitmap, SkImageEncoder::k PNG_Type, 100);
205 209
206 if (FLAGS_showMemoryUsage) { 210 if (FLAGS_showMemoryUsage) {
207 SkDebugf("Memory usage after page %i rendered: %u\n", 211 SkDebugf("Memory usage after page %i rendered: %u\n",
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 342 }
339 343
340 return 0; 344 return 0;
341 } 345 }
342 346
343 #if !defined SK_BUILD_FOR_IOS 347 #if !defined SK_BUILD_FOR_IOS
344 int main(int argc, char * const argv[]) { 348 int main(int argc, char * const argv[]) {
345 return tool_main(argc, (char**) argv); 349 return tool_main(argc, (char**) argv);
346 } 350 }
347 #endif 351 #endif
OLDNEW
« no previous file with comments | « experimental/PdfViewer/inc/SkPdfTokenLooper.h ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698