OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #ifndef PictureRenderer_DEFINED | 8 #ifndef PictureRenderer_DEFINED |
9 #define PictureRenderer_DEFINED | 9 #define PictureRenderer_DEFINED |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 kBitmap_DeviceType, | 50 kBitmap_DeviceType, |
51 #if SK_SUPPORT_GPU | 51 #if SK_SUPPORT_GPU |
52 kGPU_DeviceType, | 52 kGPU_DeviceType, |
53 kNVPR_DeviceType, | 53 kNVPR_DeviceType, |
54 #endif | 54 #endif |
55 }; | 55 }; |
56 | 56 |
57 enum BBoxHierarchyType { | 57 enum BBoxHierarchyType { |
58 kNone_BBoxHierarchyType = 0, | 58 kNone_BBoxHierarchyType = 0, |
59 kRTree_BBoxHierarchyType, | 59 kRTree_BBoxHierarchyType, |
60 kTileGrid_BBoxHierarchyType, | |
61 | 60 |
62 kLast_BBoxHierarchyType = kTileGrid_BBoxHierarchyType, | 61 kLast_BBoxHierarchyType = kRTree_BBoxHierarchyType, |
63 }; | 62 }; |
64 | 63 |
65 // this uses SkPaint::Flags as a base and adds additional flags | 64 // this uses SkPaint::Flags as a base and adds additional flags |
66 enum DrawFilterFlags { | 65 enum DrawFilterFlags { |
67 kNone_DrawFilterFlag = 0, | 66 kNone_DrawFilterFlag = 0, |
68 kHinting_DrawFilterFlag = 0x10000, // toggles between no hinting and nor
mal hinting | 67 kHinting_DrawFilterFlag = 0x10000, // toggles between no hinting and nor
mal hinting |
69 kSlightHinting_DrawFilterFlag = 0x20000, // toggles between slight and n
ormal hinting | 68 kSlightHinting_DrawFilterFlag = 0x20000, // toggles between slight and n
ormal hinting |
70 kAAClip_DrawFilterFlag = 0x40000, // toggles between soft and hard clip | 69 kAAClip_DrawFilterFlag = 0x40000, // toggles between soft and hard clip |
71 kMaskFilter_DrawFilterFlag = 0x80000, // toggles on/off mask filters (e.
g., blurs) | 70 kMaskFilter_DrawFilterFlag = 0x80000, // toggles on/off mask filters (e.
g., blurs) |
72 }; | 71 }; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 memcpy(fDrawFilters, filters, sizeof(fDrawFilters)); | 229 memcpy(fDrawFilters, filters, sizeof(fDrawFilters)); |
231 fDrawFiltersConfig = configName; | 230 fDrawFiltersConfig = configName; |
232 } | 231 } |
233 | 232 |
234 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { | 233 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { |
235 fBBoxHierarchyType = bbhType; | 234 fBBoxHierarchyType = bbhType; |
236 } | 235 } |
237 | 236 |
238 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } | 237 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } |
239 | 238 |
240 void setGridSize(int width, int height) { | |
241 fGridInfo.fTileInterval.set(width, height); | |
242 } | |
243 | |
244 void setJsonSummaryPtr(ImageResultsAndExpectations* jsonSummaryPtr) { | 239 void setJsonSummaryPtr(ImageResultsAndExpectations* jsonSummaryPtr) { |
245 fJsonSummaryPtr = jsonSummaryPtr; | 240 fJsonSummaryPtr = jsonSummaryPtr; |
246 } | 241 } |
247 | 242 |
248 bool isUsingBitmapDevice() { | 243 bool isUsingBitmapDevice() { |
249 return kBitmap_DeviceType == fDeviceType; | 244 return kBitmap_DeviceType == fDeviceType; |
250 } | 245 } |
251 | 246 |
252 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } | 247 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } |
253 | 248 |
254 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } | 249 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } |
255 | 250 |
256 /** | 251 /** |
257 * Reports the configuration of this PictureRenderer. | 252 * Reports the configuration of this PictureRenderer. |
258 */ | 253 */ |
259 SkString getConfigName() { | 254 SkString getConfigName() { |
260 SkString config = this->getConfigNameInternal(); | 255 SkString config = this->getConfigNameInternal(); |
261 if (!fViewport.isEmpty()) { | 256 if (!fViewport.isEmpty()) { |
262 config.appendf("_viewport_%ix%i", fViewport.width(), fViewport.heigh
t()); | 257 config.appendf("_viewport_%ix%i", fViewport.width(), fViewport.heigh
t()); |
263 } | 258 } |
264 if (fScaleFactor != SK_Scalar1) { | 259 if (fScaleFactor != SK_Scalar1) { |
265 config.appendf("_scalar_%f", SkScalarToFloat(fScaleFactor)); | 260 config.appendf("_scalar_%f", SkScalarToFloat(fScaleFactor)); |
266 } | 261 } |
267 if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { | 262 if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { |
268 config.append("_rtree"); | 263 config.append("_rtree"); |
269 } else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) { | |
270 config.append("_grid"); | |
271 config.append("_"); | |
272 config.appendS32(fGridInfo.fTileInterval.width()); | |
273 config.append("x"); | |
274 config.appendS32(fGridInfo.fTileInterval.height()); | |
275 } | 264 } |
276 #if SK_SUPPORT_GPU | 265 #if SK_SUPPORT_GPU |
277 switch (fDeviceType) { | 266 switch (fDeviceType) { |
278 case kGPU_DeviceType: | 267 case kGPU_DeviceType: |
279 if (fSampleCount) { | 268 if (fSampleCount) { |
280 config.appendf("_msaa%d", fSampleCount); | 269 config.appendf("_msaa%d", fSampleCount); |
281 } else if (fUseDFText) { | 270 } else if (fUseDFText) { |
282 config.append("_gpudft"); | 271 config.append("_gpudft"); |
283 } else { | 272 } else { |
284 config.append("_gpu"); | 273 config.append("_gpu"); |
(...skipping 24 matching lines...) Expand all Loading... |
309 Json::Value getJSONConfig() { | 298 Json::Value getJSONConfig() { |
310 Json::Value result; | 299 Json::Value result; |
311 | 300 |
312 result["mode"] = this->getConfigNameInternal().c_str(); | 301 result["mode"] = this->getConfigNameInternal().c_str(); |
313 result["scale"] = 1.0f; | 302 result["scale"] = 1.0f; |
314 if (SK_Scalar1 != fScaleFactor) { | 303 if (SK_Scalar1 != fScaleFactor) { |
315 result["scale"] = SkScalarToFloat(fScaleFactor); | 304 result["scale"] = SkScalarToFloat(fScaleFactor); |
316 } | 305 } |
317 if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { | 306 if (kRTree_BBoxHierarchyType == fBBoxHierarchyType) { |
318 result["bbh"] = "rtree"; | 307 result["bbh"] = "rtree"; |
319 } else if (kTileGrid_BBoxHierarchyType == fBBoxHierarchyType) { | |
320 SkString tmp("grid_"); | |
321 tmp.appendS32(fGridInfo.fTileInterval.width()); | |
322 tmp.append("x"); | |
323 tmp.appendS32(fGridInfo.fTileInterval.height()); | |
324 result["bbh"] = tmp.c_str(); | |
325 } | 308 } |
326 #if SK_SUPPORT_GPU | 309 #if SK_SUPPORT_GPU |
327 SkString tmp; | 310 SkString tmp; |
328 switch (fDeviceType) { | 311 switch (fDeviceType) { |
329 case kGPU_DeviceType: | 312 case kGPU_DeviceType: |
330 if (0 != fSampleCount) { | 313 if (0 != fSampleCount) { |
331 tmp = "msaa"; | 314 tmp = "msaa"; |
332 tmp.appendS32(fSampleCount); | 315 tmp.appendS32(fSampleCount); |
333 result["config"] = tmp.c_str(); | 316 result["config"] = tmp.c_str(); |
334 } else if (fUseDFText) { | 317 } else if (fUseDFText) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 , fEnableWrites(false) | 415 , fEnableWrites(false) |
433 , fBBoxHierarchyType(kNone_BBoxHierarchyType) | 416 , fBBoxHierarchyType(kNone_BBoxHierarchyType) |
434 , fScaleFactor(SK_Scalar1) | 417 , fScaleFactor(SK_Scalar1) |
435 #if SK_SUPPORT_GPU | 418 #if SK_SUPPORT_GPU |
436 , fGrContextFactory(opts) | 419 , fGrContextFactory(opts) |
437 , fGrContext(NULL) | 420 , fGrContext(NULL) |
438 , fSampleCount(0) | 421 , fSampleCount(0) |
439 , fUseDFText(false) | 422 , fUseDFText(false) |
440 #endif | 423 #endif |
441 { | 424 { |
442 fGridInfo.fMargin.setEmpty(); | |
443 fGridInfo.fOffset.setZero(); | |
444 fGridInfo.fTileInterval.set(1, 1); | |
445 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); | 425 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); |
446 fViewport.set(0, 0); | 426 fViewport.set(0, 0); |
447 } | 427 } |
448 | 428 |
449 #if SK_SUPPORT_GPU | 429 #if SK_SUPPORT_GPU |
450 virtual ~PictureRenderer() { | 430 virtual ~PictureRenderer() { |
451 SkSafeUnref(fGrContext); | 431 SkSafeUnref(fGrContext); |
452 } | 432 } |
453 #endif | 433 #endif |
454 | 434 |
455 protected: | 435 protected: |
456 SkAutoTUnref<SkCanvas> fCanvas; | 436 SkAutoTUnref<SkCanvas> fCanvas; |
457 SkAutoTUnref<const SkPicture> fPicture; | 437 SkAutoTUnref<const SkPicture> fPicture; |
458 bool fUseChecksumBasedFilenames; | 438 bool fUseChecksumBasedFilenames; |
459 bool fUseMultiPictureDraw; | 439 bool fUseMultiPictureDraw; |
460 ImageResultsAndExpectations* fJsonSummaryPtr; | 440 ImageResultsAndExpectations* fJsonSummaryPtr; |
461 SkDeviceTypes fDeviceType; | 441 SkDeviceTypes fDeviceType; |
462 bool fEnableWrites; | 442 bool fEnableWrites; |
463 BBoxHierarchyType fBBoxHierarchyType; | 443 BBoxHierarchyType fBBoxHierarchyType; |
464 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; | 444 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
465 SkString fDrawFiltersConfig; | 445 SkString fDrawFiltersConfig; |
466 SkString fWritePath; | 446 SkString fWritePath; |
467 SkString fMismatchPath; | 447 SkString fMismatchPath; |
468 SkString fInputFilename; | 448 SkString fInputFilename; |
469 SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid | |
470 | 449 |
471 void buildBBoxHierarchy(); | 450 void buildBBoxHierarchy(); |
472 | 451 |
473 /** | 452 /** |
474 * Return the total width that should be drawn. If the viewport width has be
en set greater than | 453 * Return the total width that should be drawn. If the viewport width has be
en set greater than |
475 * 0, this will be the minimum of the current SkPicture's width and the view
port's width. | 454 * 0, this will be the minimum of the current SkPicture's width and the view
port's width. |
476 */ | 455 */ |
477 int getViewWidth(); | 456 int getViewWidth(); |
478 | 457 |
479 /** | 458 /** |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 // These variables are only used for timing individual tiles. | 668 // These variables are only used for timing individual tiles. |
690 // Next tile to draw in fTileRects. | 669 // Next tile to draw in fTileRects. |
691 int fCurrentTileOffset; | 670 int fCurrentTileOffset; |
692 // Number of tiles in the x direction. | 671 // Number of tiles in the x direction. |
693 int fTilesX; | 672 int fTilesX; |
694 // Number of tiles in the y direction. | 673 // Number of tiles in the y direction. |
695 int fTilesY; | 674 int fTilesY; |
696 | 675 |
697 void setupTiles(); | 676 void setupTiles(); |
698 void setupPowerOf2Tiles(); | 677 void setupPowerOf2Tiles(); |
699 bool postRender(SkCanvas*, const SkIRect& tileRect, | 678 bool postRender(SkCanvas*, const SkIRect& tileRect, |
700 SkBitmap* tempBM, SkBitmap** out, | 679 SkBitmap* tempBM, SkBitmap** out, |
701 int tileNumber); | 680 int tileNumber); |
702 | 681 |
703 typedef PictureRenderer INHERITED; | 682 typedef PictureRenderer INHERITED; |
704 }; | 683 }; |
705 | 684 |
706 /** | 685 /** |
707 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord | 686 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord |
708 * into an SkPicturePlayback, which we want to time. | 687 * into an SkPicturePlayback, which we want to time. |
709 */ | 688 */ |
(...skipping 21 matching lines...) Expand all Loading... |
731 | 710 |
732 #if SK_SUPPORT_GPU | 711 #if SK_SUPPORT_GPU |
733 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options&
opts); | 712 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options&
opts); |
734 #else | 713 #else |
735 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 714 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
736 #endif | 715 #endif |
737 | 716 |
738 } | 717 } |
739 | 718 |
740 #endif // PictureRenderer_DEFINED | 719 #endif // PictureRenderer_DEFINED |
OLD | NEW |