mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
optimize cache layout
Signed-off-by: Tianer Zhou <zhoutianer@huawei.com> Change-Id: I6f9f4e696fab2a573bf810f8c7acbb22904725ad
This commit is contained in:
parent
d5340ddc95
commit
a4f009c563
@ -145,6 +145,9 @@ public:
|
||||
|
||||
virtual RefPtr<LayoutWrapper> GetOrCreateChildByIndex(
|
||||
uint32_t index, bool addToRenderTree = true, bool isCache = false) = 0;
|
||||
/**
|
||||
* @param isCache if false, child is added to render tree and AttachToMainTree is called.
|
||||
*/
|
||||
virtual RefPtr<LayoutWrapper> GetChildByIndex(uint32_t index, bool isCache = false) = 0;
|
||||
virtual ChildrenListWithGuard GetAllChildrenWithBuild(bool addToRenderTree = true) = 0;
|
||||
virtual void RemoveChildInRenderTree(uint32_t index) = 0;
|
||||
|
@ -671,6 +671,10 @@ float WaterFlowLayoutSW::MeasureChild(int32_t idx, size_t lane) const
|
||||
}
|
||||
child->Measure(WaterFlowLayoutUtils::CreateChildConstraint(
|
||||
{ itemsCrossSize_[info_->GetSegment(idx)][lane], mainLen_, axis_ }, props_, child));
|
||||
if (cacheDeadline_) {
|
||||
child->Layout();
|
||||
child->SetActive(false);
|
||||
}
|
||||
const float res = child->GetGeometryNode()->GetMarginFrameSize().MainSize(info_->axis_);
|
||||
info_->CacheItemHeight(idx, res);
|
||||
return res;
|
||||
@ -699,7 +703,8 @@ void WaterFlowLayoutSW::LayoutSection(
|
||||
const auto& lane = info_->lanes_[idx][i];
|
||||
float mainPos = lane.startPos;
|
||||
for (const auto& item : lane.items_) {
|
||||
const bool isCache = item.idx < info_->startIndex_ || item.idx > info_->endIndex_;
|
||||
const bool isCache = !props_->GetShowCachedItemsValue(false) &&
|
||||
(item.idx < info_->startIndex_ || item.idx > info_->endIndex_);
|
||||
auto child = wrapper_->GetChildByIndex(nodeIdx(item.idx), isCache);
|
||||
if (!child) {
|
||||
mainPos += item.mainSize + mainGaps_[idx];
|
||||
@ -712,12 +717,15 @@ void WaterFlowLayoutSW::LayoutSection(
|
||||
}
|
||||
childNode->SetMarginFrameOffset(offset + paddingOffset);
|
||||
|
||||
mainPos += item.mainSize + mainGaps_[idx];
|
||||
if (isCache) {
|
||||
continue;
|
||||
}
|
||||
if (child->CheckNeedForceMeasureAndLayout()) {
|
||||
child->Layout();
|
||||
} else {
|
||||
child->GetHostNode()->ForceSyncGeometryNode();
|
||||
}
|
||||
mainPos += item.mainSize + mainGaps_[idx];
|
||||
}
|
||||
if (!rtl) {
|
||||
crossPos += itemsCrossSize_[idx][i] + crossGaps_[idx];
|
||||
|
@ -243,19 +243,28 @@ void WaterFlowLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper)
|
||||
} else {
|
||||
currentOffset += OffsetF(mainOffset, crossOffset);
|
||||
}
|
||||
const bool isCache = item.first < layoutInfo_->startIndex_ || item.first > layoutInfo_->endIndex_;
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(GetChildIndexWithFooter(item.first), isCache && !showCache);
|
||||
const bool isCache =
|
||||
!showCache && (item.first < layoutInfo_->startIndex_ || item.first > layoutInfo_->endIndex_);
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(GetChildIndexWithFooter(item.first), isCache);
|
||||
if (!wrapper) {
|
||||
continue;
|
||||
}
|
||||
wrapper->GetGeometryNode()->SetMarginFrameOffset(currentOffset);
|
||||
wrapper->Layout();
|
||||
|
||||
if (isCache) {
|
||||
continue;
|
||||
}
|
||||
if (wrapper->CheckNeedForceMeasureAndLayout()) {
|
||||
wrapper->Layout();
|
||||
} else {
|
||||
wrapper->GetHostNode()->ForceSyncGeometryNode();
|
||||
}
|
||||
// recode restore info
|
||||
if (item.first == layoutInfo_->startIndex_) {
|
||||
layoutInfo_->storedOffset_ = mainOffset;
|
||||
}
|
||||
|
||||
if (!isCache && NonNegative(mainOffset + item.second.second)) {
|
||||
if (NonNegative(mainOffset + item.second.second)) {
|
||||
firstIndex = std::min(firstIndex, item.first);
|
||||
}
|
||||
auto frameNode = AceType::DynamicCast<FrameNode>(wrapper);
|
||||
|
Loading…
Reference in New Issue
Block a user