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
|
|
|
|
2019-08-12 20:39:24 +00:00
|
|
|
GMBench::GMBench(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
|
|
|
|
fName.printf("GM_%s", fGM->getName());
|
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);
|
|
|
|
}
|