commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [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 | */ |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 7 | #ifndef GMBench_DEFINED |
| 8 | #define GMBench_DEFINED |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "bench/Benchmark.h" |
| 11 | #include "gm/gm.h" |
| 12 | #include "include/core/SkCanvas.h" |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * Runs a GM as a benchmark by repeatedly drawing the GM. |
| 16 | */ |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 17 | class GMBench : public Benchmark { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 18 | public: |
Ben Wagner | 406ff50 | 2019-08-12 16:39:24 -0400 | [diff] [blame] | 19 | GMBench(std::unique_ptr<skiagm::GM> gm); |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 20 | |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 21 | void modifyGrContextOptions(GrContextOptions* options) override { |
| 22 | return fGM->modifyGrContextOptions(options); |
| 23 | } |
| 24 | |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 25 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 26 | const char* onGetName() override; |
| 27 | bool isSuitableFor(Backend backend) override; |
Robert Phillips | 83b749a | 2020-06-25 11:41:19 -0400 | [diff] [blame^] | 28 | void onPerCanvasPreDraw(SkCanvas*) override; |
| 29 | void onPerCanvasPostDraw(SkCanvas*) override; |
| 30 | void onDraw(int loops, SkCanvas*) override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 31 | SkIPoint onGetSize() override; |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 32 | |
| 33 | private: |
Ben Wagner | 406ff50 | 2019-08-12 16:39:24 -0400 | [diff] [blame] | 34 | std::unique_ptr<skiagm::GM> fGM; |
Robert Phillips | 83b749a | 2020-06-25 11:41:19 -0400 | [diff] [blame^] | 35 | SkString fName; |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 36 | typedef Benchmark INHERITED; |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 37 | }; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 38 | |
| 39 | #endif |