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; |
| 33 | }; |
| 34 | |
| 35 | class PipePictureBenchmark : public PictureBenchmark { |
| 36 | public: |
| 37 | virtual void run(SkPicture* pict); |
| 38 | private: |
| 39 | PipePictureRenderer renderer; |
| 40 | }; |
| 41 | |
| 42 | class RecordPictureBenchmark : public PictureBenchmark { |
| 43 | public: |
| 44 | virtual void run(SkPicture* pict); |
| 45 | }; |
| 46 | |
| 47 | class SimplePictureBenchmark : public PictureBenchmark { |
| 48 | public: |
| 49 | virtual void run(SkPicture* pict); |
| 50 | private: |
| 51 | SimplePictureRenderer renderer; |
| 52 | }; |
| 53 | |
| 54 | class TiledPictureBenchmark : public PictureBenchmark { |
| 55 | public: |
| 56 | virtual void run(SkPicture* pict); |
| 57 | |
| 58 | void setTileWidth(int width) { |
| 59 | renderer.setTileWidth(width); |
| 60 | } |
| 61 | |
| 62 | int getTileWidth() const { |
| 63 | return renderer.getTileWidth(); |
| 64 | } |
| 65 | |
| 66 | void setTileHeight(int height) { |
| 67 | renderer.setTileHeight(height); |
| 68 | } |
| 69 | |
| 70 | int getTileHeight() const { |
| 71 | return renderer.getTileHeight(); |
| 72 | } |
| 73 | |
| 74 | void setTileWidthPercentage(double percentage) { |
| 75 | renderer.setTileWidthPercentage(percentage); |
| 76 | } |
| 77 | |
| 78 | double getTileWidthPercentage() const { |
| 79 | return renderer.getTileWidthPercentage(); |
| 80 | } |
| 81 | |
| 82 | void setTileHeightPercentage(double percentage) { |
| 83 | renderer.setTileHeightPercentage(percentage); |
| 84 | } |
| 85 | |
| 86 | double getTileHeightPercentage() const { |
| 87 | return renderer.getTileHeightPercentage(); |
| 88 | } |
| 89 | |
| 90 | private: |
| 91 | TiledPictureRenderer renderer; |
| 92 | }; |
| 93 | |
| 94 | class UnflattenPictureBenchmark : public PictureBenchmark { |
| 95 | public: |
| 96 | virtual void run(SkPicture* pict); |
| 97 | }; |
| 98 | |
| 99 | } |
| 100 | |
| 101 | #endif // PictureBenchmark_DEFINED |