1/*
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#ifndef GMBench_DEFINED
8#define GMBench_DEFINED
9
10#include "Benchmark.h"
11#include "SkCanvas.h"
12#include "gm.h"
13
14/**
15 * Runs a GM as a benchmark by repeatedly drawing the GM.
16 */
17class GMBench : public Benchmark {
18public:
19    // Constructor takes ownership of the GM param.
20    GMBench(skiagm::GM* gm);
21    ~GMBench() override;
22
23    void modifyGrContextOptions(GrContextOptions* options) override {
24        return fGM->modifyGrContextOptions(options);
25    }
26
27protected:
28    const char* onGetName() override;
29    bool isSuitableFor(Backend backend) override;
30    void onDraw(int loops, SkCanvas* canvas) override;
31    SkIPoint onGetSize() override;
32
33private:
34    skiagm::GM* fGM;
35    SkString    fName;
36    typedef Benchmark INHERITED;
37};
38
39#endif
40