keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef PictureBenchmark_DEFINED |
| 9 | #define PictureBenchmark_DEFINED |
| 10 | #include "SkTypes.h" |
| 11 | #include "SkRefCnt.h" |
| 12 | #include "PictureRenderer.h" |
| 13 | |
| 14 | class SkPicture; |
| 15 | class SkString; |
| 16 | |
| 17 | namespace sk_tools { |
| 18 | |
| 19 | class PictureBenchmark : public SkRefCnt { |
| 20 | public: |
| 21 | virtual void run(SkPicture* pict) = 0; |
| 22 | |
| 23 | void setRepeats(int repeats) { |
| 24 | fRepeats = repeats; |
| 25 | } |
| 26 | |
| 27 | int getRepeats() const { |
| 28 | return fRepeats; |
| 29 | } |
| 30 | |
| 31 | protected: |
| 32 | int fRepeats; |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | typedef SkRefCnt INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | class PipePictureBenchmark : public PictureBenchmark { |
| 39 | public: |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 40 | virtual void run(SkPicture* pict) SK_OVERRIDE; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 41 | private: |
| 42 | PipePictureRenderer renderer; |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 43 | typedef PictureBenchmark INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | class RecordPictureBenchmark : public PictureBenchmark { |
| 47 | public: |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 48 | virtual void run(SkPicture* pict) SK_OVERRIDE; |
| 49 | private: |
| 50 | typedef PictureBenchmark INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | class SimplePictureBenchmark : public PictureBenchmark { |
| 54 | public: |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 55 | virtual void run(SkPicture* pict) SK_OVERRIDE; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 56 | private: |
| 57 | SimplePictureRenderer renderer; |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 58 | typedef PictureBenchmark INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | class TiledPictureBenchmark : public PictureBenchmark { |
| 62 | public: |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 63 | virtual void run(SkPicture* pict) SK_OVERRIDE; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 64 | |
| 65 | void setTileWidth(int width) { |
| 66 | renderer.setTileWidth(width); |
| 67 | } |
| 68 | |
| 69 | int getTileWidth() const { |
| 70 | return renderer.getTileWidth(); |
| 71 | } |
| 72 | |
| 73 | void setTileHeight(int height) { |
| 74 | renderer.setTileHeight(height); |
| 75 | } |
| 76 | |
| 77 | int getTileHeight() const { |
| 78 | return renderer.getTileHeight(); |
| 79 | } |
| 80 | |
| 81 | void setTileWidthPercentage(double percentage) { |
| 82 | renderer.setTileWidthPercentage(percentage); |
| 83 | } |
| 84 | |
| 85 | double getTileWidthPercentage() const { |
| 86 | return renderer.getTileWidthPercentage(); |
| 87 | } |
| 88 | |
| 89 | void setTileHeightPercentage(double percentage) { |
| 90 | renderer.setTileHeightPercentage(percentage); |
| 91 | } |
| 92 | |
| 93 | double getTileHeightPercentage() const { |
| 94 | return renderer.getTileHeightPercentage(); |
| 95 | } |
| 96 | |
| 97 | private: |
| 98 | TiledPictureRenderer renderer; |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 99 | typedef PictureBenchmark INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | class UnflattenPictureBenchmark : public PictureBenchmark { |
| 103 | public: |
keyar@chromium.org | 9d696c0 | 2012-08-07 17:11:33 +0000 | [diff] [blame] | 104 | virtual void run(SkPicture* pict) SK_OVERRIDE; |
| 105 | private: |
| 106 | typedef PictureBenchmark INHERITED; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | } |
| 110 | |
| 111 | #endif // PictureBenchmark_DEFINED |