From 8d9a0bb768006346c39b01282dfe039d6ee04d9e Mon Sep 17 00:00:00 2001 From: wangxinpeng Date: Thu, 13 Jan 2022 12:10:51 +0800 Subject: [PATCH] create a new thread to request vsync Signed-off-by: wangxinpeng Change-Id: Id3cd12af929aa8981b8161f9f1bd320acb59a513 --- wm/include/vsync_station.h | 1 + wm/src/vsync_station.cpp | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/wm/include/vsync_station.h b/wm/include/vsync_station.h index 4fe4720771..3fdedaa24c 100644 --- a/wm/include/vsync_station.h +++ b/wm/include/vsync_station.h @@ -48,6 +48,7 @@ private: VsyncStation() = default; static void OnVsync(int64_t nanoTimestamp, void* client); void VsyncCallbackInner(int64_t nanoTimestamp); + const std::string VSYNC_THREAD_ID = "vsync_thread"; std::shared_ptr mainHandler_ = nullptr; std::mutex lock_; std::atomic_bool hasRequestedVsync_ {false}; diff --git a/wm/src/vsync_station.cpp b/wm/src/vsync_station.cpp index a55d17d6cc..39a5117f7f 100644 --- a/wm/src/vsync_station.cpp +++ b/wm/src/vsync_station.cpp @@ -33,11 +33,8 @@ void VsyncStation::RequestVsync(CallbackType type, std::shared_ptrsecond.insert(vsyncCallback); if (mainHandler_ == nullptr) { - if (AppExecFwk::EventRunner::GetMainEventRunner() == nullptr) { - WLOGFE("can not get main event runner."); - return; - } - mainHandler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); + auto runner = AppExecFwk::EventRunner::Create(VSYNC_THREAD_ID); + mainHandler_ = std::make_shared(runner); } if (!hasRequestedVsync_) { mainHandler_->PostTask([this]() { -- Gitee