mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-30 10:43:03 +00:00
!33625 FrameRateRange新增rateType
Merge pull request !33625 from zsw/report_hisysevent
This commit is contained in:
commit
e638d8dfb3
@ -48,7 +48,7 @@ public:
|
||||
|
||||
virtual void RequestFrame();
|
||||
|
||||
virtual void FlushFrameRate(int32_t rate, bool isAnimatorStopped) {}
|
||||
virtual void FlushFrameRate(int32_t rate, bool isAnimatorStopped, int32_t rateTyte) {}
|
||||
|
||||
virtual void SetTaskExecutor(const RefPtr<TaskExecutor>& taskExecutor) {}
|
||||
|
||||
|
@ -124,11 +124,13 @@ void UIDisplaySync::DelFromPipeline(WeakPtr<PipelineBase>& pipelineContext)
|
||||
{
|
||||
auto context = GetCurrentContext();
|
||||
if (!context) {
|
||||
TAG_LOGE(AceLogTag::ACE_DISPLAY_SYNC, "[DisplaySync] CurrentContext is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<UIDisplaySyncManager> dsm = context->GetOrCreateUIDisplaySyncManager();
|
||||
if (!dsm) {
|
||||
TAG_LOGE(AceLogTag::ACE_DISPLAY_SYNC, "[DisplaySync] DSM is nullptr.");
|
||||
return;
|
||||
}
|
||||
dsm->RemoveDisplaySync(AceType::Claim(this));
|
||||
|
@ -44,6 +44,10 @@ void UIDisplaySyncManager::DispatchFunc(int64_t nanoTimestamp)
|
||||
if (rateRange->IsValid()) {
|
||||
displaySyncRange_->Merge(*rateRange);
|
||||
}
|
||||
TAG_LOGD(AceLogTag::ACE_DISPLAY_SYNC, "UIDisplaySyncMapSize:%{public}d Id:%{public}d"
|
||||
"FrameRateRange: {%{public}d, %{public}d, %{public}d}",
|
||||
static_cast<int32_t>(uiDisplaySyncMap_.size()), static_cast<int32_t>(displaySync->GetId()),
|
||||
rateRange->min_, rateRange->max_, rateRange->preferred_);
|
||||
} else {
|
||||
uiDisplaySyncMap_.erase(Id);
|
||||
}
|
||||
@ -63,9 +67,14 @@ bool UIDisplaySyncManager::HasDisplaySync(const RefPtr<UIDisplaySync>& displaySy
|
||||
bool UIDisplaySyncManager::AddDisplaySync(const RefPtr<UIDisplaySync>& displaySync)
|
||||
{
|
||||
if (HasDisplaySync(displaySync)) {
|
||||
TAG_LOGD(AceLogTag::ACE_DISPLAY_SYNC, "DisplaySyncId[%{public}d] is existed.",
|
||||
static_cast<int32_t>(displaySync->GetId()));
|
||||
return false;
|
||||
}
|
||||
ACE_SCOPED_TRACE("AddDisplaySync Id:%d", static_cast<int32_t>(displaySync->GetId()));
|
||||
uiDisplaySyncMap_[displaySync->GetId()] = displaySync;
|
||||
TAG_LOGD(AceLogTag::ACE_DISPLAY_SYNC, "AddDisplaySync MapSize: %{public}d expected: %{public}d.",
|
||||
static_cast<int32_t>(uiDisplaySyncMap_.size()), displaySync->GetDisplaySyncData()->rateRange_->preferred_);
|
||||
displaySync->JudgeWhetherRequestFrame();
|
||||
return true;
|
||||
}
|
||||
@ -73,7 +82,11 @@ bool UIDisplaySyncManager::AddDisplaySync(const RefPtr<UIDisplaySync>& displaySy
|
||||
bool UIDisplaySyncManager::RemoveDisplaySync(const RefPtr<UIDisplaySync>& displaySync)
|
||||
{
|
||||
if (HasDisplaySync(displaySync)) {
|
||||
ACE_SCOPED_TRACE("RemoveDisplaySync Id:%d", static_cast<int32_t>(displaySync->GetId()));
|
||||
uiDisplaySyncMap_.erase(displaySync->GetId());
|
||||
TAG_LOGD(AceLogTag::ACE_DISPLAY_SYNC, "RemoveDisplaySync MapSize: %{public}d expected: %{public}d.",
|
||||
static_cast<int32_t>(uiDisplaySyncMap_.size()),
|
||||
displaySync->GetDisplaySyncData()->rateRange_->preferred_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -70,16 +70,24 @@ int32_t FrameRateManager::GetDisplaySyncRate() const
|
||||
return displaySyncRate_;
|
||||
}
|
||||
|
||||
int32_t FrameRateManager::GetExpectedRate()
|
||||
std::pair<int32_t, int32_t> FrameRateManager::GetExpectedRate()
|
||||
{
|
||||
int32_t expectedRate = 0;
|
||||
int32_t rateType = 0;
|
||||
if (!nodeRateMap_.empty()) {
|
||||
auto maxIter = std::max_element(
|
||||
nodeRateMap_.begin(), nodeRateMap_.end(), [](auto a, auto b) { return a.second < b.second; });
|
||||
expectedRate = maxIter->second;
|
||||
rateType = ACE_COMPONENT_FRAME_RATE_TYPE;
|
||||
}
|
||||
expectedRate = std::max(expectedRate, displaySyncRate_);
|
||||
expectedRate = std::max(expectedRate, animateRate_);
|
||||
return expectedRate;
|
||||
if (displaySyncRate_ > expectedRate) {
|
||||
expectedRate = displaySyncRate_;
|
||||
rateType = DISPLAY_SYNC_FRAME_RATE_TYPE;
|
||||
}
|
||||
if (animateRate_ > expectedRate) {
|
||||
expectedRate = animateRate_;
|
||||
rateType = UI_ANIMATION_FRAME_RATE_TYPE;
|
||||
}
|
||||
return {expectedRate, rateType};
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -23,6 +23,10 @@
|
||||
#include "base/utils/noncopyable.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
constexpr int32_t UI_ANIMATION_FRAME_RATE_TYPE = 2;
|
||||
constexpr int32_t DISPLAY_SYNC_FRAME_RATE_TYPE = 3;
|
||||
constexpr int32_t ACE_COMPONENT_FRAME_RATE_TYPE = 4;
|
||||
|
||||
class FrameRateManager : public virtual AceType {
|
||||
DECLARE_ACE_TYPE(FrameRateManager, AceType);
|
||||
|
||||
@ -46,7 +50,7 @@ public:
|
||||
|
||||
int32_t GetDisplaySyncRate() const;
|
||||
|
||||
int32_t GetExpectedRate();
|
||||
std::pair<int32_t, int32_t> GetExpectedRate();
|
||||
|
||||
private:
|
||||
std::unordered_map<int32_t, int32_t> nodeRateMap_;
|
||||
|
@ -109,12 +109,12 @@ void RosenWindow::Init()
|
||||
}
|
||||
}
|
||||
|
||||
void RosenWindow::FlushFrameRate(int32_t rate, bool isAnimatorStopped)
|
||||
void RosenWindow::FlushFrameRate(int32_t rate, bool isAnimatorStopped, int32_t rateType)
|
||||
{
|
||||
if (!rsWindow_ || rate < 0) {
|
||||
return;
|
||||
}
|
||||
rsWindow_->FlushFrameRate(rate, isAnimatorStopped);
|
||||
rsWindow_->FlushFrameRate(rate, isAnimatorStopped, rateType);
|
||||
}
|
||||
|
||||
void RosenWindow::RequestFrame()
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
void SetRootFrameNode(const RefPtr<NG::FrameNode>& root) override;
|
||||
|
||||
void FlushFrameRate(int32_t rate, bool isAnimatorStopped) override;
|
||||
void FlushFrameRate(int32_t rate, bool isAnimatorStopped, int32_t rateType) override;
|
||||
|
||||
std::shared_ptr<Rosen::RSUIDirector> GetRSUIDirector() const override
|
||||
{
|
||||
|
@ -810,9 +810,9 @@ void PipelineContext::FlushFrameRate()
|
||||
frameRateManager_->SetAnimateRate(window_->GetAnimateExpectedRate());
|
||||
bool currAnimationStatus = scheduleTasks_.empty() ? true : false;
|
||||
if (frameRateManager_->IsRateChanged() || currAnimationStatus != lastAnimationStatus_) {
|
||||
auto rate = frameRateManager_->GetExpectedRate();
|
||||
ACE_SCOPED_TRACE("FlushFrameRate Expected frameRate = %d", rate);
|
||||
window_->FlushFrameRate(rate, currAnimationStatus);
|
||||
auto [rate, rateType] = frameRateManager_->GetExpectedRate();
|
||||
ACE_SCOPED_TRACE("FlushFrameRate Expected frameRate = %d frameRateType = %d", rate, rateType);
|
||||
window_->FlushFrameRate(rate, currAnimationStatus, rateType);
|
||||
frameRateManager_->SetIsRateChanged(false);
|
||||
lastAnimationStatus_ = currAnimationStatus;
|
||||
}
|
||||
|
@ -94,7 +94,9 @@ HWTEST_F(FrameRateRangeTest, GetDisplaySyncRate, TestSize.Level1)
|
||||
int32_t displaySyncRate = 90;
|
||||
int32_t animateRate = 60;
|
||||
FrameRateManager frameRageManager;
|
||||
EXPECT_EQ(0, frameRageManager.GetExpectedRate());
|
||||
auto [expectedRate1, expectedRateType1] = frameRageManager.GetExpectedRate();
|
||||
EXPECT_EQ(0, expectedRate1);
|
||||
EXPECT_EQ(0, expectedRateType1);
|
||||
EXPECT_EQ(0, frameRageManager.GetDisplaySyncRate());
|
||||
frameRageManager.SetDisplaySyncRate(displaySyncRate);
|
||||
EXPECT_EQ(displaySyncRate, frameRageManager.GetDisplaySyncRate());
|
||||
@ -112,6 +114,8 @@ HWTEST_F(FrameRateRangeTest, GetDisplaySyncRate, TestSize.Level1)
|
||||
EXPECT_EQ(false, frameRageManager.IsRateChanged());
|
||||
|
||||
frameRageManager.AddNodeRate(nodeId, rate);
|
||||
EXPECT_EQ(rate, frameRageManager.GetExpectedRate());
|
||||
auto [expectedRate2, expectedRateType2] = frameRageManager.GetExpectedRate();
|
||||
EXPECT_EQ(rate, expectedRate2);
|
||||
EXPECT_EQ(ACE_COMPONENT_FRAME_RATE_TYPE, expectedRateType2);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
Loading…
Reference in New Issue
Block a user