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" |
| 13 | |
keyar@chromium.org | 77a5522 | 2012-08-20 15:03:47 +0000 | [diff] [blame] | 14 | class BenchTimer; |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 15 | class SkBenchLogger; |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 16 | class SkPicture; |
| 17 | class SkString; |
| 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 |
| 29 | * via fLogger. |
| 30 | */ |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 31 | void run(SkPicture* pict); |
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; } |
scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 43 | |
| 44 | bool timeIndividualTiles() { return fTimeIndividualTiles; } |
| 45 | |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 46 | PictureRenderer* setRenderer(PictureRenderer*); |
keyar@chromium.org | fe6391a | 2012-08-20 15:03:41 +0000 | [diff] [blame] | 47 | |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 48 | void setLogPerIter(bool log) { fLogPerIter = log; } |
| 49 | |
| 50 | void setPrintMin(bool min) { fPrintMin = min; } |
| 51 | |
| 52 | void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) { |
| 53 | fShowWallTime = wall; |
| 54 | fShowTruncatedWallTime = truncatedWall; |
| 55 | fShowCpuTime = cpu; |
| 56 | fShowTruncatedCpuTime = truncatedCpu; |
| 57 | fShowGpuTime = gpu; |
| 58 | } |
| 59 | |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 60 | void setLogger(SkBenchLogger* logger) { fLogger = logger; } |
| 61 | |
| 62 | private: |
scroggo@google.com | 5239c32 | 2012-09-11 19:15:32 +0000 | [diff] [blame] | 63 | int fRepeats; |
| 64 | SkBenchLogger* fLogger; |
| 65 | PictureRenderer* fRenderer; |
| 66 | bool fLogPerIter; |
| 67 | bool fPrintMin; |
| 68 | bool fShowWallTime; |
| 69 | bool fShowTruncatedWallTime; |
| 70 | bool fShowCpuTime; |
| 71 | bool fShowTruncatedCpuTime; |
| 72 | bool fShowGpuTime; |
scroggo@google.com | cbcef70 | 2012-12-13 22:09:28 +0000 | [diff] [blame] | 73 | bool fTimeIndividualTiles; |
scroggo@google.com | 9a41252 | 2012-09-07 15:21:18 +0000 | [diff] [blame] | 74 | |
| 75 | void logProgress(const char msg[]); |
| 76 | |
robertphillips@google.com | f9d0c95 | 2013-02-07 16:21:22 +0000 | [diff] [blame] | 77 | BenchTimer* setupTimer(bool useGLTimer = true); |
keyar@chromium.org | 163b567 | 2012-08-01 17:53:29 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } |
| 81 | |
| 82 | #endif // PictureBenchmark_DEFINED |