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