blob: 01b4e1d886d6a7f64e69876c95e6c2f199a5efdf [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 */
42 void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = true; }
43
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 setDeviceType(PictureRenderer::SkDeviceTypes deviceType) {
49 if (fRenderer != NULL) {
50 fRenderer->setDeviceType(deviceType);
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000051 }
52 }
53
scroggo@google.com5239c322012-09-11 19:15:32 +000054 void setLogPerIter(bool log) { fLogPerIter = log; }
55
56 void setPrintMin(bool min) { fPrintMin = min; }
57
58 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) {
59 fShowWallTime = wall;
60 fShowTruncatedWallTime = truncatedWall;
61 fShowCpuTime = cpu;
62 fShowTruncatedCpuTime = truncatedCpu;
63 fShowGpuTime = gpu;
64 }
65
scroggo@google.com9a412522012-09-07 15:21:18 +000066 void setLogger(SkBenchLogger* logger) { fLogger = logger; }
67
68private:
scroggo@google.com5239c322012-09-11 19:15:32 +000069 int fRepeats;
70 SkBenchLogger* fLogger;
71 PictureRenderer* fRenderer;
72 bool fLogPerIter;
73 bool fPrintMin;
74 bool fShowWallTime;
75 bool fShowTruncatedWallTime;
76 bool fShowCpuTime;
77 bool fShowTruncatedCpuTime;
78 bool fShowGpuTime;
scroggo@google.comcbcef702012-12-13 22:09:28 +000079 bool fTimeIndividualTiles;
scroggo@google.com9a412522012-09-07 15:21:18 +000080
81 void logProgress(const char msg[]);
82
robertphillips@google.comf9d0c952013-02-07 16:21:22 +000083 BenchTimer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000084};
85
86}
87
88#endif // PictureBenchmark_DEFINED