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 11 #include "SkTypes.h" 12 #include "PictureRenderer.h" 13 #include "TimerData.h" 14 15 class BenchTimer; 16 class SkBenchLogger; 17 class SkPicture; 18 class SkString; 19 20 namespace sk_tools { 21 22 class PictureBenchmark { 23 public: 24 PictureBenchmark(); 25 26 ~PictureBenchmark(); 27 28 /** 29 * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output 30 * via fLogger. 31 */ 32 void run(SkPicture* pict); 33 34 void setRepeats(int repeats) { 35 fRepeats = repeats; 36 } 37 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 */ 43 void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; } 44 45 bool timeIndividualTiles() { return fTimeIndividualTiles; } 46 47 PictureRenderer* setRenderer(PictureRenderer*); 48 49 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; } 50 51 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu); 52 53 void setLogger(SkBenchLogger* logger) { fLogger = logger; } 54 55 private: 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; 62 63 void logProgress(const char msg[]); 64 65 BenchTimer* setupTimer(bool useGLTimer = true); 66 }; 67 68 } 69 70 #endif // PictureBenchmark_DEFINED 71