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 #include "core/components_ng/base/frame_node.h" 17 18 #include "core/pipeline_ng/pipeline_context.h" 19 20 namespace OHOS::Ace::NG { MarkModifyDoneMultiThread()21void FrameNode::MarkModifyDoneMultiThread() 22 { 23 PostAfterAttachMainTreeTask([weak = WeakClaim(this)]() { 24 auto host = weak.Upgrade(); 25 CHECK_NULL_VOID(host); 26 host->MarkModifyDone(); 27 }); 28 } 29 MarkDirtyNodeMultiThread(PropertyChangeFlag extraFlag)30void FrameNode::MarkDirtyNodeMultiThread(PropertyChangeFlag extraFlag) 31 { 32 PostAfterAttachMainTreeTask([weak = WeakClaim(this), extraFlag]() { 33 auto host = weak.Upgrade(); 34 CHECK_NULL_VOID(host); 35 host->MarkDirtyNode(extraFlag); 36 }); 37 } 38 RebuildRenderContextTreeMultiThread()39void FrameNode::RebuildRenderContextTreeMultiThread() 40 { 41 PostAfterAttachMainTreeTask([weak = WeakClaim(this)]() { 42 auto host = weak.Upgrade(); 43 CHECK_NULL_VOID(host); 44 host->RebuildRenderContextTree(); 45 }); 46 } 47 MarkNeedRenderMultiThread(bool isRenderBoundary)48void FrameNode::MarkNeedRenderMultiThread(bool isRenderBoundary) 49 { 50 auto context = GetContext(); 51 CHECK_NULL_VOID(context); 52 // If it has dirtyLayoutBox, need to mark dirty after layout done. 53 paintProperty_->UpdatePropertyChangeFlag(PROPERTY_UPDATE_RENDER); 54 if (isRenderDirtyMarked_ || isLayoutDirtyMarked_) { 55 return; 56 } 57 isRenderDirtyMarked_ = true; 58 if (isRenderBoundary) { 59 PostAfterAttachMainTreeTask([weak = WeakClaim(this)]() { 60 auto frameNode = weak.Upgrade(); 61 CHECK_NULL_VOID(frameNode); 62 auto context = frameNode->GetContext(); 63 CHECK_NULL_VOID(context); 64 context->AddDirtyRenderNode(weak.Upgrade()); 65 }); 66 return; 67 } 68 auto parent = GetAncestorNodeOfFrame(false); 69 if (parent) { 70 parent->MarkDirtyNode(PROPERTY_UPDATE_RENDER_BY_CHILD_REQUEST); 71 } 72 } 73 } // namespace OHOS::Ace::NG