GMBench.h 910 B

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