SKPAnimationBench.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2015 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 SKPAnimationBench_DEFINED
  8. #define SKPAnimationBench_DEFINED
  9. #include "bench/SKPBench.h"
  10. #include "tools/timer/Timer.h"
  11. #include "include/utils/SkRandom.h"
  12. /**
  13. * Runs an SkPicture as a benchmark by repeatedly drawing it, first centering the picture and
  14. * for each step it concats the passed in matrix
  15. */
  16. class SKPAnimationBench : public SKPBench {
  17. public:
  18. class Animation : public SkRefCnt {
  19. public:
  20. virtual const char* getTag() = 0;
  21. virtual void preConcatFrameMatrix(double animationTimeMs, const SkIRect& devBounds,
  22. SkMatrix* drawMatrix) = 0;
  23. virtual ~Animation() {}
  24. };
  25. SKPAnimationBench(const char* name, const SkPicture*, const SkIRect& devClip, sk_sp<Animation>,
  26. bool doLooping);
  27. static sk_sp<Animation> MakeZoomAnimation(SkScalar zoomMax, double zoomPeriodMs);
  28. protected:
  29. const char* onGetUniqueName() override;
  30. void onPerCanvasPreDraw(SkCanvas* canvas) override;
  31. void drawMPDPicture() override {
  32. SK_ABORT("MPD not supported\n");
  33. }
  34. void drawPicture() override;
  35. private:
  36. sk_sp<Animation> fAnimation;
  37. SkRandom fAnimationTime;
  38. SkString fUniqueName;
  39. SkIRect fDevBounds;
  40. typedef SKPBench INHERITED;
  41. };
  42. #endif