From: Eunki Hong Date: Fri, 9 May 2025 15:24:19 +0000 (+0900) Subject: Sort RenderItems only if we need X-Git-Tag: accepted/tizen/unified/20250515.075542~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d245560ce1afc6cf821e9c5becdf745b43db9fce;p=platform%2Fcore%2Fuifw%2Fdali-core.git Sort RenderItems only if we need Change-Id: I9ac9fde63a8a473d1d7999603874fd5ebdda43f1 Signed-off-by: Eunki Hong --- diff --git a/dali/internal/update/manager/render-instruction-processor.cpp b/dali/internal/update/manager/render-instruction-processor.cpp index 631832a67..52270a056 100644 --- a/dali/internal/update/manager/render-instruction-processor.cpp +++ b/dali/internal/update/manager/render-instruction-processor.cpp @@ -475,6 +475,8 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex, // 2 is LAYER_3D + Clipping const int comparitorIndex = layer.GetBehavior() == Dali::Layer::LAYER_3D ? respectClippingOrder ? 2u : 1u : 0u; + bool needToSort = false; + for(uint32_t index = 0; index < renderableCount; ++index) { RenderItemKey itemKey = renderList.GetItemKey(index); @@ -501,9 +503,24 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex, // Keep the renderitem pointer in the helper so we can quickly reorder items after sort. mSortingHelper[index].renderItem = itemKey; + + if(!needToSort && index > 0u) + { + // Check if we need to sort the list. + // We only need to sort if the depth index is not the same as the previous item. + // This is a fast way of checking if we need to sort. + if(mSortComparitors[comparitorIndex](mSortingHelper[index], mSortingHelper[index - 1u])) + { + needToSort = true; + } + } } - std::stable_sort(mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[comparitorIndex]); + // If we don't need to sort, we can skip the sort. + if(needToSort) + { + std::stable_sort(mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[comparitorIndex]); + } // Reorder / re-populate the RenderItems in the RenderList to correct order based on the sortinghelper. DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "Sorted Transparent List:\n");