blob: 70c56d994972d1f5a9f88f029c8977cbe099fe6c [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"
13
keyar@chromium.org77a55222012-08-20 15:03:47 +000014class BenchTimer;
scroggo@google.com9a412522012-09-07 15:21:18 +000015class SkBenchLogger;
keyar@chromium.org163b5672012-08-01 17:53:29 +000016class SkPicture;
17class SkString;
18
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
29 * via fLogger.
30 */
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; }
scroggo@google.comcbcef702012-12-13 22:09:28 +000043
44 bool timeIndividualTiles() { return fTimeIndividualTiles; }
45
scroggo@google.com5239c322012-09-11 19:15:32 +000046 PictureRenderer* setRenderer(PictureRenderer*);
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000047
scroggo@google.com5239c322012-09-11 19:15:32 +000048 void setLogPerIter(bool log) { fLogPerIter = log; }
49
50 void setPrintMin(bool min) { fPrintMin = min; }
51
52 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) {
53 fShowWallTime = wall;
54 fShowTruncatedWallTime = truncatedWall;
55 fShowCpuTime = cpu;
56 fShowTruncatedCpuTime = truncatedCpu;
57 fShowGpuTime = gpu;
58 }
59
scroggo@google.com9a412522012-09-07 15:21:18 +000060 void setLogger(SkBenchLogger* logger) { fLogger = logger; }
61
62private:
scroggo@google.com5239c322012-09-11 19:15:32 +000063 int fRepeats;
64 SkBenchLogger* fLogger;
65 PictureRenderer* fRenderer;
66 bool fLogPerIter;
67 bool fPrintMin;
68 bool fShowWallTime;
69 bool fShowTruncatedWallTime;
70 bool fShowCpuTime;
71 bool fShowTruncatedCpuTime;
72 bool fShowGpuTime;
scroggo@google.comcbcef702012-12-13 22:09:28 +000073 bool fTimeIndividualTiles;
scroggo@google.com9a412522012-09-07 15:21:18 +000074
75 void logProgress(const char msg[]);
76
robertphillips@google.comf9d0c952013-02-07 16:21:22 +000077 BenchTimer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000078};
79
80}
81
82#endif // PictureBenchmark_DEFINED