| 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 "SkCountdown.h" | |
| 13 #include "SkDrawFilter.h" | 12 #include "SkDrawFilter.h" |
| 14 #include "SkJSONCPP.h" | 13 #include "SkJSONCPP.h" |
| 15 #include "SkMath.h" | 14 #include "SkMath.h" |
| 16 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 17 #include "SkPicture.h" | 16 #include "SkPicture.h" |
| 18 #include "SkPictureRecorder.h" | 17 #include "SkPictureRecorder.h" |
| 19 #include "SkRect.h" | 18 #include "SkRect.h" |
| 20 #include "SkRefCnt.h" | 19 #include "SkRefCnt.h" |
| 21 #include "SkRunnable.h" | |
| 22 #include "SkString.h" | 20 #include "SkString.h" |
| 23 #include "SkTDArray.h" | 21 #include "SkTDArray.h" |
| 24 #include "SkThreadPool.h" | |
| 25 #include "SkTypes.h" | 22 #include "SkTypes.h" |
| 26 | 23 |
| 27 #if SK_SUPPORT_GPU | 24 #if SK_SUPPORT_GPU |
| 28 #include "GrContextFactory.h" | 25 #include "GrContextFactory.h" |
| 29 #include "GrContext.h" | 26 #include "GrContext.h" |
| 30 #endif | 27 #endif |
| 31 | 28 |
| 32 #include "image_expectations.h" | 29 #include "image_expectations.h" |
| 33 | 30 |
| 34 class SkBitmap; | 31 class SkBitmap; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 public: | 533 public: |
| 537 TiledPictureRenderer(); | 534 TiledPictureRenderer(); |
| 538 | 535 |
| 539 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, | 536 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, |
| 540 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; | 537 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; |
| 541 | 538 |
| 542 /** | 539 /** |
| 543 * Renders to tiles, rather than a single canvas. | 540 * Renders to tiles, rather than a single canvas. |
| 544 * If fWritePath was provided, a separate file is | 541 * If fWritePath was provided, a separate file is |
| 545 * created for each tile, named "path0.png", "path1.png", etc. | 542 * created for each tile, named "path0.png", "path1.png", etc. |
| 546 * Multithreaded mode currently does not support writing to a file. | |
| 547 */ | 543 */ |
| 548 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 544 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| 549 | 545 |
| 550 virtual void end() SK_OVERRIDE; | 546 virtual void end() SK_OVERRIDE; |
| 551 | 547 |
| 552 void setTileWidth(int width) { | 548 void setTileWidth(int width) { |
| 553 fTileWidth = width; | 549 fTileWidth = width; |
| 554 } | 550 } |
| 555 | 551 |
| 556 int getTileWidth() const { | 552 int getTileWidth() const { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 int fTilesX; | 642 int fTilesX; |
| 647 // Number of tiles in the y direction. | 643 // Number of tiles in the y direction. |
| 648 int fTilesY; | 644 int fTilesY; |
| 649 | 645 |
| 650 void setupTiles(); | 646 void setupTiles(); |
| 651 void setupPowerOf2Tiles(); | 647 void setupPowerOf2Tiles(); |
| 652 | 648 |
| 653 typedef PictureRenderer INHERITED; | 649 typedef PictureRenderer INHERITED; |
| 654 }; | 650 }; |
| 655 | 651 |
| 656 class CloneData; | |
| 657 | |
| 658 class MultiCorePictureRenderer : public TiledPictureRenderer { | |
| 659 public: | |
| 660 explicit MultiCorePictureRenderer(int threadCount); | |
| 661 | |
| 662 ~MultiCorePictureRenderer(); | |
| 663 | |
| 664 virtual void init(SkPicture* pict, const SkString* writePath, const SkString
* mismatchPath, | |
| 665 const SkString* inputFilename, bool useChecksumBasedFilena
mes) SK_OVERRIDE; | |
| 666 | |
| 667 /** | |
| 668 * Behaves like TiledPictureRenderer::render(), only using multiple threads. | |
| 669 */ | |
| 670 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | |
| 671 | |
| 672 virtual void end() SK_OVERRIDE; | |
| 673 | |
| 674 virtual bool supportsTimingIndividualTiles() SK_OVERRIDE { return false; } | |
| 675 | |
| 676 private: | |
| 677 virtual SkString getConfigNameInternal() SK_OVERRIDE; | |
| 678 | |
| 679 const int fNumThreads; | |
| 680 SkTDArray<SkCanvas*> fCanvasPool; | |
| 681 SkThreadPool fThreadPool; | |
| 682 SkPicture* fPictureClones; | |
| 683 CloneData** fCloneData; | |
| 684 SkCountdown fCountdown; | |
| 685 | |
| 686 typedef TiledPictureRenderer INHERITED; | |
| 687 }; | |
| 688 | |
| 689 /** | 652 /** |
| 690 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord | 653 * This class does not do any rendering, but its render function executes turnin
g an SkPictureRecord |
| 691 * into an SkPicturePlayback, which we want to time. | 654 * into an SkPicturePlayback, which we want to time. |
| 692 */ | 655 */ |
| 693 class PlaybackCreationRenderer : public PictureRenderer { | 656 class PlaybackCreationRenderer : public PictureRenderer { |
| 694 public: | 657 public: |
| 695 virtual void setup() SK_OVERRIDE; | 658 virtual void setup() SK_OVERRIDE; |
| 696 | 659 |
| 697 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; | 660 virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE; |
| 698 | 661 |
| 699 virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"
); } | 662 virtual SkString getPerIterTimeFormat() SK_OVERRIDE { return SkString("%.4f"
); } |
| 700 | 663 |
| 701 virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"
); } | 664 virtual SkString getNormalTimeFormat() SK_OVERRIDE { return SkString("%6.4f"
); } |
| 702 | 665 |
| 703 private: | 666 private: |
| 704 SkAutoTDelete<SkPictureRecorder> fRecorder; | 667 SkAutoTDelete<SkPictureRecorder> fRecorder; |
| 705 | 668 |
| 706 virtual SkString getConfigNameInternal() SK_OVERRIDE; | 669 virtual SkString getConfigNameInternal() SK_OVERRIDE; |
| 707 | 670 |
| 708 typedef PictureRenderer INHERITED; | 671 typedef PictureRenderer INHERITED; |
| 709 }; | 672 }; |
| 710 | 673 |
| 711 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 674 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
| 712 extern PictureRenderer* CreatePictureCloneRenderer(); | |
| 713 | 675 |
| 714 } | 676 } |
| 715 | 677 |
| 716 #endif // PictureRenderer_DEFINED | 678 #endif // PictureRenderer_DEFINED |
| OLD | NEW |