1 /* 2 * Copyright (c) 2025 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_OPINC_CACHE_H 17 #define RS_OPINC_CACHE_H 18 19 #include "common/rs_common_def.h" 20 #include "common/rs_macros.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSB_EXPORT RSOpincCache { 25 public: 26 RSOpincCache() = default; 27 RSOpincCache(const RSOpincCache&) = delete; 28 RSOpincCache(const RSOpincCache&&) = delete; 29 RSOpincCache& operator=(const RSOpincCache&) = delete; 30 RSOpincCache& operator=(const RSOpincCache&&) = delete; 31 32 ~RSOpincCache() = default; 33 34 // mark stable node 35 void OpincSetInAppStateStart(bool& unchangeMarkInApp); 36 void OpincSetInAppStateEnd(bool& unchangeMarkInApp); 37 void OpincQuickMarkStableNode(bool& unchangeMarkInApp, bool& unchangeMarkEnable, bool isSelfDirty); 38 bool IsOpincUnchangeState(); 39 40 bool IsMarkedRenderGroup(bool groupTypeNotNone); 41 bool OpincForcePrepareSubTree(bool autoCacheEnable, bool isDirty, bool supportFlag); 42 43 // sync to drawable 44 void OpincUpdateRootFlag(bool& unchangeMarkEnable, bool isOpincNodeSupportFlag); 45 bool OpincGetRootFlag() const; 46 47 // arkui mark 48 void MarkSuggestOpincNode(bool isOpincNode, bool isNeedCalculate); 49 bool IsSuggestOpincNode() const; 50 51 bool GetCacheChangeFlag() const; GetNodeCacheState()52 NodeCacheState GetNodeCacheState() const 53 { 54 return nodeCacheState_; 55 } 56 GetUnchangeCount()57 int GetUnchangeCount() const 58 { 59 return unchangeCount_; 60 } 61 GetSubTreeSupportFlag()62 bool GetSubTreeSupportFlag() const { return subTreeSupportFlag_; } 63 void UpdateSubTreeSupportFlag(bool childSupportFlag, bool childRootFlag, bool groupTypeIsNone); 64 GetCurNodeTreeSupportFlag()65 bool GetCurNodeTreeSupportFlag() const { return curNodeTreeSupportFlag_; } SetCurNodeTreeSupportFlag(bool curNodeTreeSupportFlag)66 void SetCurNodeTreeSupportFlag(bool curNodeTreeSupportFlag) { curNodeTreeSupportFlag_ = curNodeTreeSupportFlag; } 67 68 private: 69 // opinc state 70 NodeCacheState nodeCacheState_ = NodeCacheState::STATE_INIT; 71 bool isSuggestOpincNode_ = false; 72 bool subTreeSupportFlag_ = true; 73 bool curNodeTreeSupportFlag_ = false; 74 bool isOpincRootFlag_ = false; 75 bool isUnchangeMarkEnable_ = false; 76 bool isNeedCalculate_ = false; 77 bool isUnchangeMarkInApp_ = false; 78 79 int tryCacheTimes_ = 0; 80 int unchangeCount_ = 0; 81 int unchangeCountUpper_ = 3; // 3 time is the default to cache 82 bool cacheChangeFlag_ = false; 83 int waitCount_ = 0; 84 // opinc state func 85 void NodeCacheStateChange(NodeChangeType type); 86 void SetCacheStateByRetrytime(); 87 void NodeCacheStateReset(NodeCacheState nodeCacheState); 88 }; 89 } // namespace Rosen 90 } // namespace OHOS 91 92 #endif // RS_OPINC_CACHE_H