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 #ifndef GMBench_DEFINED 8 #define GMBench_DEFINED 9 10 #include "bench/Benchmark.h" 11 #include "gm/gm.h" 12 #include "include/core/SkCanvas.h" 13 14 /** 15 * Runs a GM as a benchmark by repeatedly drawing the GM. 16 */ 17 class GMBench : public Benchmark { 18 public: 19 GMBench(std::unique_ptr<skiagm::GM> gm); 20 modifyGrContextOptions(GrContextOptions * options)21 void modifyGrContextOptions(GrContextOptions* options) override { 22 return fGM->modifyGrContextOptions(options); 23 } 24 25 protected: 26 const char* onGetName() override; 27 bool isSuitableFor(Backend backend) override; 28 void onDraw(int loops, SkCanvas* canvas) override; 29 SkIPoint onGetSize() override; 30 31 private: 32 std::unique_ptr<skiagm::GM> fGM; 33 SkString fName; 34 typedef Benchmark INHERITED; 35 }; 36 37 #endif 38