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

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

Issue 1204433002: Begin kLegacyFontHost_InitType cleanup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add dox Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « experimental/PdfViewer/SkTrackDevice.h ('k') | experimental/PdfViewer/src/SkPdfRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
9 #include "SkCanvas.h" 8 #include "SkCanvas.h"
10 #include "SkCommandLineFlags.h" 9 #include "SkCommandLineFlags.h"
11 #include "SkDevice.h" 10 #include "SkDevice.h"
12 #include "SkGraphics.h" 11 #include "SkGraphics.h"
13 #include "SkImageDecoder.h" 12 #include "SkImageDecoder.h"
14 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
15 #include "SkOSFile.h" 14 #include "SkOSFile.h"
16 #include "SkPdfConfig.h" 15 #include "SkPdfConfig.h"
17 #include "SkPdfRenderer.h" 16 #include "SkPdfRenderer.h"
18 #include "SkPicture.h" 17 #include "SkPicture.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 113
115 static bool render_page(const SkString& outputDir, 114 static bool render_page(const SkString& outputDir,
116 const SkString& inputFilename, 115 const SkString& inputFilename,
117 const SkPdfRenderer& renderer, 116 const SkPdfRenderer& renderer,
118 int page) { 117 int page) {
119 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); 118 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page);
120 119
121 // Exercise all pdf codepaths as in normal rendering, but no actual bits are changed. 120 // Exercise all pdf codepaths as in normal rendering, but no actual bits are changed.
122 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { 121 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) {
123 SkBitmap bitmap; 122 SkBitmap bitmap;
124 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); 123 SkNulCanvas canvas(bitmap);
125 SkNulCanvas canvas(device);
126 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); 124 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
127 } else { 125 } else {
128 // 8888 126 // 8888
129 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); 127 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page);
130 128
131 SkBitmap bitmap; 129 SkBitmap bitmap;
132 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(FLAGS_DPI / 72.0)); 130 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(FLAGS_DPI / 72.0));
133 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(FLAGS_DPI / 72.0)); 131 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(FLAGS_DPI / 72.0));
134 132
135 rect = SkRect::MakeWH(width, height); 133 rect = SkRect::MakeWH(width, height);
136 134
137 SkColor background = FLAGS_transparentBackground ? SK_ColorTRANSPARENT : SK_ColorWHITE; 135 SkColor background = FLAGS_transparentBackground ? SK_ColorTRANSPARENT : SK_ColorWHITE;
138 136
139 #ifdef PDF_DEBUG_3X 137 #ifdef PDF_DEBUG_3X
140 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala rToDouble(height), 138 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala rToDouble(height),
141 background); 139 background);
142 #else 140 #else
143 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl e(height), 141 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl e(height),
144 background); 142 background);
145 #endif 143 #endif
146 SkAutoTUnref<SkBaseDevice> device; 144 if (strcmp(FLAGS_config[0], "8888") != 0) {
147 if (strcmp(FLAGS_config[0], "8888") == 0) {
148 device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
149 } else {
150 SkDebugf("unknown --config: %s\n", FLAGS_config[0]); 145 SkDebugf("unknown --config: %s\n", FLAGS_config[0]);
151 return false; 146 return false;
152 } 147 }
153 SkCanvas canvas(device); 148 SkCanvas canvas(bitmap);
154 149
155 #ifdef PDF_TRACE_DIFF_IN_PNG 150 #ifdef PDF_TRACE_DIFF_IN_PNG
156 gDumpBitmap = &bitmap; 151 gDumpBitmap = &bitmap;
157 gDumpCanvas = &canvas; 152 gDumpCanvas = &canvas;
158 #endif 153 #endif
159 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); 154 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
160 155
161 SkString outputPath; 156 SkString outputPath;
162 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) { 157 if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) {
163 return false; 158 return false;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 294 }
300 295
301 return 0; 296 return 0;
302 } 297 }
303 298
304 #if !defined SK_BUILD_FOR_IOS 299 #if !defined SK_BUILD_FOR_IOS
305 int main(int argc, char * const argv[]) { 300 int main(int argc, char * const argv[]) {
306 return tool_main(argc, (char**) argv); 301 return tool_main(argc, (char**) argv);
307 } 302 }
308 #endif 303 #endif
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkTrackDevice.h ('k') | experimental/PdfViewer/src/SkPdfRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698