• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "GMBench.h"
9 
GMBench(skiagm::GM * gm)10 GMBench::GMBench(skiagm::GM* gm) : fGM(gm) {
11     fName.printf("GM_%s", gm->getName());
12 }
13 
~GMBench()14 GMBench::~GMBench() { delete fGM; }
15 
onGetName()16 const char* GMBench::onGetName() {
17     return fName.c_str();
18 }
19 
isSuitableFor(Backend backend)20 bool GMBench::isSuitableFor(Backend backend) {
21     return kNonRendering_Backend != backend;
22 }
23 
onDraw(int loops,SkCanvas * canvas)24 void GMBench::onDraw(int loops, SkCanvas* canvas) {
25     fGM->setMode(skiagm::GM::kBench_Mode);
26     // Do we care about timing the draw of the background (once)?
27     // Does the GM ever rely on drawBackground to lazily compute something?
28     fGM->drawBackground(canvas);
29     for (int i = 0; i < loops; ++i) {
30         fGM->drawContent(canvas);
31     }
32 }
33 
onGetSize()34 SkIPoint GMBench::onGetSize() {
35     SkISize size = fGM->getISize();
36     return SkIPoint::Make(size.fWidth, size.fHeight);
37 }
38