aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/PictureBenchmark.h
blob: 70c56d994972d1f5a9f88f029c8977cbe099fe6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef PictureBenchmark_DEFINED
#define PictureBenchmark_DEFINED

#include "SkTypes.h"
#include "PictureRenderer.h"

class BenchTimer;
class SkBenchLogger;
class SkPicture;
class SkString;

namespace sk_tools {

class PictureBenchmark {
public:
    PictureBenchmark();

    ~PictureBenchmark();

    /**
     * Draw the provided SkPicture fRepeats times while collecting timing data, and log the output
     * via fLogger.
     */
    void run(SkPicture* pict);

    void setRepeats(int repeats) {
        fRepeats = repeats;
    }

    /**
     * If true, tells run to log separate timing data for each individual tile. Each tile will be
     * drawn fRepeats times. Requires the PictureRenderer set by setRenderer to be a
     * TiledPictureRenderer.
     */
    void setTimeIndividualTiles(bool indiv) { fTimeIndividualTiles = indiv; }

    bool timeIndividualTiles() { return fTimeIndividualTiles; }

    PictureRenderer* setRenderer(PictureRenderer*);

    void setLogPerIter(bool log) { fLogPerIter = log; }

    void setPrintMin(bool min) { fPrintMin = min; }

    void setTimersToShow(bool wall, bool truncatedWall, bool cpu, bool truncatedCpu, bool gpu) {
        fShowWallTime = wall;
        fShowTruncatedWallTime = truncatedWall;
        fShowCpuTime = cpu;
        fShowTruncatedCpuTime = truncatedCpu;
        fShowGpuTime = gpu;
    }

    void setLogger(SkBenchLogger* logger) { fLogger = logger; }

private:
    int              fRepeats;
    SkBenchLogger*   fLogger;
    PictureRenderer* fRenderer;
    bool             fLogPerIter;
    bool             fPrintMin;
    bool             fShowWallTime;
    bool             fShowTruncatedWallTime;
    bool             fShowCpuTime;
    bool             fShowTruncatedCpuTime;
    bool             fShowGpuTime;
    bool             fTimeIndividualTiles;

    void logProgress(const char msg[]);

    BenchTimer* setupTimer(bool useGLTimer = true);
};

}

#endif  // PictureBenchmark_DEFINED