blob: 1f01ce533ad726ac42e11a9c2a9fbb2f93beb88d [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; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000044
45 bool timeIndividualTiles() { return fTimeIndividualTiles; }
46
scroggo@google.com5239c322012-09-11 19:15:32 +000047 PictureRenderer* setRenderer(PictureRenderer*);
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000048
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000049 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
scroggo@google.com5239c322012-09-11 19:15:32 +000050
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000051 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
scroggo@google.com5239c322012-09-11 19:15:32 +000052
scroggo@google.com9a412522012-09-07 15:21:18 +000053 void setLogger(SkBenchLogger* logger) { fLogger = logger; }
54
55private:
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000056 int fRepeats;
57 SkBenchLogger* fLogger;
58 PictureRenderer* fRenderer;
59 TimerData::Result fTimerResult;
60 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values
61 bool fTimeIndividualTiles;
scroggo@google.com9a412522012-09-07 15:21:18 +000062
63 void logProgress(const char msg[]);
64
robertphillips@google.comf9d0c952013-02-07 16:21:22 +000065 BenchTimer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000066};
67
68}
69
70#endif // PictureBenchmark_DEFINED