blob: 5a917ad2a7cc6935f6f4e3973c89321105b51147 [file] [log] [blame]
commit-bot@chromium.org6adce672014-02-03 14:48:17 +00001/*
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 */
mtklein92007582014-08-01 07:46:52 -07007#ifndef GMBench_DEFINED
8#define GMBench_DEFINED
commit-bot@chromium.org6adce672014-02-03 14:48:17 +00009
tfarinaf168b862014-06-19 12:32:29 -070010#include "Benchmark.h"
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000011#include "SkCanvas.h"
tfarinaf168b862014-06-19 12:32:29 -070012#include "gm.h"
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000013
14/**
15 * Runs a GM as a benchmark by repeatedly drawing the GM.
16 */
tfarinaf168b862014-06-19 12:32:29 -070017class GMBench : public Benchmark {
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000018public:
19 // Constructor takes ownership of the GM param.
tfarinaf168b862014-06-19 12:32:29 -070020 GMBench(skiagm::GM* gm);
Brian Salomond3b65972017-03-22 12:05:03 -040021 ~GMBench() override;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000022
Brian Salomon0b4d8aa2017-10-11 15:34:27 -040023 void modifyGrContextOptions(GrContextOptions* options) override {
24 return fGM->modifyGrContextOptions(options);
25 }
26
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000027protected:
mtklein36352bf2015-03-25 18:17:31 -070028 const char* onGetName() override;
29 bool isSuitableFor(Backend backend) override;
mtkleina1ebeb22015-10-01 09:43:39 -070030 void onDraw(int loops, SkCanvas* canvas) override;
mtklein36352bf2015-03-25 18:17:31 -070031 SkIPoint onGetSize() override;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000032
33private:
34 skiagm::GM* fGM;
35 SkString fName;
tfarinaf168b862014-06-19 12:32:29 -070036 typedef Benchmark INHERITED;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000037};
mtklein92007582014-08-01 07:46:52 -070038
39#endif