blob: 1ddd18ea16358634a19c31fd625983402d976082 [file] [log] [blame]
keyar@chromium.org163b5672012-08-01 17:53:29 +00001/*
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.com5239c322012-09-11 19:15:32 +000010
keyar@chromium.org163b5672012-08-01 17:53:29 +000011#include "PictureRenderer.h"
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000012#include "PictureResultsWriter.h"
tfarinaf168b862014-06-19 12:32:29 -070013#include "SkTypes.h"
14#include "TimerData.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000015
16class SkPicture;
mtklein9ac68ee2014-06-20 11:29:20 -070017class Timer;
keyar@chromium.org163b5672012-08-01 17:53:29 +000018
19namespace sk_tools {
20
scroggo@google.com5239c322012-09-11 19:15:32 +000021class PictureBenchmark {
keyar@chromium.org163b5672012-08-01 17:53:29 +000022public:
scroggo@google.com5239c322012-09-11 19:15:32 +000023 PictureBenchmark();
24
25 ~PictureBenchmark();
scroggo@google.com9a412522012-09-07 15:21:18 +000026
scroggo@google.comcbcef702012-12-13 22:09:28 +000027 /**
28 * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000029 * via fWriter.
scroggo@google.comcbcef702012-12-13 22:09:28 +000030 */
scroggo@google.com9a412522012-09-07 15:21:18 +000031 void run(SkPicture* pict);
keyar@chromium.org163b5672012-08-01 17:53:29 +000032
33 void setRepeats(int repeats) {
34 fRepeats = repeats;
35 }
36
scroggo@google.comcbcef702012-12-13 22:09:28 +000037 /**
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.com161e1ba2013-03-04 16:41:06 +000042 void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; }
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000043 bool timeIndividualTiles() const { return fTimeIndividualTiles; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000044
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000045 void setPurgeDecodedTex(bool purgeDecodedTex) { fPurgeDecodedTex = purgeDecodedTex; }
46 bool purgeDecodedText() const { return fPurgeDecodedTex; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000047
commit-bot@chromium.orgc8733292014-04-11 15:54:14 +000048 void setPreprocess(bool preprocess) { fPreprocess = preprocess; }
49 bool preprocess() const { return fPreprocess; }
50
scroggo@google.com5239c322012-09-11 19:15:32 +000051 PictureRenderer* setRenderer(PictureRenderer*);
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000052
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000053 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
scroggo@google.com5239c322012-09-11 19:15:32 +000054
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000055 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
scroggo@google.com5239c322012-09-11 19:15:32 +000056
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000057 void setWriter(PictureResultsWriter* writer) { fWriter = writer; }
scroggo@google.com9a412522012-09-07 15:21:18 +000058
59private:
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000060 int fRepeats;
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000061 PictureRenderer* fRenderer;
62 TimerData::Result fTimerResult;
63 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values
64 bool fTimeIndividualTiles;
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000065 bool fPurgeDecodedTex;
commit-bot@chromium.orgc8733292014-04-11 15:54:14 +000066 bool fPreprocess;
scroggo@google.com9a412522012-09-07 15:21:18 +000067
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000068 PictureResultsWriter* fWriter;
scroggo@google.com9a412522012-09-07 15:21:18 +000069
mtklein9ac68ee2014-06-20 11:29:20 -070070 Timer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000071};
72
73}
74
75#endif // PictureBenchmark_DEFINED