blob: e149f8c9e9f446843ee1d66eec5ae736a1512919 [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 "SkTypes.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000012#include "PictureRenderer.h"
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000013#include "TimerData.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000014
keyar@chromium.org77a55222012-08-20 15:03:47 +000015class BenchTimer;
scroggo@google.com9a412522012-09-07 15:21:18 +000016class SkBenchLogger;
keyar@chromium.org163b5672012-08-01 17:53:29 +000017class SkPicture;
18class SkString;
19
20namespace sk_tools {
21
scroggo@google.com5239c322012-09-11 19:15:32 +000022class PictureBenchmark {
keyar@chromium.org163b5672012-08-01 17:53:29 +000023public:
scroggo@google.com5239c322012-09-11 19:15:32 +000024 PictureBenchmark();
25
26 ~PictureBenchmark();
scroggo@google.com9a412522012-09-07 15:21:18 +000027
scroggo@google.comcbcef702012-12-13 22:09:28 +000028 /**
29 * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output
30 * via fLogger.
31 */
scroggo@google.com9a412522012-09-07 15:21:18 +000032 void run(SkPicture* pict);
keyar@chromium.org163b5672012-08-01 17:53:29 +000033
34 void setRepeats(int repeats) {
35 fRepeats = repeats;
36 }
37
scroggo@google.comcbcef702012-12-13 22:09:28 +000038 /**
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 */
scroggo@google.com161e1ba2013-03-04 16:41:06 +000043 void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; }
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000044 bool timeIndividualTiles() const { return fTimeIndividualTiles; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000045
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000046 void setPurgeDecodedTex(bool purgeDecodedTex) { fPurgeDecodedTex = purgeDecodedTex; }
47 bool purgeDecodedText() const { return fPurgeDecodedTex; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000048
commit-bot@chromium.orgc8733292014-04-11 15:54:14 +000049 void setPreprocess(bool preprocess) { fPreprocess = preprocess; }
50 bool preprocess() const { return fPreprocess; }
51
scroggo@google.com5239c322012-09-11 19:15:32 +000052 PictureRenderer* setRenderer(PictureRenderer*);
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000053
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000054 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
scroggo@google.com5239c322012-09-11 19:15:32 +000055
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000056 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
scroggo@google.com5239c322012-09-11 19:15:32 +000057
scroggo@google.com9a412522012-09-07 15:21:18 +000058 void setLogger(SkBenchLogger* logger) { fLogger = logger; }
59
60private:
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000061 int fRepeats;
62 SkBenchLogger* fLogger;
63 PictureRenderer* fRenderer;
64 TimerData::Result fTimerResult;
65 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values
66 bool fTimeIndividualTiles;
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000067 bool fPurgeDecodedTex;
commit-bot@chromium.orgc8733292014-04-11 15:54:14 +000068 bool fPreprocess;
scroggo@google.com9a412522012-09-07 15:21:18 +000069
70 void logProgress(const char msg[]);
71
robertphillips@google.comf9d0c952013-02-07 16:21:22 +000072 BenchTimer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000073};
74
75}
76
77#endif // PictureBenchmark_DEFINED