1 // Copyright (c) 2012 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 
5 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_DELEGATE_H_
6 #define UI_COMPOSITOR_LAYER_ANIMATION_DELEGATE_H_
7 
8 #include "base/optional.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/compositor/compositor_export.h"
11 #include "ui/compositor/property_change_reason.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/rounded_corners_f.h"
14 #include "ui/gfx/transform.h"
15 
16 namespace cc {
17 class Layer;
18 }
19 
20 namespace ui {
21 
22 class Layer;
23 class LayerAnimatorCollection;
24 class LayerThreadedAnimationDelegate;
25 
26 // Layer animations interact with the layers using this interface.
27 class COMPOSITOR_EXPORT LayerAnimationDelegate {
28  public:
29   virtual void SetBoundsFromAnimation(const gfx::Rect& bounds,
30                                       PropertyChangeReason reason) = 0;
31   virtual void SetTransformFromAnimation(const gfx::Transform& transform,
32                                          PropertyChangeReason reason) = 0;
33   virtual void SetOpacityFromAnimation(float opacity,
34                                        PropertyChangeReason reason) = 0;
35   virtual void SetVisibilityFromAnimation(bool visibility,
36                                           PropertyChangeReason reason) = 0;
37   virtual void SetBrightnessFromAnimation(float brightnes,
38                                           PropertyChangeReason reasons) = 0;
39   virtual void SetGrayscaleFromAnimation(float grayscale,
40                                          PropertyChangeReason reason) = 0;
41   virtual void SetColorFromAnimation(SkColor color,
42                                      PropertyChangeReason reason) = 0;
43   virtual void SetClipRectFromAnimation(const gfx::Rect& clip_rect,
44                                         PropertyChangeReason reason) = 0;
45   virtual void SetRoundedCornersFromAnimation(
46       const gfx::RoundedCornersF& rounded_corners,
47       PropertyChangeReason reason) = 0;
48   virtual void ScheduleDrawForAnimation() = 0;
49   virtual const gfx::Rect& GetBoundsForAnimation() const = 0;
50   virtual gfx::Transform GetTransformForAnimation() const = 0;
51   virtual float GetOpacityForAnimation() const = 0;
52   virtual bool GetVisibilityForAnimation() const = 0;
53   virtual float GetBrightnessForAnimation() const = 0;
54   virtual float GetGrayscaleForAnimation() const = 0;
55   virtual SkColor GetColorForAnimation() const = 0;
56   virtual gfx::Rect GetClipRectForAnimation() const = 0;
57   virtual gfx::RoundedCornersF GetRoundedCornersForAnimation() const = 0;
58   virtual float GetDeviceScaleFactor() const = 0;
59   virtual ui::Layer* GetLayer() = 0;
60   virtual cc::Layer* GetCcLayer() const = 0;
61   virtual LayerAnimatorCollection* GetLayerAnimatorCollection() = 0;
62   virtual LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() = 0;
63   // Returns base::nullopt if the frame number is not available, e.g. when
64   // Layer is not attached to a Compositor. Otherwise, returns the frame number.
65   virtual base::Optional<int> GetFrameNumber() const = 0;
66   virtual float GetRefreshRate() const = 0;
67 
68  protected:
~LayerAnimationDelegate()69   virtual ~LayerAnimationDelegate() {}
70 };
71 
72 }  // namespace ui
73 
74 #endif  // UI_COMPOSITOR_LAYER_ANIMATION_DELEGATE_H_
75