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) {
|
2014-02-03 14:48:17 +00:00
|
|
|
uint32_t flags = fGM->getFlags();
|
|
|
|
switch (backend) {
|
|
|
|
case kGPU_Backend:
|
|
|
|
return !(skiagm::GM::kSkipGPU_Flag & flags);
|
|
|
|
case kPDF_Backend:
|
|
|
|
return !(skiagm::GM::kSkipPDF_Flag & flags);
|
|
|
|
case kRaster_Backend:
|
|
|
|
// GM doesn't have an equivalent flag. If the GM has known issues with 565 then
|
|
|
|
// we skip it for ALL raster configs in bench.
|
|
|
|
return !(skiagm::GM::kSkip565_Flag & flags);
|
|
|
|
case kNonRendering_Backend:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("Unexpected backend type.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|