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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 SK_COMPILE_ASSERT(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags), maskfi
lter_flag_must_be_greater); | 77 SK_COMPILE_ASSERT(!(kMaskFilter_DrawFilterFlag & SkPaint::kAllFlags), maskfi
lter_flag_must_be_greater); |
78 SK_COMPILE_ASSERT(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags), | 78 SK_COMPILE_ASSERT(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags), |
79 hinting_flag_must_be_greater); | 79 hinting_flag_must_be_greater); |
80 SK_COMPILE_ASSERT(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags), | 80 SK_COMPILE_ASSERT(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags), |
81 slight_hinting_flag_must_be_greater); | 81 slight_hinting_flag_must_be_greater); |
82 | 82 |
83 /** | 83 /** |
84 * Called with each new SkPicture to render. | 84 * Called with each new SkPicture to render. |
85 * | 85 * |
86 * @param pict The SkPicture to render. | 86 * @param pict The SkPicture to render. |
87 * @param outputDir The output directory within which this renderer should w
rite files, | 87 * @param writePath The output directory within which this renderer should w
rite all images, |
88 * or NULL if this renderer should not write files at all. | 88 * or NULL if this renderer should not write all images. |
| 89 * @param mismatchPath The output directory within which this renderer shoul
d write any images |
| 90 * which do not match expectations, or NULL if this renderer should not
write mismatches. |
89 * @param inputFilename The name of the input file we are rendering. | 91 * @param inputFilename The name of the input file we are rendering. |
90 * @param useChecksumBasedFilenames Whether to use checksum-based filenames
when writing | 92 * @param useChecksumBasedFilenames Whether to use checksum-based filenames
when writing |
91 * bitmap images to disk. | 93 * bitmap images to disk. |
92 */ | 94 */ |
93 virtual void init(SkPicture* pict, const SkString* outputDir, | 95 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, |
94 const SkString* inputFilename, bool useChecksumBasedFilena
mes); | 96 const SkString* inputFilename, bool useChecksumBasedFilena
mes); |
95 | 97 |
96 /** | 98 /** |
97 * Set the viewport so that only the portion listed gets drawn. | 99 * Set the viewport so that only the portion listed gets drawn. |
98 */ | 100 */ |
99 void setViewport(SkISize size) { fViewport = size; } | 101 void setViewport(SkISize size) { fViewport = size; } |
100 | 102 |
101 /** | 103 /** |
102 * Set the scale factor at which draw the picture. | 104 * Set the scale factor at which draw the picture. |
103 */ | 105 */ |
104 void setScaleFactor(SkScalar scale) { fScaleFactor = scale; } | 106 void setScaleFactor(SkScalar scale) { fScaleFactor = scale; } |
105 | 107 |
106 /** | 108 /** |
107 * Perform any setup that should done prior to each iteration of render() wh
ich should not be | 109 * Perform any setup that should done prior to each iteration of render() wh
ich should not be |
108 * timed. | 110 * timed. |
109 */ | 111 */ |
110 virtual void setup() {} | 112 virtual void setup() {} |
111 | 113 |
112 /** | 114 /** |
113 * Perform the work. If this is being called within the context of bench_pi
ctures, | 115 * Perform the work. If this is being called within the context of bench_pi
ctures, |
114 * this is the step that will be timed. | 116 * this is the step that will be timed. |
115 * | 117 * |
116 * Typically "the work" is rendering an SkPicture into a bitmap, but in some
subclasses | 118 * Typically "the work" is rendering an SkPicture into a bitmap, but in some
subclasses |
117 * it is recording the source SkPicture into another SkPicture. | 119 * it is recording the source SkPicture into another SkPicture. |
118 * | 120 * |
119 * If fOutputDir has been specified, the result of the work will be written
to that dir. | 121 * If fWritePath has been specified, the result of the work will be written
to that dir. |
| 122 * If fMismatchPath has been specified, and the actual image result differs
from its |
| 123 * expectation, the result of the work will be written to that dir. |
120 * | 124 * |
121 * @param out If non-null, the implementing subclass MAY allocate an SkBitma
p, copy the | 125 * @param out If non-null, the implementing subclass MAY allocate an SkBitma
p, copy the |
122 * output image into it, and return it here. (Some subclasses ig
nore this parameter) | 126 * output image into it, and return it here. (Some subclasses ig
nore this parameter) |
123 * @return bool True if rendering succeeded and, if fOutputDir had been spec
ified, the output | 127 * @return bool True if rendering succeeded and, if fWritePath had been spec
ified, the output |
124 * was successfully written to a file. | 128 * was successfully written to a file. |
125 */ | 129 */ |
126 virtual bool render(SkBitmap** out = NULL) = 0; | 130 virtual bool render(SkBitmap** out = NULL) = 0; |
127 | 131 |
128 /** | 132 /** |
129 * Called once finished with a particular SkPicture, before calling init aga
in, and before | 133 * Called once finished with a particular SkPicture, before calling init aga
in, and before |
130 * being done with this Renderer. | 134 * being done with this Renderer. |
131 */ | 135 */ |
132 virtual void end(); | 136 virtual void end(); |
133 | 137 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 367 |
364 protected: | 368 protected: |
365 SkAutoTUnref<SkCanvas> fCanvas; | 369 SkAutoTUnref<SkCanvas> fCanvas; |
366 SkAutoTUnref<SkPicture> fPicture; | 370 SkAutoTUnref<SkPicture> fPicture; |
367 bool fUseChecksumBasedFilenames; | 371 bool fUseChecksumBasedFilenames; |
368 ImageResultsAndExpectations* fJsonSummaryPtr; | 372 ImageResultsAndExpectations* fJsonSummaryPtr; |
369 SkDeviceTypes fDeviceType; | 373 SkDeviceTypes fDeviceType; |
370 BBoxHierarchyType fBBoxHierarchyType; | 374 BBoxHierarchyType fBBoxHierarchyType; |
371 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; | 375 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
372 SkString fDrawFiltersConfig; | 376 SkString fDrawFiltersConfig; |
373 SkString fOutputDir; | 377 SkString fWritePath; |
| 378 SkString fMismatchPath; |
374 SkString fInputFilename; | 379 SkString fInputFilename; |
375 SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid | 380 SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid |
376 | 381 |
377 void buildBBoxHierarchy(); | 382 void buildBBoxHierarchy(); |
378 | 383 |
379 /** | 384 /** |
380 * Return the total width that should be drawn. If the viewport width has be
en set greater than | 385 * Return the total width that should be drawn. If the viewport width has be
en set greater than |
381 * 0, this will be the minimum of the current SkPicture's width and the view
port's width. | 386 * 0, this will be the minimum of the current SkPicture's width and the view
port's width. |
382 */ | 387 */ |
383 int getViewWidth(); | 388 int getViewWidth(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 445 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
441 | 446 |
442 private: | 447 private: |
443 virtual SkString getConfigNameInternal() SK_OVERRIDE; | 448 virtual SkString getConfigNameInternal() SK_OVERRIDE; |
444 | 449 |
445 typedef PictureRenderer INHERITED; | 450 typedef PictureRenderer INHERITED; |
446 }; | 451 }; |
447 | 452 |
448 class SimplePictureRenderer : public PictureRenderer { | 453 class SimplePictureRenderer : public PictureRenderer { |
449 public: | 454 public: |
450 virtual void init(SkPicture* pict, const SkString* outputDir, | 455 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, |
451 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; | 456 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; |
452 | 457 |
453 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 458 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
454 | 459 |
455 private: | 460 private: |
456 virtual SkString getConfigNameInternal() SK_OVERRIDE; | 461 virtual SkString getConfigNameInternal() SK_OVERRIDE; |
457 | 462 |
458 typedef PictureRenderer INHERITED; | 463 typedef PictureRenderer INHERITED; |
459 }; | 464 }; |
460 | 465 |
461 class TiledPictureRenderer : public PictureRenderer { | 466 class TiledPictureRenderer : public PictureRenderer { |
462 public: | 467 public: |
463 TiledPictureRenderer(); | 468 TiledPictureRenderer(); |
464 | 469 |
465 virtual void init(SkPicture* pict, const SkString* outputDir, | 470 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, |
466 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; | 471 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; |
467 | 472 |
468 /** | 473 /** |
469 * Renders to tiles, rather than a single canvas. | 474 * Renders to tiles, rather than a single canvas. |
470 * If fOutputDir was provided, a separate file is | 475 * If fWritePath was provided, a separate file is |
471 * created for each tile, named "path0.png", "path1.png", etc. | 476 * created for each tile, named "path0.png", "path1.png", etc. |
472 * Multithreaded mode currently does not support writing to a file. | 477 * Multithreaded mode currently does not support writing to a file. |
473 */ | 478 */ |
474 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 479 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
475 | 480 |
476 virtual void end() SK_OVERRIDE; | 481 virtual void end() SK_OVERRIDE; |
477 | 482 |
478 void setTileWidth(int width) { | 483 void setTileWidth(int width) { |
479 fTileWidth = width; | 484 fTileWidth = width; |
480 } | 485 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 }; | 585 }; |
581 | 586 |
582 class CloneData; | 587 class CloneData; |
583 | 588 |
584 class MultiCorePictureRenderer : public TiledPictureRenderer { | 589 class MultiCorePictureRenderer : public TiledPictureRenderer { |
585 public: | 590 public: |
586 explicit MultiCorePictureRenderer(int threadCount); | 591 explicit MultiCorePictureRenderer(int threadCount); |
587 | 592 |
588 ~MultiCorePictureRenderer(); | 593 ~MultiCorePictureRenderer(); |
589 | 594 |
590 virtual void init(SkPicture* pict, const SkString* outputDir, | 595 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, |
591 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; | 596 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; |
592 | 597 |
593 /** | 598 /** |
594 * Behaves like TiledPictureRenderer::render(), only using multiple threads. | 599 * Behaves like TiledPictureRenderer::render(), only using multiple threads. |
595 */ | 600 */ |
596 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 601 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
597 | 602 |
598 virtual void end() SK_OVERRIDE; | 603 virtual void end() SK_OVERRIDE; |
599 | 604 |
600 virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; } | 605 virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 638 |
634 typedef PictureRenderer INHERITED; | 639 typedef PictureRenderer INHERITED; |
635 }; | 640 }; |
636 | 641 |
637 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 642 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
638 extern PictureRenderer* CreatePictureCloneRenderer(); | 643 extern PictureRenderer* CreatePictureCloneRenderer(); |
639 | 644 |
640 } | 645 } |
641 | 646 |
642 #endif // PictureRenderer_DEFINED | 647 #endif // PictureRenderer_DEFINED |
OLD | NEW |