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 PictureRenderer* renderer() { return fRenderer; } 53 54 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; } 55 56 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu); 57 58 void setWriter(PictureResultsWriter* writer) { fWriter = writer; } 59 60 private: 61 int fRepeats; 62 PictureRenderer* fRenderer; 63 TimerData::Result fTimerResult; 64 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values 65 bool fTimeIndividualTiles; 66 bool fPurgeDecodedTex; 67 bool fPreprocess; 68 69 PictureResultsWriter* fWriter; 70 71 Timer* setupTimer(bool useGLTimer = true); 72 }; 73 74 } 75 76 #endif // PictureBenchmark_DEFINED 77