• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_ANIMATION_MANAGER_H
17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_MANAGER_H
18 
19 #include <list>
20 #include <memory>
21 #include <unordered_map>
22 
23 #include "common/rs_common_def.h"
24 #include "common/rs_macros.h"
25 #include "modifier/rs_modifier_type.h"
26 
27 namespace OHOS {
28 namespace Rosen {
29 class RSDirtyRegionManager;
30 class RSPaintFilterCanvas;
31 class RSProperties;
32 class RSRenderAnimation;
33 class RSRenderNode;
34 
35 class RSB_EXPORT RSAnimationManager {
36 public:
37     RSAnimationManager() = default;
38     ~RSAnimationManager() = default;
39 
40     void AddAnimation(const std::shared_ptr<RSRenderAnimation>& animation);
41     void RemoveAnimation(AnimationId keyId);
42     const std::shared_ptr<RSRenderAnimation> GetAnimation(AnimationId id) const;
43     void FilterAnimationByPid(pid_t pid);
44 
45     std::pair<bool, bool> Animate(int64_t time, bool nodeIsOnTheTree);
46 
47     // spring animation related
48     void RegisterSpringAnimation(PropertyId propertyId, AnimationId animId);
49     void UnregisterSpringAnimation(PropertyId propertyId, AnimationId animId);
50     std::shared_ptr<RSRenderAnimation> QuerySpringAnimation(PropertyId propertyId);
51 
52 private:
53     void OnAnimationFinished(const std::shared_ptr<RSRenderAnimation>& animation);
54 
55     std::unordered_map<AnimationId, std::shared_ptr<RSRenderAnimation>> animations_;
56     std::unordered_map<PropertyId, AnimationId> springAnimations_;
57 
58     friend class RSRenderNode;
59 };
60 } // namespace Rosen
61 } // namespace OHOS
62 
63 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_MANAGER_H