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-06-19 19:32:29 +00:00
|
|
|
#include "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
|
|
|
}
|
|
|
|
|
2014-06-19 19:32:29 +00:00
|
|
|
void GMBench::onDraw(const int loops, SkCanvas* canvas) {
|
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) {
|
|
|
|
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);
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
|