blob: 99eca6bcc066dc0851a6fcc78902532fffbee589 [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 */
robertphillips78c71272014-10-09 04:59:19 -070031 void run(SkPicture* pict, bool useMultiPictureDraw);
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
scroggo@google.com5239c322012-09-11 19:15:32 +000048 PictureRenderer* setRenderer(PictureRenderer*);
robertphillips754f4e92014-09-18 13:52:08 -070049 PictureRenderer* renderer() { return fRenderer; }
keyar@chromium.orgfe6391a2012-08-20 15:03:41 +000050
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000051 void setTimerResultType(TimerData::Result resultType) { fTimerResult = resultType; }
scroggo@google.com5239c322012-09-11 19:15:32 +000052
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000053 void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu);
scroggo@google.com5239c322012-09-11 19:15:32 +000054
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000055 void setWriter(PictureResultsWriter* writer) { fWriter = writer; }
scroggo@google.com9a412522012-09-07 15:21:18 +000056
57private:
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000058 int fRepeats;
commit-bot@chromium.org55fd6122013-07-31 20:00:56 +000059 PictureRenderer* fRenderer;
60 TimerData::Result fTimerResult;
61 uint32_t fTimerTypes; // bitfield of TimerData::TimerFlags values
62 bool fTimeIndividualTiles;
robertphillips@google.com94d8f1e2013-12-18 17:25:33 +000063 bool fPurgeDecodedTex;
scroggo@google.com9a412522012-09-07 15:21:18 +000064
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000065 PictureResultsWriter* fWriter;
scroggo@google.com9a412522012-09-07 15:21:18 +000066
mtklein9ac68ee2014-06-20 11:29:20 -070067 Timer* setupTimer(bool useGLTimer = true);
keyar@chromium.org163b5672012-08-01 17:53:29 +000068};
69
70}
71
72#endif // PictureBenchmark_DEFINED