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 |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 10 | |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 11 | #include "SkTypes.h" |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 12 | #include "PictureRenderer.h" |
commit-bot@chromium.org | 55fd612 | 2013-07-31 20:00:56 +0000 | [diff] [blame] | 13 | #include "TimerData.h" |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 14 | |
keyar@chromium.org | 77a5522 | 2012-08-20 15:03:47 +0000 | [diff] [blame] | 15 | class BenchTimer; |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 16 | class SkBenchLogger; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 17 | class SkPicture; |
| 18 | class SkString; |
| 19 | |
| 20 | namespace sk_tools { |
| 21 | |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 22 | class PictureBenchmark { |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 23 | public: |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 24 | PictureBenchmark(); |
| 25 | |
| 26 | ~PictureBenchmark(); |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 27 | |
scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 28 | /** |
| 29 | * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output |
| 30 | * via fLogger. |
| 31 | */ |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 32 | void run(SkPicture* pict); |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 33 | |
| 34 | void setRepeats(int repeats) { |
| 35 | fRepeats = repeats; |
| 36 | } |
| 37 | |
scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 38 | /** |
| 39 | * If true, tells run to log separate timing data for each individual tile. Each tile will be |
| 40 | * drawn fRepeats times. Requires the PictureRenderer set by setRenderer to be a |
| 41 | * TiledPictureRenderer. |
| 42 | */ |
scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 43 | void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; } |
scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 44 | |
| 45 | bool timeIndividualTiles() { return fTimeIndividualTiles; } |
| 46 | |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 47 | PictureRenderer* setRenderer(PictureRenderer*); |
keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 48 | |
commit-bot@chromium.org | 55fd612 | 2013-07-31 20:00:56 +0000 | [diff] [blame] | 49 | void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; } |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 50 | |
commit-bot@chromium.org | 55fd612 | 2013-07-31 20:00:56 +0000 | [diff] [blame] | 51 | void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu); |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 52 | |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 53 | void setLogger(SkBenchLogger* logger) { fLogger = logger; } |
| 54 | |
| 55 | private: |
commit-bot@chromium.org | 55fd612 | 2013-07-31 20:00:56 +0000 | [diff] [blame] | 56 | int fRepeats; |
| 57 | SkBenchLogger* fLogger; |
| 58 | PictureRenderer* fRenderer; |
| 59 | TimerData::Result fTimerResult; |
| 60 | uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values |
| 61 | bool fTimeIndividualTiles; |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 62 | |
| 63 | void logProgress(const char msg[]); |
| 64 | |
robertphillips@google.com | f9d0c95 | 2013-02-07 16:21:22 +0000 | [diff] [blame] | 65 | BenchTimer* setupTimer(bool useGLTimer = true); |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif // PictureBenchmark_DEFINED |