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 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkDrawFilter.h" | 12 #include "SkDrawFilter.h" |
13 #include "SkJSONCPP.h" | 13 #include "SkJSONCPP.h" |
14 #include "SkMath.h" | 14 #include "SkMath.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkPicture.h" | 16 #include "SkPicture.h" |
17 #include "SkPictureRecorder.h" | 17 #include "SkPictureRecorder.h" |
18 #include "SkRect.h" | 18 #include "SkRect.h" |
19 #include "SkRefCnt.h" | 19 #include "SkRefCnt.h" |
20 #include "SkString.h" | 20 #include "SkString.h" |
21 #include "SkTDArray.h" | 21 #include "SkTDArray.h" |
22 #include "SkTypes.h" | 22 #include "SkTypes.h" |
23 | 23 |
24 #if SK_SUPPORT_GPU | 24 #if SK_SUPPORT_GPU |
25 #include "GrContextFactory.h" | 25 #include "GrContextFactory.h" |
26 #include "GrContext.h" | 26 #include "GrContext.h" |
27 #endif | 27 #endif |
28 | 28 |
29 #include "image_expectations.h" | |
30 | |
31 struct GrContextOptions; | 29 struct GrContextOptions; |
32 class SkBitmap; | 30 class SkBitmap; |
33 class SkCanvas; | 31 class SkCanvas; |
34 class SkGLContext; | 32 class SkGLContext; |
35 class SkThread; | 33 class SkThread; |
36 | 34 |
37 namespace sk_tools { | 35 namespace sk_tools { |
38 | 36 |
39 class TiledPictureRenderer; | 37 class TiledPictureRenderer; |
40 | 38 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 * @param useMultiPictureDraw true if MultiPictureDraw should be used for re
ndering | 93 * @param useMultiPictureDraw true if MultiPictureDraw should be used for re
ndering |
96 */ | 94 */ |
97 virtual void init(const SkPicture* pict, | 95 virtual void init(const SkPicture* pict, |
98 const SkString* writePath, | 96 const SkString* writePath, |
99 const SkString* mismatchPath, | 97 const SkString* mismatchPath, |
100 const SkString* inputFilename, | 98 const SkString* inputFilename, |
101 bool useChecksumBasedFilenames, | 99 bool useChecksumBasedFilenames, |
102 bool useMultiPictureDraw); | 100 bool useMultiPictureDraw); |
103 | 101 |
104 /** | 102 /** |
105 * TODO(epoger): Temporary hack, while we work on http://skbug.com/2584 ('be
nch_pictures is | |
106 * timing reading pixels and writing json files'), such that: | |
107 * - render_pictures can call this method and continue to work | |
108 * - any other callers (bench_pictures) will skip calls to write() by defaul
t | |
109 */ | |
110 void enableWrites() { fEnableWrites = true; } | |
111 | |
112 /** | |
113 * Set the viewport so that only the portion listed gets drawn. | 103 * Set the viewport so that only the portion listed gets drawn. |
114 */ | 104 */ |
115 void setViewport(SkISize size) { fViewport = size; } | 105 void setViewport(SkISize size) { fViewport = size; } |
116 | 106 |
117 /** | 107 /** |
118 * Set the scale factor at which draw the picture. | 108 * Set the scale factor at which draw the picture. |
119 */ | 109 */ |
120 void setScaleFactor(SkScalar scale) { fScaleFactor = scale; } | 110 void setScaleFactor(SkScalar scale) { fScaleFactor = scale; } |
121 | 111 |
122 /** | 112 /** |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 fHasDrawFilters |= SkToBool(filters[i]); | 234 fHasDrawFilters |= SkToBool(filters[i]); |
245 } | 235 } |
246 } | 236 } |
247 | 237 |
248 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { | 238 void setBBoxHierarchyType(BBoxHierarchyType bbhType) { |
249 fBBoxHierarchyType = bbhType; | 239 fBBoxHierarchyType = bbhType; |
250 } | 240 } |
251 | 241 |
252 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } | 242 BBoxHierarchyType getBBoxHierarchyType() { return fBBoxHierarchyType; } |
253 | 243 |
254 void setJsonSummaryPtr(ImageResultsAndExpectations* jsonSummaryPtr) { | |
255 fJsonSummaryPtr = jsonSummaryPtr; | |
256 } | |
257 | |
258 bool isUsingBitmapDevice() { | 244 bool isUsingBitmapDevice() { |
259 return kBitmap_DeviceType == fDeviceType; | 245 return kBitmap_DeviceType == fDeviceType; |
260 } | 246 } |
261 | 247 |
262 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } | 248 virtual SkString getPerIterTimeFormat() { return SkString("%.2f"); } |
263 | 249 |
264 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } | 250 virtual SkString getNormalTimeFormat() { return SkString("%6.2f"); } |
265 | 251 |
266 /** | 252 /** |
267 * Reports the configuration of this PictureRenderer. | 253 * Reports the configuration of this PictureRenderer. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 423 |
438 const SkPicture* getPicture() { | 424 const SkPicture* getPicture() { |
439 return fPicture; | 425 return fPicture; |
440 } | 426 } |
441 | 427 |
442 #if SK_SUPPORT_GPU | 428 #if SK_SUPPORT_GPU |
443 explicit PictureRenderer(const GrContextOptions &opts) | 429 explicit PictureRenderer(const GrContextOptions &opts) |
444 #else | 430 #else |
445 PictureRenderer() | 431 PictureRenderer() |
446 #endif | 432 #endif |
447 : fJsonSummaryPtr(nullptr) | 433 : fDeviceType(kBitmap_DeviceType) |
448 , fDeviceType(kBitmap_DeviceType) | |
449 , fEnableWrites(false) | |
450 , fBBoxHierarchyType(kNone_BBoxHierarchyType) | 434 , fBBoxHierarchyType(kNone_BBoxHierarchyType) |
451 , fHasDrawFilters(false) | 435 , fHasDrawFilters(false) |
452 , fScaleFactor(SK_Scalar1) | 436 , fScaleFactor(SK_Scalar1) |
453 #if SK_SUPPORT_GPU | 437 #if SK_SUPPORT_GPU |
454 , fGrContextFactory(opts) | 438 , fGrContextFactory(opts) |
455 , fGrContext(nullptr) | 439 , fGrContext(nullptr) |
456 , fSampleCount(0) | 440 , fSampleCount(0) |
457 , fUseDFText(false) | 441 , fUseDFText(false) |
458 #endif | 442 #endif |
459 { | 443 { |
460 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); | 444 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); |
461 fViewport.set(0, 0); | 445 fViewport.set(0, 0); |
462 } | 446 } |
463 | 447 |
464 #if SK_SUPPORT_GPU | 448 #if SK_SUPPORT_GPU |
465 virtual ~PictureRenderer() { | 449 virtual ~PictureRenderer() { |
466 SkSafeUnref(fGrContext); | 450 SkSafeUnref(fGrContext); |
467 } | 451 } |
468 #endif | 452 #endif |
469 | 453 |
470 protected: | 454 protected: |
471 SkAutoTUnref<SkCanvas> fCanvas; | 455 SkAutoTUnref<SkCanvas> fCanvas; |
472 SkAutoTUnref<const SkPicture> fPicture; | 456 SkAutoTUnref<const SkPicture> fPicture; |
473 bool fUseChecksumBasedFilenames; | 457 bool fUseChecksumBasedFilenames; |
474 bool fUseMultiPictureDraw; | 458 bool fUseMultiPictureDraw; |
475 ImageResultsAndExpectations* fJsonSummaryPtr; | |
476 SkDeviceTypes fDeviceType; | 459 SkDeviceTypes fDeviceType; |
477 bool fEnableWrites; | |
478 BBoxHierarchyType fBBoxHierarchyType; | 460 BBoxHierarchyType fBBoxHierarchyType; |
479 bool fHasDrawFilters; | 461 bool fHasDrawFilters; |
480 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; | 462 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
481 SkString fDrawFiltersConfig; | 463 SkString fDrawFiltersConfig; |
482 SkString fWritePath; | 464 SkString fWritePath; |
483 SkString fMismatchPath; | 465 SkString fMismatchPath; |
484 SkString fInputFilename; | 466 SkString fInputFilename; |
485 | 467 |
486 void buildBBoxHierarchy(); | 468 void buildBBoxHierarchy(); |
487 | 469 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 | 728 |
747 #if SK_SUPPORT_GPU | 729 #if SK_SUPPORT_GPU |
748 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op
ts); | 730 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op
ts); |
749 #else | 731 #else |
750 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 732 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
751 #endif | 733 #endif |
752 | 734 |
753 } | 735 } |
754 | 736 |
755 #endif // PictureRenderer_DEFINED | 737 #endif // PictureRenderer_DEFINED |
OLD | NEW |