blob: c9fb766d42123939b20ce0225df60f127ffff5c2 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "bench/Benchmark.h"
11#include "gm/gm.h"
12#include "include/core/SkCanvas.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:
Ben Wagner406ff502019-08-12 16:39:24 -040019 GMBench(std::unique_ptr<skiagm::GM> gm);
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000020
Brian Salomon0b4d8aa2017-10-11 15:34:27 -040021 void modifyGrContextOptions(GrContextOptions* options) override {
22 return fGM->modifyGrContextOptions(options);
23 }
24
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000025protected:
mtklein36352bf2015-03-25 18:17:31 -070026 const char* onGetName() override;
27 bool isSuitableFor(Backend backend) override;
Robert Phillips83b749a2020-06-25 11:41:19 -040028 void onPerCanvasPreDraw(SkCanvas*) override;
29 void onPerCanvasPostDraw(SkCanvas*) override;
30 void onDraw(int loops, SkCanvas*) override;
mtklein36352bf2015-03-25 18:17:31 -070031 SkIPoint onGetSize() override;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000032
33private:
Ben Wagner406ff502019-08-12 16:39:24 -040034 std::unique_ptr<skiagm::GM> fGM;
Robert Phillips83b749a2020-06-25 11:41:19 -040035 SkString fName;
Robert Phillipse9229532020-06-26 10:10:49 -040036 bool fGpuSetupFailed = false;
37
John Stiles7571f9e2020-09-02 22:42:33 -040038 using INHERITED = Benchmark;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000039};
mtklein92007582014-08-01 07:46:52 -070040
41#endif