GMBench.cpp 981 B

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