animation_observer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_LOTTIE_ANIMATION_OBSERVER_H_
  5. #define UI_LOTTIE_ANIMATION_OBSERVER_H_
  6. #include "base/component_export.h"
  7. #include "base/observer_list_types.h"
  8. namespace lottie {
  9. class Animation;
  10. class COMPONENT_EXPORT(UI_LOTTIE) AnimationObserver
  11. : public base::CheckedObserver {
  12. public:
  13. // Called when the animation started playing.
  14. virtual void AnimationWillStartPlaying(const Animation* animation) {}
  15. // Called when one animation cycle has completed. This happens when a linear
  16. // animation has reached its end, or a loop/throbbing animation has finished
  17. // a cycle.
  18. virtual void AnimationCycleEnded(const Animation* animation) {}
  19. // Called when the animation has successfully resumed.
  20. virtual void AnimationResuming(const Animation* animation) {}
  21. // Called after each animation frame is painted. Note this is not synonymous
  22. // with the frame ultimately being rendered on screen; it only means the frame
  23. // has been submitted to the rest of the graphics pipeline for rendering.
  24. //
  25. // |t| is the normalized timestamp in range [0, 1] of the frame just painted.
  26. virtual void AnimationFramePainted(const Animation* animation, float t) {}
  27. // Called in the Animation's destructor. Observers may remove themselves
  28. // within their implementation.
  29. virtual void AnimationIsDeleting(const Animation* animation) {}
  30. protected:
  31. ~AnimationObserver() override = default;
  32. };
  33. } // namespace lottie
  34. #endif // UI_LOTTIE_ANIMATION_OBSERVER_H_