| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 * Called with each new SkPicture to render. | 81 * Called with each new SkPicture to render. |
| 82 * | 82 * |
| 83 * @param pict The SkPicture to render. | 83 * @param pict The SkPicture to render. |
| 84 * @param writePath The output directory within which this renderer should w
rite all images, | 84 * @param writePath The output directory within which this renderer should w
rite all images, |
| 85 * or NULL if this renderer should not write all images. | 85 * or NULL if this renderer should not write all images. |
| 86 * @param mismatchPath The output directory within which this renderer shoul
d write any images | 86 * @param mismatchPath The output directory within which this renderer shoul
d write any images |
| 87 * which do not match expectations, or NULL if this renderer should not
write mismatches. | 87 * which do not match expectations, or NULL if this renderer should not
write mismatches. |
| 88 * @param inputFilename The name of the input file we are rendering. | 88 * @param inputFilename The name of the input file we are rendering. |
| 89 * @param useChecksumBasedFilenames Whether to use checksum-based filenames
when writing | 89 * @param useChecksumBasedFilenames Whether to use checksum-based filenames
when writing |
| 90 * bitmap images to disk. | 90 * bitmap images to disk. |
| 91 * @param useMultiPictureDraw true if MultiPictureDraw should be used for re
ndering |
| 91 */ | 92 */ |
| 92 virtual void init(const SkPicture* pict, | 93 virtual void init(const SkPicture* pict, |
| 93 const SkString* writePath, | 94 const SkString* writePath, |
| 94 const SkString* mismatchPath, | 95 const SkString* mismatchPath, |
| 95 const SkString* inputFilename, | 96 const SkString* inputFilename, |
| 96 bool useChecksumBasedFilenames); | 97 bool useChecksumBasedFilenames, |
| 98 bool useMultiPictureDraw); |
| 97 | 99 |
| 98 /** | 100 /** |
| 99 * TODO(epoger): Temporary hack, while we work on http://skbug.com/2584 ('be
nch_pictures is | 101 * TODO(epoger): Temporary hack, while we work on http://skbug.com/2584 ('be
nch_pictures is |
| 100 * timing reading pixels and writing json files'), such that: | 102 * timing reading pixels and writing json files'), such that: |
| 101 * - render_pictures can call this method and continue to work | 103 * - render_pictures can call this method and continue to work |
| 102 * - any other callers (bench_pictures) will skip calls to write() by defaul
t | 104 * - any other callers (bench_pictures) will skip calls to write() by defaul
t |
| 103 */ | 105 */ |
| 104 void enableWrites() { fEnableWrites = true; } | 106 void enableWrites() { fEnableWrites = true; } |
| 105 | 107 |
| 106 /** | 108 /** |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 #if SK_SUPPORT_GPU | 440 #if SK_SUPPORT_GPU |
| 439 virtual ~PictureRenderer() { | 441 virtual ~PictureRenderer() { |
| 440 SkSafeUnref(fGrContext); | 442 SkSafeUnref(fGrContext); |
| 441 } | 443 } |
| 442 #endif | 444 #endif |
| 443 | 445 |
| 444 protected: | 446 protected: |
| 445 SkAutoTUnref<SkCanvas> fCanvas; | 447 SkAutoTUnref<SkCanvas> fCanvas; |
| 446 SkAutoTUnref<const SkPicture> fPicture; | 448 SkAutoTUnref<const SkPicture> fPicture; |
| 447 bool fUseChecksumBasedFilenames; | 449 bool fUseChecksumBasedFilenames; |
| 450 bool fUseMultiPictureDraw; |
| 448 ImageResultsAndExpectations* fJsonSummaryPtr; | 451 ImageResultsAndExpectations* fJsonSummaryPtr; |
| 449 SkDeviceTypes fDeviceType; | 452 SkDeviceTypes fDeviceType; |
| 450 bool fEnableWrites; | 453 bool fEnableWrites; |
| 451 BBoxHierarchyType fBBoxHierarchyType; | 454 BBoxHierarchyType fBBoxHierarchyType; |
| 452 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; | 455 DrawFilterFlags fDrawFilters[SkDrawFilter::kTypeCount]; |
| 453 SkString fDrawFiltersConfig; | 456 SkString fDrawFiltersConfig; |
| 454 SkString fWritePath; | 457 SkString fWritePath; |
| 455 SkString fMismatchPath; | 458 SkString fMismatchPath; |
| 456 SkString fInputFilename; | 459 SkString fInputFilename; |
| 457 SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid | 460 SkTileGridFactory::TileGridInfo fGridInfo; // used when fBBoxHierarchyType i
s TileGrid |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 class SimplePictureRenderer : public PictureRenderer { | 544 class SimplePictureRenderer : public PictureRenderer { |
| 542 public: | 545 public: |
| 543 #if SK_SUPPORT_GPU | 546 #if SK_SUPPORT_GPU |
| 544 SimplePictureRenderer(const GrContext::Options &opts) : INHERITED(opts) { } | 547 SimplePictureRenderer(const GrContext::Options &opts) : INHERITED(opts) { } |
| 545 #endif | 548 #endif |
| 546 | 549 |
| 547 virtual void init(const SkPicture* pict, | 550 virtual void init(const SkPicture* pict, |
| 548 const SkString* writePath, | 551 const SkString* writePath, |
| 549 const SkString* mismatchPath, | 552 const SkString* mismatchPath, |
| 550 const SkString* inputFilename, | 553 const SkString* inputFilename, |
| 551 bool useChecksumBasedFilenames) SK_OVERRIDE; | 554 bool useChecksumBasedFilenames, |
| 555 bool useMultiPictureDraw) SK_OVERRIDE; |
| 552 | 556 |
| 553 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 557 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| 554 | 558 |
| 555 private: | 559 private: |
| 556 virtual SkString getConfigNameInternal() SK_OVERRIDE; | 560 virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 557 | 561 |
| 558 typedef PictureRenderer INHERITED; | 562 typedef PictureRenderer INHERITED; |
| 559 }; | 563 }; |
| 560 | 564 |
| 561 class TiledPictureRenderer : public PictureRenderer { | 565 class TiledPictureRenderer : public PictureRenderer { |
| 562 public: | 566 public: |
| 563 #if SK_SUPPORT_GPU | 567 #if SK_SUPPORT_GPU |
| 564 TiledPictureRenderer(const GrContext::Options &opts); | 568 TiledPictureRenderer(const GrContext::Options &opts); |
| 565 #else | 569 #else |
| 566 TiledPictureRenderer(); | 570 TiledPictureRenderer(); |
| 567 #endif | 571 #endif |
| 568 | 572 |
| 569 virtual void init(const SkPicture* pict, | 573 virtual void init(const SkPicture* pict, |
| 570 const SkString* writePath, | 574 const SkString* writePath, |
| 571 const SkString* mismatchPath, | 575 const SkString* mismatchPath, |
| 572 const SkString* inputFilename, | 576 const SkString* inputFilename, |
| 573 bool useChecksumBasedFilenames) SK_OVERRIDE; | 577 bool useChecksumBasedFilenames, |
| 578 bool useMultiPictureDraw) SK_OVERRIDE; |
| 574 | 579 |
| 575 /** | 580 /** |
| 576 * Renders to tiles, rather than a single canvas. | 581 * Renders to tiles, rather than a single canvas. |
| 577 * If fWritePath was provided, a separate file is | 582 * If fWritePath was provided, a separate file is |
| 578 * created for each tile, named "path0.png", "path1.png", etc. | 583 * created for each tile, named "path0.png", "path1.png", etc. |
| 579 */ | 584 */ |
| 580 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 585 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| 581 | 586 |
| 582 virtual void end() SK_OVERRIDE; | 587 virtual void end() SK_OVERRIDE; |
| 583 | 588 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 bool nextTile(int& i, int& j); | 657 bool nextTile(int& i, int& j); |
| 653 | 658 |
| 654 /** | 659 /** |
| 655 * Render one tile. This will draw the same tile each time it is called unti
l nextTile is | 660 * Render one tile. This will draw the same tile each time it is called unti
l nextTile is |
| 656 * called. The tile rendered will depend on how many calls have been made to
nextTile. | 661 * called. The tile rendered will depend on how many calls have been made to
nextTile. |
| 657 * It is an error to call this without first calling nextTile, or if nextTil
e returns false. | 662 * It is an error to call this without first calling nextTile, or if nextTil
e returns false. |
| 658 */ | 663 */ |
| 659 void drawCurrentTile(); | 664 void drawCurrentTile(); |
| 660 | 665 |
| 661 protected: | 666 protected: |
| 662 SkTDArray<SkRect> fTileRects; | 667 SkTDArray<SkIRect> fTileRects; |
| 663 | 668 |
| 664 virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE; | 669 virtual SkCanvas* setupCanvas(int width, int height) SK_OVERRIDE; |
| 665 virtual SkString getConfigNameInternal() SK_OVERRIDE; | 670 virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 666 | 671 |
| 667 private: | 672 private: |
| 668 int fTileWidth; | 673 int fTileWidth; |
| 669 int fTileHeight; | 674 int fTileHeight; |
| 670 double fTileWidthPercentage; | 675 double fTileWidthPercentage; |
| 671 double fTileHeightPercentage; | 676 double fTileHeightPercentage; |
| 672 int fTileMinPowerOf2Width; | 677 int fTileMinPowerOf2Width; |
| 673 | 678 |
| 674 // These variables are only used for timing individual tiles. | 679 // These variables are only used for timing individual tiles. |
| 675 // Next tile to draw in fTileRects. | 680 // Next tile to draw in fTileRects. |
| 676 int fCurrentTileOffset; | 681 int fCurrentTileOffset; |
| 677 // Number of tiles in the x direction. | 682 // Number of tiles in the x direction. |
| 678 int fTilesX; | 683 int fTilesX; |
| 679 // Number of tiles in the y direction. | 684 // Number of tiles in the y direction. |
| 680 int fTilesY; | 685 int fTilesY; |
| 681 | 686 |
| 682 void setupTiles(); | 687 void setupTiles(); |
| 683 void setupPowerOf2Tiles(); | 688 void setupPowerOf2Tiles(); |
| 689 bool postRender(SkCanvas*, const SkIRect& tileRect, |
| 690 SkBitmap* tempBM, SkBitmap** out, |
| 691 int tileNumber); |
| 684 | 692 |
| 685 typedef PictureRenderer INHERITED; | 693 typedef PictureRenderer INHERITED; |
| 686 }; | 694 }; |
| 687 | 695 |
| 688 /** | 696 /** |
| 689 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord | 697 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord |
| 690 * into an SkPicturePlayback, which we want to time. | 698 * into an SkPicturePlayback, which we want to time. |
| 691 */ | 699 */ |
| 692 class PlaybackCreationRenderer : public PictureRenderer { | 700 class PlaybackCreationRenderer : public PictureRenderer { |
| 693 public: | 701 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 713 | 721 |
| 714 #if SK_SUPPORT_GPU | 722 #if SK_SUPPORT_GPU |
| 715 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options&
opts); | 723 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options&
opts); |
| 716 #else | 724 #else |
| 717 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 725 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
| 718 #endif | 726 #endif |
| 719 | 727 |
| 720 } | 728 } |
| 721 | 729 |
| 722 #endif // PictureRenderer_DEFINED | 730 #endif // PictureRenderer_DEFINED |
| OLD | NEW |