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); |
| 22 | ~SKPBench() SK_OVERRIDE; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 23 | |
| 24 | protected: |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame^] | 25 | const char* onGetName() SK_OVERRIDE; |
| 26 | const char* onGetUniqueName() SK_OVERRIDE; |
| 27 | void onPerCanvasPreDraw(SkCanvas*) SK_OVERRIDE; |
| 28 | void onPerCanvasPostDraw(SkCanvas*) SK_OVERRIDE; |
| 29 | bool isSuitableFor(Backend backend) SK_OVERRIDE; |
| 30 | void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE; |
| 31 | SkIPoint onGetSize() SK_OVERRIDE; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 32 | |
| 33 | private: |
| 34 | SkAutoTUnref<const SkPicture> fPic; |
| 35 | const SkIRect fClip; |
| 36 | const SkScalar fScale; |
| 37 | SkString fName; |
mtklein | 9628905 | 2014-09-10 12:05:59 -0700 | [diff] [blame] | 38 | SkString fUniqueName; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 39 | |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame^] | 40 | const bool fUseMultiPictureDraw; |
| 41 | SkTDArray<SkSurface*> fSurfaces; // for MultiPictureDraw |
| 42 | SkTDArray<SkIRect> fTileRects; // for MultiPictureDraw |
| 43 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 44 | typedef Benchmark INHERITED; |
| 45 | }; |
| 46 | |
| 47 | #endif |