blob: 75cee6c0639261f3b0e6e549cf7af9d07dda6409 [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 */
7
tfarinaf168b862014-06-19 12:32:29 -07008#include "Benchmark.h"
commit-bot@chromium.org6adce672014-02-03 14:48:17 +00009#include "SkCanvas.h"
tfarinaf168b862014-06-19 12:32:29 -070010#include "gm.h"
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000011
12/**
13 * Runs a GM as a benchmark by repeatedly drawing the GM.
14 */
tfarinaf168b862014-06-19 12:32:29 -070015class GMBench : public Benchmark {
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000016public:
17 // Constructor takes ownership of the GM param.
tfarinaf168b862014-06-19 12:32:29 -070018 GMBench(skiagm::GM* gm);
19 virtual ~GMBench();
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000020
21protected:
22 virtual const char* onGetName() SK_OVERRIDE;
23 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE;
24 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE;
25 virtual SkIPoint onGetSize() SK_OVERRIDE;
26
27private:
28 skiagm::GM* fGM;
29 SkString fName;
tfarinaf168b862014-06-19 12:32:29 -070030 typedef Benchmark INHERITED;
commit-bot@chromium.org6adce672014-02-03 14:48:17 +000031};