skia2/bench/GMBench.cpp
Brian Osman 7035a8e797 Fix benches that aren't really timing what we want
Remove full clears from benches
Fix unbounded canvas modification in GM benches

Bug: skia:
Change-Id: Ie3d67282714a7b4e980aec399056c0e9df330993
Reviewed-on: https://skia-review.googlesource.com/86040
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-18 15:56:02 +00:00

39 lines
975 B
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GMBench.h"
GMBench::GMBench(skiagm::GM* gm) : fGM(gm) {
fName.printf("GM_%s", gm->getName());
}
GMBench::~GMBench() { delete fGM; }
const char* GMBench::onGetName() {
return fName.c_str();
}
bool GMBench::isSuitableFor(Backend backend) {
return kNonRendering_Backend != backend;
}
void GMBench::onDraw(int loops, SkCanvas* canvas) {
fGM->setMode(skiagm::GM::kBench_Mode);
// 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) {
SkAutoCanvasRestore acr(canvas, true);
fGM->drawContent(canvas);
}
}
SkIPoint GMBench::onGetSize() {
SkISize size = fGM->getISize();
return SkIPoint::Make(size.fWidth, size.fHeight);
}