1 /* 2 * Copyright (c) 2025 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 RS_UIFIRST_FRAMERATE_CONTROL_H 17 #define RS_UIFIRST_FRAMERATE_CONTROL_H 18 19 #include <parameter.h> 20 #include <parameters.h> 21 #include <string> 22 #include "pipeline/rs_surface_render_node.h" 23 #include "variable_frame_rate/rs_variable_frame_rate.h" 24 #include "transaction/rs_render_service_client.h" 25 #include <mutex> 26 27 namespace OHOS::Rosen { 28 class RSUifirstFrameRateControl { 29 public: 30 enum class SceneId { 31 LAUNCHER_APP_LAUNCH_FROM_ICON, 32 LAUNCHER_APP_SWIPE_TO_HOME, 33 GESTURE_TO_RECENTS, 34 LAUNCHER_APP_LAUNCH_FROM_RECENT, 35 EXIT_RECENT_2_HOME_ANI, 36 CLEAR_1_RECENT_ANI, 37 CLEAR_ALL_RECENT_ANI, 38 AOD_TO_LAUNCHER, 39 LOCKSCREEN_TO_LAUNCHER, 40 UNKNOWN 41 }; 42 GetSceneId(const std::string & sceneId)43 SceneId GetSceneId(const std::string& sceneId) 44 { 45 if (sceneId == "LAUNCHER_APP_LAUNCH_FROM_ICON") { 46 return SceneId::LAUNCHER_APP_LAUNCH_FROM_ICON; 47 } else if (sceneId == "LAUNCHER_APP_SWIPE_TO_HOME") { 48 return SceneId::LAUNCHER_APP_SWIPE_TO_HOME; 49 } else if (sceneId == "GESTURE_TO_RECENTS") { 50 return SceneId::GESTURE_TO_RECENTS; 51 } else if (sceneId == "LAUNCHER_APP_LAUNCH_FROM_RECENT") { 52 return SceneId::LAUNCHER_APP_LAUNCH_FROM_RECENT; 53 } else if (sceneId == "EXIT_RECENT_2_HOME_ANI") { 54 return SceneId::EXIT_RECENT_2_HOME_ANI; 55 } else if (sceneId == "CLEAR_1_RECENT_ANI") { 56 return SceneId::CLEAR_1_RECENT_ANI; 57 } else if (sceneId == "CLEAR_All_RECENT_ANI") { 58 return SceneId::CLEAR_ALL_RECENT_ANI; 59 } else if (sceneId == "AOD_TO_LAUNCHER") { 60 return SceneId::AOD_TO_LAUNCHER; 61 } else if (sceneId == "LOCKSCREEN_TO_LAUNCHER") { 62 return SceneId::LOCKSCREEN_TO_LAUNCHER; 63 } else { 64 return SceneId::UNKNOWN; 65 } 66 } 67 Instance()68 static RSUifirstFrameRateControl& Instance() 69 { 70 static RSUifirstFrameRateControl instance; 71 return instance; 72 } 73 74 void SetAnimationStartInfo(const DataBaseRs& eventInfo); 75 void SetAnimationEndInfo(const DataBaseRs& eventInfo); 76 bool JudgeMultiSubSurface(const RSSurfaceRenderNode& node); 77 bool SubThreadFrameDropDecision(const RSSurfaceRenderNode& node); 78 bool NeedRSUifirstControlFrameDrop(const RSSurfaceRenderNode& node); 79 bool GetUifirstFrameDropInternal(int); JudgeStartAnimation()80 bool JudgeStartAnimation() const 81 { 82 return startAnimationStatus_; 83 } 84 SetStartAnimation(bool status)85 void SetStartAnimation(bool status) 86 { 87 startAnimationStatus_ = status; 88 } 89 JudgeStopAnimation()90 bool JudgeStopAnimation() const 91 { 92 return stopAnimationStatus_; 93 } 94 SetStopAnimation(bool status)95 void SetStopAnimation(bool status) 96 { 97 stopAnimationStatus_ = status; 98 } 99 JudgeMultTaskAnimation()100 bool JudgeMultTaskAnimation() const 101 { 102 return multTaskAnimationStatus_; 103 } 104 SetMultTaskAnimation(bool status)105 void SetMultTaskAnimation(bool status) 106 { 107 multTaskAnimationStatus_ = status; 108 } 109 110 private: RSUifirstFrameRateControl()111 RSUifirstFrameRateControl() {} 112 std::mutex incrementCallCount_; 113 int callCount_ = 0; 114 bool startAnimationStatus_ = false; 115 bool stopAnimationStatus_ = false; 116 bool multTaskAnimationStatus_ = false; 117 bool forceRefreshOnce_ = true; 118 }; 119 } 120 #endif