Get world scale more faster
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-instruction-processor.cpp
index 1c57380..87c3c98 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -216,12 +216,12 @@ inline void AddRendererToRenderList(BufferIndex               updateBufferIndex,
       SetNodeUpdateArea(node, isLayer3d, nodeWorldMatrix, nodeSize, nodeUpdateArea);
       nodeUpdateAreaSet = true;
 
-      const Vector3& scale = node->GetWorldScale(updateBufferIndex);
+      const Vector3& scale = nodeWorldMatrix.GetScale();
       const Vector3& size  = Vector3(nodeUpdateArea.z, nodeUpdateArea.w, 1.0f) * scale;
 
       if(size.LengthSquared() > Math::MACHINE_EPSILON_1000)
       {
-        MatrixUtils::Multiply(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
+        MatrixUtils::MultiplyTransformMatrix(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
         nodeModelViewMatrixSet = true;
 
         // Assume actors are at z=0, compute AABB in view space & test rect intersection
@@ -266,13 +266,13 @@ inline void AddRendererToRenderList(BufferIndex               updateBufferIndex,
 
       if(DALI_LIKELY(renderable.mRenderer))
       {
-        item.mRenderer   = &renderable.mRenderer->GetRenderer();
+        item.mRenderer   = renderable.mRenderer->GetRenderer();
         item.mTextureSet = renderable.mRenderer->GetTextureSet();
         item.mDepthIndex += renderable.mRenderer->GetDepthIndex();
       }
       else
       {
-        item.mRenderer = nullptr;
+        item.mRenderer = Render::RendererKey{};
       }
 
       item.mIsUpdated |= isLayer3d;
@@ -288,7 +288,7 @@ inline void AddRendererToRenderList(BufferIndex               updateBufferIndex,
 
       if(!nodeModelViewMatrixSet)
       {
-        MatrixUtils::Multiply(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
+        MatrixUtils::MultiplyTransformMatrix(nodeModelViewMatrix, nodeWorldMatrix, viewMatrix);
       }
       item.mModelViewMatrix = nodeModelViewMatrix;
 
@@ -385,14 +385,14 @@ inline bool TryReuseCachedRenderers(Layer&               layer,
     //@todo just use keys, don't deref.
     for(uint32_t index = 0; index < renderableCount; ++index)
     {
-      if(DALI_LIKELY(renderables[index].mRenderer != RendererKey::INVALID))
+      if(DALI_LIKELY(renderables[index].mRenderer))
       {
-        const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer();
-        checkSumNew += reinterpret_cast<std::size_t>(&renderer);
+        Render::RendererKey renderer = renderables[index].mRenderer->GetRenderer();
+        checkSumNew += renderer.Value();
       }
       if(DALI_LIKELY(renderList.GetItem(index).mRenderer))
       {
-        checkSumOld += reinterpret_cast<std::size_t>(&renderList.GetRenderer(index));
+        checkSumOld += renderList.GetItem(index).mRenderer.Value();
       }
     }
     if(checkSumNew == checkSumOld)
@@ -459,10 +459,8 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
 
   // List of zValue calculating functions.
   const Dali::Layer::SortFunctionType zValueFunctionFromVector3[] = {
-    [](const Vector3& position)
-    { return position.z; },
-    [](const Vector3& position)
-    { return position.LengthSquared(); },
+    [](const Vector3& position) { return position.z; },
+    [](const Vector3& position) { return position.LengthSquared(); },
     layer.GetSortFunction(),
   };
 
@@ -478,8 +476,8 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
 
   for(uint32_t index = 0; index < renderableCount; ++index)
   {
-    RenderItem& item = renderList.GetItem(index);
-
+    RenderItemKey itemKey = renderList.GetItemKey(index);
+    RenderItem&   item    = *itemKey.Get();
     if(DALI_LIKELY(item.mRenderer))
     {
       item.mRenderer->SetSortAttributes(mSortingHelper[index]);
@@ -491,7 +489,7 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
     mSortingHelper[index].zValue = zValueFunctionFromVector3[zValueFunctionIndex](item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
 
     // Keep the renderitem pointer in the helper so we can quickly reorder items after sort.
-    mSortingHelper[index].renderItem = &item;
+    mSortingHelper[index].renderItem = itemKey;
   }
 
   // Here we determine which comparitor (of the 3) to use.
@@ -508,7 +506,7 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
   for(uint32_t index = 0; index < renderableCount; ++index, ++renderListIter)
   {
     *renderListIter = mSortingHelper[index].renderItem;
-    DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "  sortedList[%d] = %p\n", index, mSortingHelper[index].renderItem->mRenderer);
+    DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "  sortedList[%d] = %x\n", index, mSortingHelper[index].renderItem->mRenderer);
   }
 }