mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
optimize get cache item
Signed-off-by: Tianer Zhou <zhoutianer@huawei.com> Change-Id: Ie286e60b1706a040f9d57ff35d5a47339b1a6bd2
This commit is contained in:
parent
0668035ef3
commit
44e4368723
@ -218,7 +218,7 @@ std::pair<float, LayoutConstraintF> GridIrregularFiller::MeasureItem(
|
||||
}
|
||||
|
||||
child->Measure(constraint);
|
||||
SetItemInfo(itemIdx, row, col, itemSize);
|
||||
SetItemInfo(child, row, col, itemSize);
|
||||
|
||||
float childHeight = child->GetGeometryNode()->GetMarginFrameSize().MainSize(info_->axis_);
|
||||
// spread height to each row.
|
||||
@ -354,14 +354,13 @@ int32_t GridIrregularFiller::FindItemTopRow(int32_t row, int32_t col) const
|
||||
return row;
|
||||
}
|
||||
|
||||
void GridIrregularFiller::SetItemInfo(int32_t idx, int32_t row, int32_t col, GridItemSize size)
|
||||
void GridIrregularFiller::SetItemInfo(const RefPtr<LayoutWrapper>& item, int32_t row, int32_t col, GridItemSize size)
|
||||
{
|
||||
CHECK_NULL_VOID(item);
|
||||
if (info_->axis_ == Axis::HORIZONTAL) {
|
||||
std::swap(row, col);
|
||||
std::swap(size.rows, size.columns);
|
||||
}
|
||||
auto item = wrapper_->GetChildByIndex(idx);
|
||||
CHECK_NULL_VOID(item);
|
||||
auto pattern = item->GetHostNode()->GetPattern<GridItemPattern>();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
auto props = pattern->GetLayoutProperty<GridItemLayoutProperty>();
|
||||
|
@ -218,12 +218,11 @@ private:
|
||||
/**
|
||||
* @brief Update item info to the newly filled GridItem.
|
||||
*
|
||||
* @param idx item index
|
||||
* @param row row index of item's top-left corner
|
||||
* @param col column index of item's top-left corner
|
||||
* @param size size of the item.
|
||||
*/
|
||||
void SetItemInfo(int32_t idx, int32_t row, int32_t col, GridItemSize size);
|
||||
void SetItemInfo(const RefPtr<LayoutWrapper>& item, int32_t row, int32_t col, GridItemSize size);
|
||||
|
||||
int32_t posY_ = 0; /**< The current row index in the grid. */
|
||||
int32_t posX_ = -1; /**< The current column index in the grid. */
|
||||
|
@ -622,11 +622,11 @@ void GridIrregularLayoutAlgorithm::PreloadItems(int32_t cacheCnt)
|
||||
std::list<GridPreloadItem> itemsToPreload;
|
||||
for (int32_t i = 1; i <= cacheCnt; ++i) {
|
||||
const int32_t l = info_.startIndex_ - i;
|
||||
if (l >= 0 && !wrapper_->GetChildByIndex(l)) {
|
||||
if (l >= 0 && !wrapper_->GetChildByIndex(l, true)) {
|
||||
itemsToPreload.emplace_back(l);
|
||||
}
|
||||
const int32_t r = info_.endIndex_ + i;
|
||||
if (r < info_.childrenCount_ && !wrapper_->GetChildByIndex(r)) {
|
||||
if (r < info_.childrenCount_ && !wrapper_->GetChildByIndex(r, true)) {
|
||||
itemsToPreload.emplace_back(r);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user