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 "bench/GMBench.h" 9 GMBench(std::unique_ptr<skiagm::GM> gm)10GMBench::GMBench(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) { 11 fName.printf("GM_%s", fGM->getName()); 12 } 13 onGetName()14const char* GMBench::onGetName() { 15 return fName.c_str(); 16 } 17 isSuitableFor(Backend backend)18bool GMBench::isSuitableFor(Backend backend) { 19 return kNonRendering_Backend != backend; 20 } 21 onDraw(int loops,SkCanvas * canvas)22void GMBench::onDraw(int loops, SkCanvas* canvas) { 23 fGM->setMode(skiagm::GM::kBench_Mode); 24 // Do we care about timing the draw of the background (once)? 25 // Does the GM ever rely on drawBackground to lazily compute something? 26 fGM->drawBackground(canvas); 27 for (int i = 0; i < loops; ++i) { 28 SkAutoCanvasRestore acr(canvas, true); 29 fGM->drawContent(canvas); 30 } 31 } 32 onGetSize()33SkIPoint GMBench::onGetSize() { 34 SkISize size = fGM->getISize(); 35 return SkIPoint::Make(size.fWidth, size.fHeight); 36 } 37