blob: 53ab5c244343a6736fc6826a2d30501ab356f292 [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
10#include "SkTypes.h"
11#include "SkRefCnt.h"
12#include "PictureRenderer.h"
13
14class SkPicture;
15class SkString;
16
17namespace sk_tools {
18
19class PictureBenchmark : public SkRefCnt {
20public:
21 virtual void run(SkPicture* pict) = 0;
22
23 void setRepeats(int repeats) {
24 fRepeats = repeats;
25 }
26
27 int getRepeats() const {
28 return fRepeats;
29 }
30
31protected:
32 int fRepeats;
keyar@chromium.org9d696c02012-08-07 17:11:33 +000033
34private:
35 typedef SkRefCnt INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +000036};
37
38class PipePictureBenchmark : public PictureBenchmark {
39public:
keyar@chromium.org9d696c02012-08-07 17:11:33 +000040 virtual void run(SkPicture* pict) SK_OVERRIDE;
keyar@chromium.org163b5672012-08-01 17:53:29 +000041private:
42 PipePictureRenderer renderer;
keyar@chromium.org9d696c02012-08-07 17:11:33 +000043 typedef PictureBenchmark INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +000044};
45
46class RecordPictureBenchmark : public PictureBenchmark {
47public:
keyar@chromium.org9d696c02012-08-07 17:11:33 +000048 virtual void run(SkPicture* pict) SK_OVERRIDE;
49private:
50 typedef PictureBenchmark INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +000051};
52
53class SimplePictureBenchmark : public PictureBenchmark {
54public:
keyar@chromium.org9d696c02012-08-07 17:11:33 +000055 virtual void run(SkPicture* pict) SK_OVERRIDE;
keyar@chromium.org163b5672012-08-01 17:53:29 +000056private:
57 SimplePictureRenderer renderer;
keyar@chromium.org9d696c02012-08-07 17:11:33 +000058 typedef PictureBenchmark INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +000059};
60
61class TiledPictureBenchmark : public PictureBenchmark {
62public:
keyar@chromium.org9d696c02012-08-07 17:11:33 +000063 virtual void run(SkPicture* pict) SK_OVERRIDE;
keyar@chromium.org163b5672012-08-01 17:53:29 +000064
65 void setTileWidth(int width) {
66 renderer.setTileWidth(width);
67 }
68
69 int getTileWidth() const {
70 return renderer.getTileWidth();
71 }
72
73 void setTileHeight(int height) {
74 renderer.setTileHeight(height);
75 }
76
77 int getTileHeight() const {
78 return renderer.getTileHeight();
79 }
80
81 void setTileWidthPercentage(double percentage) {
82 renderer.setTileWidthPercentage(percentage);
83 }
84
85 double getTileWidthPercentage() const {
86 return renderer.getTileWidthPercentage();
87 }
88
89 void setTileHeightPercentage(double percentage) {
90 renderer.setTileHeightPercentage(percentage);
91 }
92
93 double getTileHeightPercentage() const {
94 return renderer.getTileHeightPercentage();
95 }
96
97private:
98 TiledPictureRenderer renderer;
keyar@chromium.org9d696c02012-08-07 17:11:33 +000099 typedef PictureBenchmark INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +0000100};
101
102class UnflattenPictureBenchmark : public PictureBenchmark {
103public:
keyar@chromium.org9d696c02012-08-07 17:11:33 +0000104 virtual void run(SkPicture* pict) SK_OVERRIDE;
105private:
106 typedef PictureBenchmark INHERITED;
keyar@chromium.org163b5672012-08-01 17:53:29 +0000107};
108
109}
110
111#endif // PictureBenchmark_DEFINED