blob: e2240528278ad588497663a1121a449858766d44 [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:
24 virtual const char* onGetName() SK_OVERRIDE;
25 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE;
26 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE;
27 virtual SkIPoint onGetSize() SK_OVERRIDE;
28
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