add: add PreLayout for window to flush first frame

Signed-off-by: yhpeng <pengyuhao1@huawei.com>
This commit is contained in:
yhpeng 2024-05-30 15:28:48 +08:00
parent ecbf13ff89
commit 10408a6043
7 changed files with 34 additions and 0 deletions

View File

@ -3221,4 +3221,21 @@ void UIContentImpl::SetContentNodeGrayScale(float grayscale)
CHECK_NULL_VOID(renderContext);
renderContext->UpdateFrontGrayScale(Dimension(grayscale));
}
void UIContentImpl::PreLayout()
{
auto container = Platform::AceContainer::GetContainer(instanceId_);
CHECK_NULL_VOID(container);
ContainerScope scope(instanceId_);
auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext());
CHECK_NULL_VOID(pipelineContext);
auto taskExecutor = container->GetTaskExecutor();
CHECK_NULL_VOID(taskExecutor);
taskExecutor->PostSyncTask(
[pipelineContext] {
pipelineContext->PreLayout(pipelineContext->GetTimeFromExternalTimer());
},
TaskExecutor::TaskType::UI, "ArkUIPreLayout");
}
} // namespace OHOS::Ace

View File

@ -313,6 +313,8 @@ public:
void SetContentNodeGrayScale(float grayscale) override;
void PreLayout() override;
private:
UIContentErrorCode InitializeInner(
OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, bool isNamedRouter);

View File

@ -145,6 +145,8 @@ public:
void SetContentNodeGrayScale(float grayscale) override {};
void PreLayout() override {};
private:
UIContentErrorCode CommonInitialize(OHOS::Rosen::Window* window, const std::string& contentInfo,
napi_value storage);

View File

@ -3649,6 +3649,11 @@ bool PipelineContext::IsContainerModalVisible()
return isShowTitle_ && isFloatingWindow && customTitleSettedShow_;
}
void PipelineContext::PreLayout(uint64_t nanoTimestamp, uint32_t frameCount)
{
FlushVsync(nanoTimestamp, frameCount);
}
void PipelineContext::CheckAndLogLastReceivedTouchEventInfo(int32_t eventId, TouchType type)
{
eventManager_->CheckAndLogLastReceivedTouchEventInfo(eventId, type);

View File

@ -763,6 +763,9 @@ public:
{
predictNode_.Reset();
}
void PreLayout(uint64_t nanoTimestamp, uint32_t frameCount);
protected:
void StartWindowSizeChangeAnimate(int32_t width, int32_t height, WindowSizeChangeReason type,
const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr);

View File

@ -410,6 +410,8 @@ public:
const std::function<void(std::vector<Ace::RectF>)>& callback) const {};
virtual void SetContentNodeGrayScale(float grayscale) {};
virtual void PreLayout() {};
};
} // namespace OHOS::Ace

View File

@ -606,6 +606,9 @@ void PipelineContext::CheckAndLogLastConsumedMouseEventInfo(int32_t eventId, Mou
void PipelineContext::CheckAndLogLastReceivedAxisEventInfo(int32_t eventId, AxisAction action) {}
void PipelineContext::CheckAndLogLastConsumedAxisEventInfo(int32_t eventId, AxisAction action) {}
void PipelineContext::PreLayout(uint64_t nanoTimestamp, uint32_t frameCount) {}
} // namespace OHOS::Ace::NG
// pipeline_context ============================================================