blob: 3b645e97346df2d13bd428794caa82324ed56069 [file] [log] [blame]
mtklein92007582014-08-01 07:46:52 -07001/*
2 * Copyright 2014 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 SKPBench_DEFINED
9#define SKPBench_DEFINED
10
11#include "Benchmark.h"
12#include "SkCanvas.h"
13#include "SkPicture.h"
14
15/**
16 * Runs an SkPicture as a benchmark by repeatedly drawing it scaled inside a device clip.
17 */
18class SKPBench : public Benchmark {
19public:
robertphillips5b693772014-11-21 06:19:36 -080020 SKPBench(const char* name, const SkPicture*, const SkIRect& devClip, SkScalar scale,
21 bool useMultiPictureDraw);
mtklein36352bf2015-03-25 18:17:31 -070022 ~SKPBench() override;
mtklein92007582014-08-01 07:46:52 -070023
24protected:
mtklein36352bf2015-03-25 18:17:31 -070025 const char* onGetName() override;
26 const char* onGetUniqueName() override;
27 void onPerCanvasPreDraw(SkCanvas*) override;
28 void onPerCanvasPostDraw(SkCanvas*) override;
29 bool isSuitableFor(Backend backend) override;
30 void onDraw(const int loops, SkCanvas* canvas) override;
31 SkIPoint onGetSize() override;
mtklein92007582014-08-01 07:46:52 -070032
joshualitt261c3ad2015-04-27 09:16:57 -070033 virtual void drawMPDPicture();
34 virtual void drawPicture();
35
36 const SkPicture* picture() const { return fPic; }
37 const SkTDArray<SkSurface*>& surfaces() const { return fSurfaces; }
38 const SkTDArray<SkIRect>& tileRects() const { return fTileRects; }
39
mtklein92007582014-08-01 07:46:52 -070040private:
41 SkAutoTUnref<const SkPicture> fPic;
42 const SkIRect fClip;
43 const SkScalar fScale;
44 SkString fName;
mtklein96289052014-09-10 12:05:59 -070045 SkString fUniqueName;
mtklein92007582014-08-01 07:46:52 -070046
robertphillips5b693772014-11-21 06:19:36 -080047 const bool fUseMultiPictureDraw;
48 SkTDArray<SkSurface*> fSurfaces; // for MultiPictureDraw
49 SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw
50
mtklein92007582014-08-01 07:46:52 -070051 typedef Benchmark INHERITED;
52};
53
54#endif