1 /* 2 * Copyright (c) 2021-2023 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_MAIN_THREAD 17 #define RS_MAIN_THREAD 18 19 #include <future> 20 #include <memory> 21 #include <mutex> 22 #include <queue> 23 #include <thread> 24 #include <set> 25 26 #include "refbase.h" 27 #include "rs_base_render_engine.h" 28 #include "vsync_distributor.h" 29 #include <event_handler.h> 30 #include "vsync_receiver.h" 31 32 #include "command/rs_command.h" 33 #include "common/rs_common_def.h" 34 #include "common/rs_thread_handler.h" 35 #include "common/rs_thread_looper.h" 36 #include "ipc_callbacks/iapplication_agent.h" 37 #include "ipc_callbacks/rs_iocclusion_change_callback.h" 38 #include "ipc_callbacks/rs_isurface_occlusion_change_callback.h" 39 #include "memory/rs_app_state_listener.h" 40 #include "memory/rs_memory_graphic.h" 41 #include "pipeline/rs_context.h" 42 #include "pipeline/rs_uni_render_judgement.h" 43 #include "platform/drawing/rs_vsync_client.h" 44 #include "platform/common/rs_event_manager.h" 45 #include "transaction/rs_transaction_data.h" 46 47 namespace OHOS::Rosen { 48 #if defined(ACCESSIBILITY_ENABLE) 49 class AccessibilityObserver; 50 #endif 51 class HgmFrameRateManager; 52 struct FrameRateRangeData; 53 namespace Detail { 54 template<typename Task> 55 class ScheduledTask : public RefBase { 56 public: Create(Task && task)57 static auto Create(Task&& task) 58 { 59 sptr<ScheduledTask<Task>> t(new ScheduledTask(std::forward<Task&&>(task))); 60 return std::make_pair(t, t->task_.get_future()); 61 } 62 Run()63 void Run() 64 { 65 task_(); 66 } 67 68 private: ScheduledTask(Task && task)69 explicit ScheduledTask(Task&& task) : task_(std::move(task)) {} 70 ~ScheduledTask() override = default; 71 72 using Return = std::invoke_result_t<Task>; 73 std::packaged_task<Return()> task_; 74 }; 75 } // namespace Detail 76 77 class RSMainThread { 78 public: 79 static RSMainThread* Instance(); 80 81 void Init(); 82 void Start(); 83 void ProcessDataBySingleFrameComposer(std::unique_ptr<RSTransactionData>& rsTransactionData); 84 void RecvRSTransactionData(std::unique_ptr<RSTransactionData>& rsTransactionData); 85 void RequestNextVSync(); 86 void PostTask(RSTaskMessage::RSTask task); 87 void PostTask(RSTaskMessage::RSTask task, const std::string& name, int64_t delayTime, 88 AppExecFwk::EventQueue::Priority priority = AppExecFwk::EventQueue::Priority::IDLE); 89 void RemoveTask(const std::string& name); 90 void PostSyncTask(RSTaskMessage::RSTask task); 91 bool IsIdle() const; 92 void QosStateDump(std::string& dumpString); 93 void RenderServiceTreeDump(std::string& dumpString); 94 void RsEventParamDump(std::string& dumpString); 95 bool IsUIFirstOn() const; 96 void GetAppMemoryInMB(float& cpuMemSize, float& gpuMemSize); 97 void ClearMemoryCache(ClearMemoryMoment moment, bool deeply = false); 98 99 template<typename Task, typename Return = std::invoke_result_t<Task>> ScheduleTask(Task && task)100 std::future<Return> ScheduleTask(Task&& task) 101 { 102 auto [scheduledTask, taskFuture] = Detail::ScheduledTask<Task>::Create(std::forward<Task&&>(task)); 103 PostTask([t(std::move(scheduledTask))]() { t->Run(); }); 104 return std::move(taskFuture); 105 } 106 GetRenderEngine()107 const std::shared_ptr<RSBaseRenderEngine>& GetRenderEngine() const 108 { 109 return isUniRender_ ? uniRenderEngine_ : renderEngine_; 110 } 111 GetClearMemoryFinished()112 bool GetClearMemoryFinished() const 113 { 114 return clearMemoryFinished_; 115 } 116 GetContext()117 RSContext& GetContext() 118 { 119 return *context_; 120 } 121 Id()122 std::thread::id Id() const 123 { 124 return mainThreadId_; 125 } 126 CheckIsHardwareEnabledBufferUpdated()127 bool CheckIsHardwareEnabledBufferUpdated() const 128 { 129 return isHardwareEnabledBufferUpdated_; 130 } 131 132 /* Judge if rootnode has to be prepared based on it corresponding process is active 133 * If its pid is in activeProcessPids_ set, return true 134 */ 135 bool CheckNodeHasToBePreparedByPid(NodeId nodeId, bool isClassifyByRoot); 136 // check if active app has static drawing cache 137 bool IsDrawingGroupChanged(RSRenderNode& cacheRootNode) const; 138 // check if active instance only move or scale it's main window surface without rearrangement 139 // instanceNodeId should be MainWindowType, or it cannot grep correct app's info 140 void CheckAndUpdateInstanceContentStaticStatus(std::shared_ptr<RSSurfaceRenderNode> instanceNode) const; 141 142 void RegisterApplicationAgent(uint32_t pid, sptr<IApplicationAgent> app); 143 void UnRegisterApplicationAgent(sptr<IApplicationAgent> app); 144 145 void RegisterOcclusionChangeCallback(pid_t pid, sptr<RSIOcclusionChangeCallback> callback); 146 void UnRegisterOcclusionChangeCallback(pid_t pid); 147 148 void RegisterSurfaceOcclusionChangeCallback( 149 NodeId id, pid_t pid, sptr<RSISurfaceOcclusionChangeCallback> callback, std::vector<float>& partitionPoints); 150 void UnRegisterSurfaceOcclusionChangeCallback(NodeId id); 151 void ClearSurfaceOcclusionChangeCallback(pid_t pid); 152 bool SurfaceOcclusionCallBackIfOnTreeStateChanged(); 153 154 void WaitUtilUniRenderFinished(); 155 void NotifyUniRenderFinish(); 156 157 bool WaitUntilDisplayNodeBufferReleased(RSDisplayRenderNode& node); 158 void NotifyDisplayNodeBufferReleased(); 159 160 bool WaitHardwareThreadTaskExcute(); 161 void NotifyHardwareThreadCanExcuteTask(); 162 163 // driven render 164 void NotifyDrivenRenderFinish(); 165 void WaitUtilDrivenRenderFinished(); 166 167 void ClearTransactionDataPidInfo(pid_t remotePid); 168 void AddTransactionDataPidInfo(pid_t remotePid); 169 170 void SetFocusAppInfo( 171 int32_t pid, int32_t uid, const std::string &bundleName, const std::string &abilityName, uint64_t focusNodeId); 172 std::unordered_map<NodeId, bool> GetCacheCmdSkippedNodes() const; 173 std::string GetFocusAppBundleName() const; 174 175 sptr<VSyncDistributor> rsVSyncDistributor_; 176 sptr<VSyncController> rsVSyncController_; 177 sptr<VSyncController> appVSyncController_; 178 sptr<VSyncGenerator> vsyncGenerator_; 179 180 void ReleaseSurface(); 181 #ifndef USE_ROSEN_DRAWING 182 void AddToReleaseQueue(sk_sp<SkSurface>&& surface); 183 #else 184 void AddToReleaseQueue(std::shared_ptr<Drawing::Surface>&& surface); 185 #endif 186 187 void SetDirtyFlag(); 188 void SetColorPickerForceRequestVsync(bool colorPickerForceRequestVsync); 189 void SetNoNeedToPostTask(bool noNeedToPostTask); 190 void SetAccessibilityConfigChanged(); 191 void ForceRefreshForUni(); 192 void TrimMem(std::unordered_set<std::u16string>& argSets, std::string& result); 193 void DumpMem(std::unordered_set<std::u16string>& argSets, std::string& result, std::string& type, int pid = 0); 194 void DumpNode(std::string& result, uint64_t nodeId) const; 195 void CountMem(int pid, MemoryGraphic& mem); 196 void CountMem(std::vector<MemoryGraphic>& mems); 197 void SetAppWindowNum(uint32_t num); 198 void SetMultiInstancePidVSyncRate(std::map<uint32_t, RSVisibleLevel>& pidVisMap, 199 std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces); 200 bool SetSystemAnimatedScenes(SystemAnimatedScenes systemAnimatedScenes); 201 SystemAnimatedScenes GetSystemAnimatedScenes(); 202 void ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow); 203 void SetIsCachedSurfaceUpdated(bool isCachedSurfaceUpdated); 204 pid_t GetDesktopPidForRotationScene() const; SetForceUpdateUniRenderFlag(bool flag)205 void SetForceUpdateUniRenderFlag(bool flag) 206 { 207 forceUpdateUniRenderFlag_ = flag; 208 } SetIdleTimerExpiredFlag(bool flag)209 void SetIdleTimerExpiredFlag(bool flag) 210 { 211 idleTimerExpiredFlag_ = flag; 212 } 213 #ifndef USE_ROSEN_DRAWING 214 sk_sp<SkImage> GetWatermarkImg(); 215 #else 216 std::shared_ptr<Drawing::Image> GetWatermarkImg(); 217 #endif 218 bool GetWatermarkFlag(); GetFrameCount()219 uint64_t GetFrameCount() const 220 { 221 return frameCount_; 222 } GetDrawStatusVec()223 std::vector<NodeId>& GetDrawStatusVec() 224 { 225 return curDrawStatusVec_; 226 } SetAppVSyncDistributor(const sptr<VSyncDistributor> & appVSyncDistributor)227 void SetAppVSyncDistributor(const sptr<VSyncDistributor>& appVSyncDistributor) 228 { 229 appVSyncDistributor_ = appVSyncDistributor; 230 } 231 232 DeviceType GetDeviceType() const; 233 bool IsSingleDisplay(); 234 bool GetNoNeedToPostTask(); 235 uint64_t GetFocusNodeId() const; 236 uint64_t GetFocusLeashWindowId() const; GetClearMemDeeply()237 bool GetClearMemDeeply() const 238 { 239 return clearMemDeeply_; 240 } 241 GetClearMoment()242 ClearMemoryMoment GetClearMoment() const 243 { 244 if (!context_) { 245 return ClearMemoryMoment::NO_CLEAR; 246 } 247 return context_->clearMoment_; 248 } 249 SetClearMoment(ClearMemoryMoment moment)250 void SetClearMoment(ClearMemoryMoment moment) 251 { 252 if (!context_) { 253 return; 254 } 255 context_->clearMoment_ = moment; 256 } 257 IsMainLooping()258 bool IsMainLooping() const 259 { 260 return mainLooping_.load(); 261 } 262 GetDiscardJankFrames()263 bool GetDiscardJankFrames() const 264 { 265 return discardJankFrames_.load(); 266 } 267 SetDiscardJankFrames(bool discardJankFrames)268 void SetDiscardJankFrames(bool discardJankFrames) 269 { 270 discardJankFrames_.store(discardJankFrames); 271 } 272 IsPCThreeFingerScenesListScene()273 bool IsPCThreeFingerScenesListScene() const 274 { 275 return !threeFingerScenesList_.empty(); 276 } 277 278 void SubscribeAppState(); 279 void HandleOnTrim(Memory::SystemMemoryLevel level); 280 void NotifySurfaceCapProcFinish(); 281 void WaitUntilSurfaceCapProcFinished(); 282 void SetSurfaceCapProcFinished(bool flag); 283 284 const std::vector<std::shared_ptr<RSSurfaceRenderNode>>& GetSelfDrawingNodes() const; 285 bool GetParallelCompositionEnabled(); GetFrameRateMgr()286 std::shared_ptr<HgmFrameRateManager> GetFrameRateMgr() { return frameRateMgr_; }; 287 private: 288 using TransactionDataIndexMap = std::unordered_map<pid_t, 289 std::pair<uint64_t, std::vector<std::unique_ptr<RSTransactionData>>>>; 290 291 RSMainThread(); 292 ~RSMainThread() noexcept; 293 RSMainThread(const RSMainThread&) = delete; 294 RSMainThread(const RSMainThread&&) = delete; 295 RSMainThread& operator=(const RSMainThread&) = delete; 296 RSMainThread& operator=(const RSMainThread&&) = delete; 297 298 void OnVsync(uint64_t timestamp, void* data); 299 void ProcessCommand(); 300 void Animate(uint64_t timestamp); 301 void ApplyModifiers(); 302 void ConsumeAndUpdateAllNodes(); 303 void CollectInfoForHardwareComposer(); 304 void CollectInfoForDrivenRender(); 305 void ReleaseAllNodesBuffer(); 306 void Render(); 307 void SetDeviceType(); 308 void ColorPickerRequestVsyncIfNeed(); 309 void UniRender(std::shared_ptr<RSBaseRenderNode> rootNode); 310 bool CheckSurfaceNeedProcess(OcclusionRectISet& occlusionSurfaces, std::shared_ptr<RSSurfaceRenderNode> curSurface); 311 void CalcOcclusionImplementation(std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces, 312 VisibleData& dstCurVisVec, std::map<uint32_t, RSVisibleLevel>& dstPidVisMap); 313 void CalcOcclusion(); 314 bool CheckSurfaceVisChanged(std::map<uint32_t, RSVisibleLevel>& pidVisMap, 315 std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces); 316 void SetVSyncRateByVisibleLevel(std::map<uint32_t, RSVisibleLevel>& pidVisMap, 317 std::vector<RSBaseRenderNode::SharedPtr>& curAllSurfaces); 318 void CallbackToWMS(VisibleData& curVisVec); 319 void SendCommands(); 320 void SurfaceOcclusionCallback(); 321 void InitRSEventDetector(); 322 void RemoveRSEventDetector(); 323 void SetRSEventDetectorLoopStartTag(); 324 void SetRSEventDetectorLoopFinishTag(); 325 void CallbackDrawContextStatusToWMS(); 326 void CheckSystemSceneStatus(); 327 void UpdateUIFirstSwitch(); 328 // ROG: Resolution Online Government 329 void UpdateRogSizeIfNeeded(); 330 uint32_t GetRefreshRate() const; 331 void SkipCommandByNodeId(std::vector<std::unique_ptr<RSTransactionData>>& transactionVec, pid_t pid); 332 333 bool DoParallelComposition(std::shared_ptr<RSBaseRenderNode> rootNode); 334 335 void ClassifyRSTransactionData(std::unique_ptr<RSTransactionData>& rsTransactionData); 336 void ProcessRSTransactionData(std::unique_ptr<RSTransactionData>& rsTransactionData, pid_t pid); 337 void ProcessSyncRSTransactionData(std::unique_ptr<RSTransactionData>& rsTransactionData, pid_t pid); 338 void ProcessAllSyncTransactionData(); 339 void ProcessCommandForDividedRender(); 340 void ProcessCommandForUniRender(); 341 void WaitUntilUnmarshallingTaskFinished(); 342 void MergeToEffectiveTransactionDataMap(TransactionDataMap& cachedTransactionDataMap); 343 344 void ClearDisplayBuffer(); 345 void PerfAfterAnim(bool needRequestNextVsync); 346 void PerfForBlurIfNeeded(); 347 void PerfMultiWindow(); 348 void RenderFrameStart(uint64_t timestamp); 349 void ResetHardwareEnabledState(); 350 void CheckIfHardwareForcedDisabled(); 351 void CheckAndUpdateTransactionIndex( 352 std::shared_ptr<TransactionDataMap>& transactionDataEffective, std::string& transactionFlags); 353 354 bool IsResidentProcess(pid_t pid) const; 355 bool IsNeedSkip(NodeId instanceRootNodeId, pid_t pid); 356 357 // UIFirst 358 bool CheckParallelSubThreadNodesStatus(); 359 void CacheCommands(); 360 bool CheckSubThreadNodeStatusIsDoing(NodeId appNodeId) const; 361 362 // used for informing hgm the bundle name of SurfaceRenderNodes 363 void InformHgmNodeInfo(); 364 void CheckIfNodeIsBundle(std::shared_ptr<RSSurfaceRenderNode> node); 365 366 void SetFocusLeashWindowId(); 367 void ProcessHgmFrameRate(uint64_t timestamp); 368 bool IsLastFrameUIFirstEnabled(NodeId appNodeId) const; 369 RSVisibleLevel GetRegionVisibleLevel(const Occlusion::Region& curRegion, 370 const Occlusion::Region& visibleRegion); 371 void PrintCurrentStatus(); 372 void WaitUntilUploadTextureTaskFinishedForGL(); 373 374 std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr; 375 std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr; 376 RSTaskMessage::RSTask mainLoop_; 377 std::unique_ptr<RSVsyncClient> vsyncClient_ = nullptr; 378 std::unordered_map<NodeId, uint64_t> bufferTimestamps_; 379 380 std::mutex transitionDataMutex_; 381 std::unordered_map<NodeId, std::map<uint64_t, std::vector<std::unique_ptr<RSCommand>>>> cachedCommands_; 382 std::map<uint64_t, std::vector<std::unique_ptr<RSCommand>>> effectiveCommands_; 383 std::map<uint64_t, std::vector<std::unique_ptr<RSCommand>>> pendingEffectiveCommands_; 384 std::unordered_map<pid_t, std::vector<std::unique_ptr<RSTransactionData>>> syncTransactionData_; 385 int32_t syncTransactionCount_ { 0 }; 386 387 TransactionDataMap cachedTransactionDataMap_; 388 TransactionDataIndexMap effectiveTransactionDataIndexMap_; 389 std::map<pid_t, std::vector<std::unique_ptr<RSTransactionData>>> cachedSkipTransactionDataMap_; 390 std::unordered_map<pid_t, uint64_t> transactionDataLastWaitTime_; 391 392 uint64_t curTime_ = 0; 393 uint64_t timestamp_ = 0; 394 uint64_t lastAnimateTimestamp_ = 0; 395 uint64_t prePerfTimestamp_ = 0; 396 uint64_t lastCleanCacheTimestamp_ = 0; 397 int hardwareTid_ = -1; 398 std::unordered_map<uint32_t, sptr<IApplicationAgent>> applicationAgentMap_; 399 400 std::shared_ptr<RSContext> context_; 401 std::thread::id mainThreadId_; 402 std::shared_ptr<VSyncReceiver> receiver_ = nullptr; 403 std::map<pid_t, sptr<RSIOcclusionChangeCallback>> occlusionListeners_; 404 std::mutex occlusionMutex_; 405 406 bool isUniRender_ = RSUniRenderJudgement::IsUniRender(); 407 RSTaskMessage::RSTask unmarshalBarrierTask_; 408 std::condition_variable unmarshalTaskCond_; 409 std::mutex unmarshalMutex_; 410 int32_t unmarshalFinishedCount_ = 0; 411 sptr<VSyncDistributor> appVSyncDistributor_ = nullptr; 412 413 std::condition_variable surfaceCapProcTaskCond_; 414 std::mutex surfaceCapProcMutex_; 415 bool surfaceCapProcFinished_ = true; 416 417 #if defined(RS_ENABLE_PARALLEL_UPLOAD) && defined(RS_ENABLE_GL) 418 RSTaskMessage::RSTask uploadTextureBarrierTask_; 419 std::condition_variable uploadTextureTaskCond_; 420 std::mutex uploadTextureMutex_; 421 int32_t uploadTextureFinishedCount_ = 0; 422 EGLSyncKHR uploadTextureFence; 423 #endif 424 425 mutable std::mutex uniRenderMutex_; 426 bool uniRenderFinished_ = false; 427 std::condition_variable uniRenderCond_; 428 // used for blocking mainThread before displayNode has no freed buffer to request 429 mutable std::mutex displayNodeBufferReleasedMutex_; 430 bool displayNodeBufferReleased_ = false; 431 // used for stalling mainThread before displayNode has no freed buffer to request 432 std::condition_variable displayNodeBufferReleasedCond_; 433 434 bool clearMemoryFinished_ = true; 435 bool clearMemDeeply_ = false; 436 437 // driven render 438 mutable std::mutex drivenRenderMutex_; 439 bool drivenRenderFinished_ = false; 440 std::condition_variable drivenRenderCond_; 441 442 // Used to refresh the whole display when AccessibilityConfig is changed 443 bool isAccessibilityConfigChanged_ = false; 444 445 // used for blocking mainThread when hardwareThread has 2 and more task to excute 446 mutable std::mutex hardwareThreadTaskMutex_; 447 std::condition_variable hardwareThreadTaskCond_; 448 449 std::map<uint32_t, RSVisibleLevel> lastPidVisMap_; 450 VisibleData lastVisVec_; 451 std::map<NodeId, uint64_t> lastDrawStatusMap_; 452 std::vector<NodeId> curDrawStatusVec_; 453 bool qosPidCal_ = false; 454 bool isDirty_ = false; 455 std::atomic_bool doWindowAnimate_ = false; 456 std::vector<NodeId> lastSurfaceIds_; 457 int32_t focusAppPid_ = -1; 458 int32_t focusAppUid_ = -1; 459 const uint8_t opacity_ = 255; 460 std::string focusAppBundleName_ = ""; 461 std::string focusAppAbilityName_ = ""; 462 uint64_t focusNodeId_ = 0; 463 uint64_t focusLeashWindowId_ = 0; 464 uint64_t lastFocusNodeId_ = 0; 465 uint32_t appWindowNum_ = 0; 466 uint32_t requestNextVsyncNum_ = 0; 467 bool lastFrameHasFilter_ = false; 468 bool vsyncControlEnabled_ = true; 469 bool systemAnimatedScenesEnabled_ = false; 470 bool isFoldScreenDevice_ = false; 471 472 bool colorPickerForceRequestVsync_ = false; 473 std::atomic_bool noNeedToPostTask_ = false; 474 std::atomic_int colorPickerRequestFrameNum_ = 15; 475 476 std::shared_ptr<RSBaseRenderEngine> renderEngine_; 477 std::shared_ptr<RSBaseRenderEngine> uniRenderEngine_; 478 std::shared_ptr<RSBaseEventDetector> rsCompositionTimeoutDetector_; 479 RSEventManager rsEventManager_; 480 #if defined(ACCESSIBILITY_ENABLE) 481 std::shared_ptr<AccessibilityObserver> accessibilityObserver_; 482 #endif 483 484 // used for hardware enabled case 485 bool doDirectComposition_ = true; 486 bool isHardwareEnabledBufferUpdated_ = false; 487 std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_; 488 std::vector<std::shared_ptr<RSSurfaceRenderNode>> selfDrawingNodes_; 489 bool isHardwareForcedDisabled_ = false; // if app node has shadow or filter, disable hardware composer for all 490 491 // used for watermark 492 std::mutex watermarkMutex_; 493 #ifndef USE_ROSEN_DRAWING 494 sk_sp<SkImage> watermarkImg_ = nullptr; 495 #else 496 std::shared_ptr<Drawing::Image> watermarkImg_ = nullptr; 497 #endif 498 bool isShow_ = false; 499 bool doParallelComposition_ = false; 500 501 // driven render 502 bool hasDrivenNodeOnUniTree_ = false; 503 bool hasDrivenNodeMarkRender_ = false; 504 505 std::shared_ptr<HgmFrameRateManager> frameRateMgr_ = nullptr; 506 std::shared_ptr<RSRenderFrameRateLinker> rsFrameRateLinker_ = nullptr; 507 pid_t desktopPidForRotationScene_ = 0; 508 FrameRateRange rsCurrRange_; 509 510 // UIFirst 511 std::list<std::shared_ptr<RSSurfaceRenderNode>> subThreadNodes_; 512 std::unordered_map<NodeId, bool> cacheCmdSkippedNodes_; 513 std::unordered_map<pid_t, std::pair<std::vector<NodeId>, bool>> cacheCmdSkippedInfo_; 514 std::atomic<uint64_t> frameCount_ = 0; 515 std::set<std::shared_ptr<RSBaseRenderNode>> oldDisplayChildren_; 516 DeviceType deviceType_ = DeviceType::PHONE; 517 bool isCachedSurfaceUpdated_ = false; 518 bool isUiFirstOn_ = false; 519 520 // used for informing hgm the bundle name of SurfaceRenderNodes 521 bool noBundle_ = false; 522 std::string currentBundleName_ = ""; 523 bool forceUpdateUniRenderFlag_ = false; 524 bool idleTimerExpiredFlag_ = false; 525 // for ui first 526 std::mutex mutex_; 527 #ifndef USE_ROSEN_DRAWING 528 std::queue<sk_sp<SkSurface>> tmpSurfaces_; 529 #else 530 std::queue<std::shared_ptr<Drawing::Surface>> tmpSurfaces_; 531 #endif 532 533 // for surface occlusion change callback 534 std::mutex surfaceOcclusionMutex_; 535 std::vector<NodeId> lastRegisteredSurfaceOnTree_; 536 std::mutex systemAnimatedScenesMutex_; 537 std::list<std::pair<SystemAnimatedScenes, time_t>> systemAnimatedScenesList_; 538 std::list<std::pair<SystemAnimatedScenes, time_t>> threeFingerScenesList_; 539 bool isReduceVSyncBySystemAnimatedScenes_ = false; 540 std::unordered_map<NodeId, // map<node ID, <pid, callback, partition points vector, level>> 541 std::tuple<pid_t, sptr<RSISurfaceOcclusionChangeCallback>, 542 std::vector<float>, uint8_t>> surfaceOcclusionListeners_; 543 std::unordered_map<NodeId, // map<node ID, <surface node, app window node>> 544 std::pair<std::shared_ptr<RSSurfaceRenderNode>, std::shared_ptr<RSSurfaceRenderNode>>> savedAppWindowNode_; 545 546 std::shared_ptr<RSAppStateListener> rsAppStateListener_; 547 int32_t subscribeFailCount_ = 0; 548 SystemAnimatedScenes systemAnimatedScenes_ = SystemAnimatedScenes::OTHERS; 549 uint32_t LeashWindowCount_ = 0; 550 551 std::atomic_bool mainLooping_ = false; 552 std::atomic_bool discardJankFrames_ = false; 553 bool forceUIFirstChanged_ = false; 554 }; 555 } // namespace OHOS::Rosen 556 #endif // RS_MAIN_THREAD 557