• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PATH_ANIMATION_H
17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PATH_ANIMATION_H
18 
19 #include "animation/rs_interpolator.h"
20 #include "animation/rs_render_property_animation.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class RSRenderPathAnimation : public RSRenderPropertyAnimation<Vector2f> {
25 static constexpr float UNDEFINED_FLOAT = 0.0f;
26 public:
27     RSRenderPathAnimation(AnimationId id, const RSAnimatableProperty& property, const Vector2f& originPosition,
28         float originRotation, const std::shared_ptr<RSPath>& animationPath);
29 
30     ~RSRenderPathAnimation() = default;
31 
32     void SetInterpolator(const std::shared_ptr<RSInterpolator>& interpolator);
33 
34     const std::shared_ptr<RSInterpolator>& GetInterpolator() const;
35 
36     void SetRotationMode(const RotationMode& rotationMode);
37 
38     RotationMode GetRotationMode() const;
39 
40     void SetBeginFraction(float fraction);
41 
42     float GetBeginFraction() const;
43 
44     void SetEndFraction(float fraction);
45 
46     float GetEndFraction() const;
47 
48 #ifdef ROSEN_OHOS
49     bool Marshalling(Parcel& parcel) const override;
50     static RSRenderPathAnimation* Unmarshalling(Parcel& parcel);
51 #endif
52 
53 protected:
54     void OnAnimate(float fraction) override;
55 
56     void OnRemoveOnCompletion() override;
57 
58 private:
59 #ifdef ROSEN_OHOS
60     bool ParseParam(Parcel& parcel) override;
61 #endif
62     void SetPathValue(const Vector2f& position, float tangent);
63     RSRenderPathAnimation() = default;
64 
65     float originRotation_ { UNDEFINED_FLOAT };
66     float beginFraction_ { FRACTION_MIN };
67     float endFraction_ { FRACTION_MAX };
68     RotationMode rotationMode_ { RotationMode::ROTATE_NONE };
69     std::shared_ptr<RSInterpolator> interpolator_ { RSInterpolator::DEFAULT };
70     std::shared_ptr<RSPath> animationPath_;
71 };
72 } // namespace Rosen
73 } // namespace OHOS
74 
75 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_RENDER_PATH_ANIMATION_H
76