• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, bool useMultiPictureDraw);
32 
setRepeats(int repeats)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      */
setTimeIndividualTiles(bool indiv)42     void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; }
timeIndividualTiles()43     bool timeIndividualTiles() const { return fTimeIndividualTiles; }
44 
setPurgeDecodedTex(bool purgeDecodedTex)45     void setPurgeDecodedTex(bool purgeDecodedTex) { fPurgeDecodedTex = purgeDecodedTex; }
purgeDecodedText()46     bool purgeDecodedText() const { return fPurgeDecodedTex; }
47 
48     PictureRenderer* setRenderer(PictureRenderer*);
renderer()49     PictureRenderer* renderer() { return fRenderer; }
50 
setTimerResultType(TimerData::Result resultType)51     void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
52 
53     void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
54 
setWriter(PictureResultsWriter * writer)55     void setWriter(PictureResultsWriter* writer) { fWriter = writer; }
56 
57 private:
58     int               fRepeats;
59     PictureRenderer*  fRenderer;
60     TimerData::Result fTimerResult;
61     uint32_t          fTimerTypes; // bitfield of TimerData::TimerFlags values
62     bool              fTimeIndividualTiles;
63     bool              fPurgeDecodedTex;
64 
65     PictureResultsWriter* fWriter;
66 
67     Timer* setupTimer(bool useGLTimer = true);
68 };
69 
70 }
71 
72 #endif  // PictureBenchmark_DEFINED
73