1 /* 2 * Copyright (c) 2022 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_UI_ANIMATION_MANAGER_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_UI_ANIMATION_MANAGER_H 18 19 #include <list> 20 #include <memory> 21 #include <unordered_map> 22 23 #include "common/rs_common_def.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class RSModifierManager; 28 class RSAnimation; 29 class RSRenderAnimation; 30 class RSPropertyBase; 31 class RSRenderPropertyBase; 32 33 class RS_EXPORT RSUIAnimationManager { 34 public: 35 RSUIAnimationManager(); 36 virtual ~RSUIAnimationManager() = default; 37 38 void AddAnimation(const std::shared_ptr<RSRenderAnimation>& animation, 39 const std::shared_ptr<RSAnimation>& uiAnimation); 40 void RemoveAnimation(const AnimationId keyId); 41 const std::shared_ptr<RSRenderAnimation> GetAnimation(AnimationId id) const; 42 void AddAnimatableProp(const PropertyId id, 43 const std::shared_ptr<RSPropertyBase>& uiProperty, 44 const std::shared_ptr<RSRenderPropertyBase>& renderProperty); 45 const std::shared_ptr<RSRenderPropertyBase> GetRenderProperty( 46 const PropertyId id); 47 void RemoveProperty(const PropertyId id); 48 49 bool Animate(int64_t time); 50 void Draw(); 51 52 private: 53 void OnAnimationRemove(const std::shared_ptr<RSRenderAnimation>& animation); 54 void OnAnimationAdd(const std::shared_ptr<RSRenderAnimation>& animation); 55 void OnAnimationFinished(const std::shared_ptr<RSRenderAnimation>& animation); 56 bool UpdateAnimateValue(const std::shared_ptr<RSRenderAnimation>& animation, int64_t time); 57 void RemoveUIAnimation(const AnimationId id); 58 59 std::shared_ptr<RSModifierManager> modifierManager_; 60 std::unordered_map<AnimationId, std::shared_ptr<RSRenderAnimation>> animations_; 61 std::unordered_map<AnimationId, std::shared_ptr<RSAnimation>> uiAnimations_; 62 std::unordered_map<PropertyId, int> animationNum_; 63 std::unordered_map<PropertyId, std::pair<std::shared_ptr<RSPropertyBase>, 64 std::shared_ptr<RSRenderPropertyBase>>> properties_; 65 66 }; 67 } // namespace Rosen 68 } // namespace OHOS 69 70 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_UI_ANIMATION_MANAGER_H 71