blob: c9ec80c64325aa0edd95c14001bbb8f1dcdd0a08 [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
23protected:
mtklein36352bf2015-03-25 18:17:31 -070024 const char* onGetName() override;
25 bool isSuitableFor(Backend backend) override;
mtkleina1ebeb22015-10-01 09:43:39 -070026 void onDraw(int loops, SkCanvas* canvas) override;
mtklein36352bf2015-03-25 18:17:31 -070027 SkIPoint onGetSize() override;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000028
29private:
30 skiagm::GM* fGM;
31 SkString fName;
tfarinaf168b862014-06-19 12:32:29 -070032 typedef Benchmark INHERITED;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000033};
mtklein92007582014-08-01 07:46:52 -070034
35#endif