blob: 43ca9812a18433a751a00f408e7579e700a10b10 [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:
mtklein72c9faa2015-01-09 10:06:39 -080024 const char* onGetName() SK_OVERRIDE;
25 bool isSuitableFor(Backend backend) SK_OVERRIDE;
26 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE;
27 SkIPoint onGetSize() SK_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