2014-02-03 14:48:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2014-08-01 14:46:52 +00:00
|
|
|
#ifndef GMBench_DEFINED
|
|
|
|
#define GMBench_DEFINED
|
2014-02-03 14:48:17 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/Benchmark.h"
|
|
|
|
#include "gm/gm.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
2014-02-03 14:48:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs a GM as a benchmark by repeatedly drawing the GM.
|
|
|
|
*/
|
2014-06-19 19:32:29 +00:00
|
|
|
class GMBench : public Benchmark {
|
2014-02-03 14:48:17 +00:00
|
|
|
public:
|
2019-08-12 20:39:24 +00:00
|
|
|
GMBench(std::unique_ptr<skiagm::GM> gm);
|
2014-02-03 14:48:17 +00:00
|
|
|
|
2017-10-11 19:34:27 +00:00
|
|
|
void modifyGrContextOptions(GrContextOptions* options) override {
|
|
|
|
return fGM->modifyGrContextOptions(options);
|
|
|
|
}
|
|
|
|
|
2014-02-03 14:48:17 +00:00
|
|
|
protected:
|
2015-03-26 01:17:31 +00:00
|
|
|
const char* onGetName() override;
|
|
|
|
bool isSuitableFor(Backend backend) override;
|
2020-06-25 15:41:19 +00:00
|
|
|
void onPerCanvasPreDraw(SkCanvas*) override;
|
|
|
|
void onPerCanvasPostDraw(SkCanvas*) override;
|
|
|
|
void onDraw(int loops, SkCanvas*) override;
|
2015-03-26 01:17:31 +00:00
|
|
|
SkIPoint onGetSize() override;
|
2014-02-03 14:48:17 +00:00
|
|
|
|
|
|
|
private:
|
2019-08-12 20:39:24 +00:00
|
|
|
std::unique_ptr<skiagm::GM> fGM;
|
2020-06-25 15:41:19 +00:00
|
|
|
SkString fName;
|
2020-06-26 14:10:49 +00:00
|
|
|
bool fGpuSetupFailed = false;
|
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = Benchmark;
|
2014-02-03 14:48:17 +00:00
|
|
|
};
|
2014-08-01 14:46:52 +00:00
|
|
|
|
|
|
|
#endif
|