layer_animator_collection.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2014 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_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_
  5. #define UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_
  6. #include <set>
  7. #include "base/callback.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "base/time/time.h"
  11. #include "ui/compositor/compositor_animation_observer.h"
  12. #include "ui/compositor/compositor_export.h"
  13. namespace ui {
  14. class Compositor;
  15. class LayerAnimator;
  16. // A collection of LayerAnimators that should be updated at each animation step
  17. // in the compositor.
  18. class COMPOSITOR_EXPORT LayerAnimatorCollection
  19. : public CompositorAnimationObserver {
  20. public:
  21. explicit LayerAnimatorCollection(Compositor* compositor);
  22. LayerAnimatorCollection(const LayerAnimatorCollection&) = delete;
  23. LayerAnimatorCollection& operator=(const LayerAnimatorCollection&) = delete;
  24. ~LayerAnimatorCollection() override;
  25. void StartAnimator(scoped_refptr<LayerAnimator> animator);
  26. void StopAnimator(scoped_refptr<LayerAnimator> animator);
  27. bool HasActiveAnimators() const;
  28. base::TimeTicks last_tick_time() const { return last_tick_time_; }
  29. // CompositorAnimationObserver:
  30. void OnAnimationStep(base::TimeTicks timestamp) override;
  31. void OnCompositingShuttingDown(Compositor* compositor) override;
  32. private:
  33. raw_ptr<Compositor> compositor_;
  34. base::TimeTicks last_tick_time_;
  35. std::set<scoped_refptr<LayerAnimator> > animators_;
  36. };
  37. } // namespace ui
  38. #endif // UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_