Bug 1827491 [wpt PR 39482] - Update html5lib-tests generated tests, a=testonly
[gecko.git] / gfx / layers / AnimationStorageData.h
blobaa0a14b5c45b4955854c2ab09106cdb586364532
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_layers_AnimationStorageData_h
8 #define mozilla_layers_AnimationStorageData_h
10 #include "mozilla/dom/Nullable.h"
11 #include "mozilla/ServoStyleConsts.h" // for ComputedTimingFunction
12 #include "mozilla/layers/LayersMessages.h" // for TransformData, etc
13 #include "mozilla/layers/LayersTypes.h" // for LayersId
14 #include "mozilla/TimeStamp.h" // for TimeStamp
15 #include "mozilla/TimingParams.h"
16 #include "X11UndefineNone.h"
18 namespace mozilla {
20 namespace dom {
21 enum class CompositeOperation : uint8_t;
22 enum class IterationCompositeOperation : uint8_t;
23 }; // namespace dom
25 namespace layers {
27 struct PropertyAnimation {
28 struct SegmentData {
29 RefPtr<RawServoAnimationValue> mStartValue;
30 RefPtr<RawServoAnimationValue> mEndValue;
31 Maybe<mozilla::StyleComputedTimingFunction> mFunction;
32 float mStartPortion;
33 float mEndPortion;
34 dom::CompositeOperation mStartComposite;
35 dom::CompositeOperation mEndComposite;
37 nsTArray<SegmentData> mSegments;
38 TimingParams mTiming;
40 // These two variables correspond to the variables of the same name in
41 // KeyframeEffectReadOnly and are used for the same purpose: to skip composing
42 // animations whose progress has not changed.
43 dom::Nullable<double> mProgressOnLastCompose;
44 uint64_t mCurrentIterationOnLastCompose = 0;
45 // These two variables are used for a similar optimization above but are
46 // applied to the timing function in each keyframe.
47 uint32_t mSegmentIndexOnLastCompose = 0;
48 dom::Nullable<double> mPortionInSegmentOnLastCompose;
50 TimeStamp mOriginTime;
51 Maybe<TimeDuration> mStartTime;
52 TimeDuration mHoldTime;
53 float mPlaybackRate;
54 dom::IterationCompositeOperation mIterationComposite;
55 bool mIsNotPlaying;
57 // The information for scroll-driven animations.
58 Maybe<ScrollTimelineOptions> mScrollTimelineOptions;
60 void ResetLastCompositionValues() {
61 mCurrentIterationOnLastCompose = 0;
62 mSegmentIndexOnLastCompose = 0;
63 mProgressOnLastCompose.SetNull();
64 mPortionInSegmentOnLastCompose.SetNull();
68 struct PropertyAnimationGroup {
69 nsCSSPropertyID mProperty;
71 nsTArray<PropertyAnimation> mAnimations;
72 RefPtr<RawServoAnimationValue> mBaseStyle;
74 bool IsEmpty() const { return mAnimations.IsEmpty(); }
75 void Clear() {
76 mAnimations.Clear();
77 mBaseStyle = nullptr;
79 void ResetLastCompositionValues() {
80 for (PropertyAnimation& animation : mAnimations) {
81 animation.ResetLastCompositionValues();
86 struct AnimationStorageData {
87 // Each entry in the array represents an animation list for one property. For
88 // transform-like properties (e.g. transform, rotate etc.), there may be
89 // multiple entries depending on how many transform-like properties we have.
90 nsTArray<PropertyAnimationGroup> mAnimation;
91 Maybe<TransformData> mTransformData;
92 // For motion path. We cached the gfx path for optimization.
93 RefPtr<gfx::Path> mCachedMotionPath;
94 // This is used to communicate with the main-thread. E.g. to tell the fact
95 // that this animation needs to be pre-rendered again on the main-thread, etc.
96 LayersId mLayersId;
98 AnimationStorageData() = default;
99 AnimationStorageData(AnimationStorageData&& aOther) = default;
100 AnimationStorageData& operator=(AnimationStorageData&& aOther) = default;
102 // Avoid any copy because mAnimation could be a large array.
103 AnimationStorageData(const AnimationStorageData& aOther) = delete;
104 AnimationStorageData& operator=(const AnimationStorageData& aOther) = delete;
106 bool IsEmpty() const { return mAnimation.IsEmpty(); }
107 void Clear() {
108 mAnimation.Clear();
109 mTransformData.reset();
110 mCachedMotionPath = nullptr;
114 } // namespace layers
115 } // namespace mozilla
117 #endif // mozilla_layers_AnimationStorageData_h