增加系统帧率对外接口
authorCaisking <Casiking@zhihuishixun.com>
Fri, 26 Sep 2025 06:32:11 +0000 (14:32 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Fri, 26 Sep 2025 06:32:11 +0000 (14:32 +0800)
code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/frameworks/common/low_power_manager.cpp
code/sdk/middleware/services/gui/uikit/proprietary/src/ui/innerkits/common/low_power_manager.h

index 07a9a43..d927b39 100644 (file)
@@ -372,7 +372,7 @@ static constexpr int16_t REBOOT_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 36;
     void SetFrequence(int freq)
     {
         GraphicService::GetInstance()->PostGraphicEvent([=]
-                                                        { SetFrequenceInner(freq); });
+                                                        {OHOS::LowPowerManager::GetInstance()->SetMaxFrequence(freq);});
     }
 
     void NotifyScreenOn(void)
index 94f987a..dde8d21 100644 (file)
@@ -35,14 +35,15 @@ void LowPowerManager::TryToEnterLowPower()
     }
 
     uint32_t period = TaskManager::GetInstance()->GetMinimumCustomerTaskPeriod();
-    int freq = (period == 0) ? 1 : 1000 / static_cast<int>(period);
+    int tmp = (period == 0) ? 1 : 1000 / static_cast<int>(period); // 1000: ms
+    int freq = (tmp > maxFrequence_) ? maxFrequence_ : tmp;
     SetFrequenceInner(freq);
 }
 
 void LowPowerManager::ExitLowPower()
 {
     lastExitTime_ = HALTick::GetInstance().GetTime();
-    SetFrequenceInner(60); // 60: 60fps
+    SetFrequenceInner(maxFrequence_);
 }
 
 bool LowPowerManager::IsLiteSurfaceInRootView()
@@ -59,4 +60,12 @@ bool LowPowerManager::IsLiteSurfaceInRootView()
 
     return (view == RootView::GetInstance());
 }
+
+void LowPowerManager::SetMaxFrequence(uint32_t freq)
+{
+    maxFrequence_ = freq;
+    if (GetFrequence() > maxFrequence_) {
+        SetFrequenceInner(maxFrequence_);
+    }
+}
 } // namespace OHOS
index e0dc860..9964c6f 100644 (file)
@@ -49,8 +49,11 @@ public:
      */
     bool IsLiteSurfaceInRootView();
 
+    void SetMaxFrequence(uint32_t freq);
+
 private:
     uint32_t lastExitTime_ = 0;
+    uint32_t maxFrequence_ = 60;
 };
 } // OHOS
 #endif // GRAPHIC_LOW_POWER_MANAGER