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 "PictureRenderer.h" 12 #include "PictureResultsWriter.h" 13 #include "SkTypes.h" 14 #include "TimerData.h" 15 16 class SkPicture; 17 class Timer; 18 19 namespace sk_tools { 20 21 class PictureBenchmark { 22 public: 23 PictureBenchmark(); 24 25 ~PictureBenchmark(); 26 27 /** 28 * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output 29 * via fWriter. 30 */ 31 void run(SkPicture* pict); 32 33 void setRepeats(int repeats) { 34 fRepeats = repeats; 35 } 36 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 */ 42 void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; } 43 bool timeIndividualTiles() const { return fTimeIndividualTiles; } 44 45 void setPurgeDecodedTex(bool purgeDecodedTex) { fPurgeDecodedTex = purgeDecodedTex; } 46 bool purgeDecodedText() const { return fPurgeDecodedTex; } 47 48 void setPreprocess(bool preprocess) { fPreprocess = preprocess; } 49 bool preprocess() const { return fPreprocess; } 50 51 PictureRenderer* setRenderer(PictureRenderer*); 52 53 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; } 54 55 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu); 56 57 void setWriter(PictureResultsWriter* writer) { fWriter = writer; } 58 59 private: 60 int fRepeats; 61 PictureRenderer* fRenderer; 62 TimerData::Result fTimerResult; 63 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values 64 bool fTimeIndividualTiles; 65 bool fPurgeDecodedTex; 66 bool fPreprocess; 67 68 PictureResultsWriter* fWriter; 69 70 Timer* setupTimer(bool useGLTimer = true); 71 }; 72 73 } 74 75 #endif // PictureBenchmark_DEFINED 76