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 | */ |
| 7 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 8 | #include "GMBench.h" |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 9 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 10 | GMBench::GMBench(skiagm::GM* gm) : fGM(gm) { |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 11 | fName.printf("GM_%s", gm->getName()); |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 12 | } |
| 13 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 14 | GMBench::~GMBench() { delete fGM; } |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 15 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 16 | const char* GMBench::onGetName() { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 17 | return fName.c_str(); |
| 18 | } |
| 19 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 20 | bool GMBench::isSuitableFor(Backend backend) { |
mtklein | 1c40292 | 2015-01-23 11:07:07 -0800 | [diff] [blame] | 21 | return kNonRendering_Backend != backend; |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 22 | } |
| 23 | |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 24 | void GMBench::onDraw(int loops, SkCanvas* canvas) { |
bsalomon | d584d46 | 2016-05-16 09:09:18 -0700 | [diff] [blame] | 25 | fGM->setMode(skiagm::GM::kBench_Mode); |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 26 | // Do we care about timing the draw of the background (once)? |
| 27 | // Does the GM ever rely on drawBackground to lazily compute something? |
| 28 | fGM->drawBackground(canvas); |
| 29 | for (int i = 0; i < loops; ++i) { |
Brian Osman | 7035a8e | 2017-12-15 14:25:11 -0500 | [diff] [blame] | 30 | SkAutoCanvasRestore acr(canvas, true); |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 31 | fGM->drawContent(canvas); |
| 32 | } |
| 33 | } |
| 34 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 35 | SkIPoint GMBench::onGetSize() { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 36 | SkISize size = fGM->getISize(); |
| 37 | return SkIPoint::Make(size.fWidth, size.fHeight); |
| 38 | } |