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 OHOS_ROSEN_REMOTE_ANIMATION_H 17 #define OHOS_ROSEN_REMOTE_ANIMATION_H 18 19 #include <refbase.h> 20 #include <rs_iwindow_animation_controller.h> 21 #include <rs_window_animation_finished_callback.h> 22 #include <rs_window_animation_target.h> 23 24 #include "wm_common.h" 25 #include "window_controller.h" 26 #include "window_node.h" 27 #include "window_root.h" 28 #include "window_transition_info.h" 29 30 namespace OHOS { 31 namespace Rosen { 32 enum class TransitionEvent : uint32_t { 33 APP_TRANSITION, 34 HOME, 35 MINIMIZE, 36 CLOSE, 37 UNKNOWN, 38 BACK_TRANSITION, 39 }; 40 41 class RemoteAnimation : public RefBase { 42 public: 43 RemoteAnimation() = delete; 44 ~RemoteAnimation() = default; 45 46 static bool CheckTransition(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode, 47 sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& dstNode); 48 static TransitionEvent GetTransitionEvent(sptr<WindowTransitionInfo> srcInfo, 49 sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 50 static WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller); 51 static WMError NotifyAnimationTransition(sptr<WindowTransitionInfo> srcInfo, sptr<WindowTransitionInfo> dstInfo, 52 const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 53 static WMError NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode); 54 static WMError NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode, 55 TransitionEvent event); 56 static WMError NotifyAnimationBackTransition(sptr<WindowTransitionInfo> srcInfo, 57 sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode, 58 const sptr<WindowNode>& dstNode); 59 static void NotifyAnimationUpdateWallpaper(sptr<WindowNode> node); 60 static void OnRemoteDie(const sptr<IRemoteObject>& remoteObject); 61 static bool CheckAnimationController(); 62 static bool CheckRemoteAnimationEnabled(DisplayId displayId); 63 static WMError NotifyAnimationByHome(); 64 static WMError NotifyAnimationScreenUnlock(std::function<void(void)> callback); 65 static void SetMainTaskHandler(std::shared_ptr<AppExecFwk::EventHandler> handler); 66 static void NotifyAnimationTargetsUpdate(std::vector<uint32_t>& fullScreenWinIds, 67 std::vector<uint32_t>& floatWinIds); 68 static void SetAnimationFirst(bool animationFirst); 69 static void SetWindowControllerAndRoot(const sptr<WindowController>& windowController, 70 const sptr<WindowRoot>& windowRoot); 71 static bool IsRemoteAnimationEnabledAndFirst(DisplayId displayId = 0); 72 static void CallbackTimeOutProcess(); 73 static sptr<RSWindowAnimationFinishedCallback> CreateAnimationFinishedCallback( 74 const std::function<void(void)>& callback); IsAnimationFirst()75 static inline bool IsAnimationFirst() 76 { 77 return animationFirst_; 78 } 79 static bool isRemoteAnimationEnable_; 80 private: 81 static sptr<RSWindowAnimationTarget> CreateWindowAnimationTarget(sptr<WindowTransitionInfo> info, 82 const sptr<WindowNode>& windowNode); 83 static WMError NotifyAnimationStartApp(sptr<WindowTransitionInfo> srcInfo, 84 const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, 85 sptr<RSWindowAnimationTarget>& dstTarget, sptr<RSWindowAnimationFinishedCallback>& finishedCallback); 86 static sptr<RSWindowAnimationFinishedCallback> CreateShowAnimationFinishedCallback( 87 const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, bool needMinimizeSrcNode); 88 static sptr<RSWindowAnimationFinishedCallback> CreateHideAnimationFinishedCallback( 89 const sptr<WindowNode>& srcNode, TransitionEvent event); 90 static void ProcessNodeStateTask(sptr<WindowNode>& node); 91 static void GetExpectRect(const sptr<WindowNode>& dstNode, const sptr<RSWindowAnimationTarget>& dstTarget); 92 static void PostProcessShowCallback(const sptr<WindowNode>& node); 93 static void ExecuteFinalStateTask(sptr<WindowNode>& node); 94 static void GetAnimationTargetsForHome(std::vector<sptr<RSWindowAnimationTarget>>& animationTargets, 95 std::vector<wptr<WindowNode>> needMinimizeAppNodes); 96 static sptr<RSWindowAnimationFinishedCallback> GetTransitionFinishedCallback( 97 const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 98 99 static sptr<RSIWindowAnimationController> windowAnimationController_; 100 static wptr<WindowRoot> windowRoot_; 101 static std::weak_ptr<AppExecFwk::EventHandler> wmsTaskHandler_; 102 static wptr<WindowController> windowController_; 103 static bool animationFirst_; 104 static std::atomic<uint32_t> allocationId_; 105 }; 106 } // Rosen 107 } // OHOS 108 #endif // OHOS_ROSEN_REMOTE_ANIMATION_H 109