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) { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 21 | uint32_t flags = fGM->getFlags(); |
| 22 | switch (backend) { |
| 23 | case kGPU_Backend: |
| 24 | return !(skiagm::GM::kSkipGPU_Flag & flags); |
| 25 | case kPDF_Backend: |
| 26 | return !(skiagm::GM::kSkipPDF_Flag & flags); |
| 27 | case kRaster_Backend: |
| 28 | // GM doesn't have an equivalent flag. If the GM has known issues with 565 then |
| 29 | // we skip it for ALL raster configs in bench. |
| 30 | return !(skiagm::GM::kSkip565_Flag & flags); |
| 31 | case kNonRendering_Backend: |
| 32 | return false; |
| 33 | default: |
| 34 | SkDEBUGFAIL("Unexpected backend type."); |
| 35 | return false; |
| 36 | } |
| 37 | } |
| 38 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 39 | void GMBench::onDraw(const int loops, SkCanvas* canvas) { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 40 | // Do we care about timing the draw of the background (once)? |
| 41 | // Does the GM ever rely on drawBackground to lazily compute something? |
| 42 | fGM->drawBackground(canvas); |
| 43 | for (int i = 0; i < loops; ++i) { |
| 44 | fGM->drawContent(canvas); |
| 45 | } |
| 46 | } |
| 47 | |
tfarina | f168b86 | 2014-06-19 12:32:29 -0700 | [diff] [blame] | 48 | SkIPoint GMBench::onGetSize() { |
commit-bot@chromium.org | 6adce67 | 2014-02-03 14:48:17 +0000 | [diff] [blame] | 49 | SkISize size = fGM->getISize(); |
| 50 | return SkIPoint::Make(size.fWidth, size.fHeight); |
| 51 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame^] | 52 | |