mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 18 | class SKPBench : public Benchmark { |
| 19 | public: |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 20 | SKPBench(const char* name, const SkPicture*, const SkIRect& devClip, SkScalar scale, |
| 21 | bool useMultiPictureDraw); |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 22 | ~SKPBench() override; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 23 | |
| 24 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 25 | 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; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 32 | |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 33 | 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 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 40 | private: |
| 41 | SkAutoTUnref<const SkPicture> fPic; |
| 42 | const SkIRect fClip; |
| 43 | const SkScalar fScale; |
| 44 | SkString fName; |
mtklein | 9628905 | 2014-09-10 12:05:59 -0700 | [diff] [blame] | 45 | SkString fUniqueName; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 46 | |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 47 | const bool fUseMultiPictureDraw; |
| 48 | SkTDArray<SkSurface*> fSurfaces; // for MultiPictureDraw |
| 49 | SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw |
| 50 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 51 | typedef Benchmark INHERITED; |
| 52 | }; |
| 53 | |
| 54 | #endif |