OLD | NEW |
1 #include "SkCanvas.h" | 1 #include "SkCanvas.h" |
2 #include "SkCommandLineFlags.h" | 2 #include "SkCommandLineFlags.h" |
3 #include "SkDevice.h" | 3 #include "SkDevice.h" |
4 #include "SkGraphics.h" | 4 #include "SkGraphics.h" |
5 #include "SkImageDecoder.h" | 5 #include "SkImageDecoder.h" |
6 #include "SkImageEncoder.h" | 6 #include "SkImageEncoder.h" |
7 #include "SkOSFile.h" | 7 #include "SkOSFile.h" |
8 #include "SkPicture.h" | 8 #include "SkPicture.h" |
9 #include "SkStream.h" | 9 #include "SkStream.h" |
10 #include "SkTypeface.h" | 10 #include "SkTypeface.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 static bool render_page(const SkString& outputDir, | 173 static bool render_page(const SkString& outputDir, |
174 const SkString& inputFilename, | 174 const SkString& inputFilename, |
175 const SkPdfRenderer& renderer, | 175 const SkPdfRenderer& renderer, |
176 int page) { | 176 int page) { |
177 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 177 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
178 | 178 |
179 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. | 179 // Exercise all pdf codepaths as in normal rendering, but no actual bits are
changed. |
180 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { | 180 if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { |
181 SkBitmap bitmap; | 181 SkBitmap bitmap; |
182 SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap))); | 182 SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); |
183 SkNulCanvas canvas(device); | 183 SkNulCanvas canvas(device); |
184 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); | 184 renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); |
185 } else { | 185 } else { |
186 // 8888 | 186 // 8888 |
187 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); | 187 SkRect rect = renderer.MediaBox(page < 0 ? 0 :page); |
188 | 188 |
189 SkBitmap bitmap; | 189 SkBitmap bitmap; |
190 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(sqrt(FLAGS_
DPI / 72.0))); | 190 SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(sqrt(FLAGS_
DPI / 72.0))); |
191 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(sqrt(FLAG
S_DPI / 72.0))); | 191 SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(sqrt(FLAG
S_DPI / 72.0))); |
192 | 192 |
193 rect = SkRect::MakeWH(width, height); | 193 rect = SkRect::MakeWH(width, height); |
194 | 194 |
195 #ifdef PDF_DEBUG_3X | 195 #ifdef PDF_DEBUG_3X |
196 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height)); | 196 setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScala
rToDouble(height)); |
197 #else | 197 #else |
198 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height)); | 198 setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDoubl
e(height)); |
199 #endif | 199 #endif |
200 SkAutoTUnref<SkDevice> device; | 200 SkAutoTUnref<SkBaseDevice> device; |
201 if (strcmp(FLAGS_config[0], "8888") == 0) { | 201 if (strcmp(FLAGS_config[0], "8888") == 0) { |
202 device.reset(SkNEW_ARGS(SkDevice, (bitmap))); | 202 device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap))); |
203 } | 203 } |
204 #if SK_SUPPORT_GPU | 204 #if SK_SUPPORT_GPU |
205 else if (strcmp(FLAGS_config[0], "gpu") == 0) { | 205 else if (strcmp(FLAGS_config[0], "gpu") == 0) { |
206 SkAutoTUnref<GrSurface> target; | 206 SkAutoTUnref<GrSurface> target; |
207 GrContext* gr = gContextFactory.get(GrContextFactory::kNative_GLCont
extType); | 207 GrContext* gr = gContextFactory.get(GrContextFactory::kNative_GLCont
extType); |
208 if (gr) { | 208 if (gr) { |
209 // create a render target to back the device | 209 // create a render target to back the device |
210 GrTextureDesc desc; | 210 GrTextureDesc desc; |
211 desc.fConfig = kSkia8888_GrPixelConfig; | 211 desc.fConfig = kSkia8888_GrPixelConfig; |
212 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 212 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 372 } |
373 | 373 |
374 return 0; | 374 return 0; |
375 } | 375 } |
376 | 376 |
377 #if !defined SK_BUILD_FOR_IOS | 377 #if !defined SK_BUILD_FOR_IOS |
378 int main(int argc, char * const argv[]) { | 378 int main(int argc, char * const argv[]) { |
379 return tool_main(argc, (char**) argv); | 379 return tool_main(argc, (char**) argv); |
380 } | 380 } |
381 #endif | 381 #endif |
OLD | NEW |