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.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/GMBench.h"
|
2014-02-03 14:48:17 +00:00
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
GMBench::GMBench(skiagm::GM* gm) : fGM(gm) {
|
2014-07-31 19:13:48 +00:00
|
|
|
fName.printf("GM_%s", gm->getName());
|
2014-02-03 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
GMBench::~GMBench() { delete fGM; }
|
2014-02-03 14:48:17 +00:00
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
const char* GMBench::onGetName() {
|
2014-02-03 14:48:17 +00:00
|
|
|
return fName.c_str();
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
bool GMBench::isSuitableFor(Backend backend) {
|
2015-01-23 19:07:07 +00:00
|
|
|
return kNonRendering_Backend != backend;
|
2014-02-03 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-01 16:43:39 +00:00
|
|
|
void GMBench::onDraw(int loops, SkCanvas* canvas) {
|
2016-05-16 16:09:18 +00:00
|
|
|
fGM->setMode(skiagm::GM::kBench_Mode);
|
2014-02-03 14:48:17 +00:00
|
|
|
// Do we care about timing the draw of the background (once)?
|
|
|
|
// Does the GM ever rely on drawBackground to lazily compute something?
|
|
|
|
fGM->drawBackground(canvas);
|
|
|
|
for (int i = 0; i < loops; ++i) {
|
2017-12-15 19:25:11 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
2014-02-03 14:48:17 +00:00
|
|
|
fGM->drawContent(canvas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
SkIPoint GMBench::onGetSize() {
|
2014-02-03 14:48:17 +00:00
|
|
|
SkISize size = fGM->getISize();
|
|
|
|
return SkIPoint::Make(size.fWidth, size.fHeight);
|
|
|
|
}
|