blob: 82ca3c9c71d8f0142fbec6aafa8a7fc09db8f8a1 [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);
21 virtual ~GMBench();
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;
26 void onDraw(const int loops, SkCanvas* canvas) override;
27 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