Support UpdateAreaExtents for Renderer 77/321077/7
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 13 Mar 2025 11:01:01 +0000 (20:01 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 20 Mar 2025 05:58:06 +0000 (14:58 +0900)
Add property for extents the dirty rect calculated range for the renderer.

Change-Id: Ibdfe6ea2a90906d01d29c93b0e632d5e631249d4
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-DecoratedVisualRenderer.cpp
automated-tests/src/dali/utc-Dali-Renderer.cpp
automated-tests/src/dali/utc-Dali-VisualRenderer.cpp
dali/devel-api/rendering/renderer-devel.h
dali/internal/event/rendering/renderer-impl.cpp
dali/internal/event/rendering/renderer-impl.h
dali/internal/update/rendering/scene-graph-renderer-messages.h
dali/internal/update/rendering/scene-graph-renderer.cpp
dali/internal/update/rendering/scene-graph-renderer.h

index d83afe449f03d5d8a8e5015b819f018bc5c4144c..92b775bf73e9320a779e09273621f4f434e874bb 100644 (file)
@@ -205,9 +205,9 @@ int UtcDaliDecoratedVisualRendererDefaultProperties(void)
   VisualRenderer          baseVisualRenderer = VisualRenderer::New(geometry, shader);
   Renderer                baseRenderer       = Renderer::New(geometry, shader);
 
-  DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 32, TEST_LOCATION);
-  DALI_TEST_EQUALS(baseVisualRenderer.GetPropertyCount(), 32 + 8, TEST_LOCATION);
-  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32 + 8 + 7, TEST_LOCATION);
+  DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 33, TEST_LOCATION);
+  DALI_TEST_EQUALS(baseVisualRenderer.GetPropertyCount(), 33 + 8, TEST_LOCATION);
+  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 33 + 8 + 7, TEST_LOCATION);
 
   TEST_RENDERER_PROPERTY(renderer, "cornerRadius", Property::VECTOR4, true, true, true, DecoratedVisualRenderer::Property::CORNER_RADIUS, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "cornerRadiusPolicy", Property::FLOAT, true, false, true, DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, TEST_LOCATION);
index 7b15104748e163c2930cc6b83f7bde9db6a3b6fc..1356f9d164ce965a64d268fdffdc394aa46e32b1 100644 (file)
@@ -306,12 +306,13 @@ int UtcDaliRendererDefaultProperties(void)
   DALI_PROPERTY("renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR)
   DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION)
   DALI_PROPERTY("instanceCount", INTEGER, true, false, false, Dali::DevelRenderer::Property::INSTANCE_COUNT)
+  DALI_PROPERTY("updateAreaExtents", EXTENTS, true, false, false, Dali::DevelRenderer::Property::UPDATE_AREA_EXTENTS)
 */
 
   Geometry geometry = CreateQuadGeometry();
   Shader   shader   = CreateShader();
   Renderer renderer = Renderer::New(geometry, shader);
-  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32, TEST_LOCATION);
+  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 33, TEST_LOCATION);
 
   TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION);
@@ -345,6 +346,7 @@ int UtcDaliRendererDefaultProperties(void)
   TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "instanceCount", Property::INTEGER, true, false, false, DevelRenderer::Property::INSTANCE_COUNT, TEST_LOCATION);
+  TEST_RENDERER_PROPERTY(renderer, "updateAreaExtents", Property::EXTENTS, true, false, false, DevelRenderer::Property::UPDATE_AREA_EXTENTS, TEST_LOCATION);
 
   END_TEST;
 }
@@ -5238,6 +5240,8 @@ int UtcDaliRendererVertexRange(void)
   END_TEST;
 }
 
+namespace
+{
 TestGraphicsBuffer* FindUniformBuffer(int bufferIndex, TestGraphicsController& graphics)
 {
   int counter = 0;
@@ -5282,6 +5286,7 @@ void CreateRendererProperties(Renderer renderer, const Matrix& m, const Matrix&
   renderer["uBlendShapeWeight[55]"]  = w2;
   renderer["uBlendShapeWeight[127]"] = w3;
 }
+} // namespace
 
 int UtcDaliRendererUniformBlocks01(void)
 {
@@ -5985,3 +5990,77 @@ int UtcDaliRendererDestructWorkerThreadN(void)
 
   END_TEST;
 }
+
+int utcDaliRendererPartialUpdateUpdateAreaExtents(void)
+{
+  TestApplication application(
+    TestApplication::DEFAULT_SURFACE_WIDTH,
+    TestApplication::DEFAULT_SURFACE_HEIGHT,
+    TestApplication::DEFAULT_HORIZONTAL_DPI,
+    TestApplication::DEFAULT_VERTICAL_DPI,
+    true,
+    true);
+
+  tet_infoline("Check the damaged rect with renderer's UPDATE_AREA_EXTENTS property");
+
+  const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+  Shader   shader   = Shader::New("VertexSource", "FragmentSource");
+  Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New(geometry, shader);
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
+  actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+  actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+
+  std::vector<Rect<int>> damagedRects;
+  Rect<int>              clippingRect;
+
+  // 1. Actor added, damaged rect is added size of actor
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int>(16, 768, 32, 32); // in screen coordinates
+
+  DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+  DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+  DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+  // Check dirty rect empty
+  application.SendNotification();
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+  clippingRect = TestApplication::DEFAULT_SURFACE_RECT;
+  DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  // Set update area extents
+  renderer.SetProperty(DevelRenderer::Property::UPDATE_AREA_EXTENTS, Dali::Extents(8u, 40u, 8u, 72u));
+  DALI_TEST_EQUALS(renderer.GetProperty<Extents>(DevelRenderer::Property::UPDATE_AREA_EXTENTS), Dali::Extents(8u, 40u, 8u, 72u), TEST_LOCATION);
+  application.SendNotification();
+
+  damagedRects.clear();
+  application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+  DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+
+  // Aligned by 16
+  clippingRect = Rect<int>(0, 688, 80, 112); // in screen coordinates
+
+  DirtyRectChecker(damagedRects, {clippingRect}, true, TEST_LOCATION);
+  application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+  END_TEST;
+}
index c193b0559a66bf4d0c2c815e92b5a31e4364d446..7e3d251ae5767e93c617d42cbe838e1b1a79ff31 100644 (file)
@@ -189,8 +189,8 @@ int UtcDaliVisualRendererDefaultProperties(void)
   VisualRenderer  renderer     = VisualRenderer::New(geometry, shader);
   Renderer        baseRenderer = Renderer::New(geometry, shader);
 
-  DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 32, TEST_LOCATION);
-  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32 + 8, TEST_LOCATION);
+  DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 33, TEST_LOCATION);
+  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 33 + 8, TEST_LOCATION);
 
   TEST_RENDERER_PROPERTY(renderer, "transformOffset", Property::VECTOR2, true, true, true, VisualRenderer::Property::TRANSFORM_OFFSET, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "transformSize", Property::VECTOR2, true, true, true, VisualRenderer::Property::TRANSFORM_SIZE, TEST_LOCATION);
index 6357927312db4652b29aaccbf9147d6ca0aeb98d..97129729213b73894d457e90c72f8139ce809403 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_RENDERER_DEVEL_H
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -163,6 +163,16 @@ enum Type
    * @details name "instanceCount", type INTEGER
    */
   INSTANCE_COUNT = OPACITY + 3,
+
+  /**
+   * @brief Increase the range of update area by pixel value.
+   * @note Extents the area - the position and the size - used for the attached actor's damaged area calculation.
+   * This value be appended after calculate all update area, like visual offset.
+   * @see Dali::Actor::Property::UPDATE_AREA_HINT
+   * @details name "updateAreaExtents", type EXTENTS
+   * @SINCE_2_4.11
+   */
+  UPDATE_AREA_EXTENTS = OPACITY + 4,
 };
 } // namespace Property
 
index 2a626fca6f357ba3b3c307317cbfaee83f560c16..0d29bc26cda55216aac9708d319f287535b8e1e2 100644 (file)
@@ -70,6 +70,7 @@ DALI_PROPERTY("rendererOpacity", FLOAT, true, true, true, Dali::Renderer::Proper
 DALI_PROPERTY("renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR)
 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION)
 DALI_PROPERTY("instanceCount", INTEGER, true, false, false, Dali::DevelRenderer::Property::INSTANCE_COUNT)
+DALI_PROPERTY("updateAreaExtents", EXTENTS, true, false, false, Dali::DevelRenderer::Property::UPDATE_AREA_EXTENTS)
 DALI_PROPERTY_TABLE_END(DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties)
 
 // Property string to enumeration tables:
@@ -718,6 +719,19 @@ void Renderer::SetDefaultProperty(Property::Index        index,
       }
       break;
     }
+    case DevelRenderer::Property::UPDATE_AREA_EXTENTS:
+    {
+      Extents updateAreaExtents;
+      if(propertyValue.Get(updateAreaExtents))
+      {
+        if(mUpdateAreaExtents != updateAreaExtents)
+        {
+          mUpdateAreaExtents = updateAreaExtents;
+          SetUpdateAreaExtentsMessage(GetEventThreadServices(), GetRendererSceneObject(), mUpdateAreaExtents);
+        }
+      }
+      break;
+    }
   }
 }
 
@@ -884,6 +898,7 @@ Renderer::Renderer(const SceneGraph::Renderer* sceneObject)
   mDepthIndex(0),
   mIndexedDrawFirstElement(0),
   mIndexedDrawElementCount(0),
+  mUpdateAreaExtents(),
   mStencilParameters(RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP),
   mBlendingOptions(),
   mDepthFunction(DepthFunction::LESS),
@@ -1087,6 +1102,11 @@ bool Renderer::GetCachedPropertyValue(Property::Index index, Property::Value& va
       value = int(mInstanceCount);
       break;
     }
+    case DevelRenderer::Property::UPDATE_AREA_EXTENTS:
+    {
+      value = mUpdateAreaExtents;
+      break;
+    }
     default:
     {
       // Must be a scene-graph only property
index b116fd5fe894b28c4516d2ffaac23b2ce824e39d..f382094ec91130d177541405b851023ef6196097 100644 (file)
@@ -279,6 +279,8 @@ protected:
   uint32_t mIndexedDrawElementCount; ///< Number of elements to draw
   uint32_t mInstanceCount{0};        ///< Number of instances to draw
 
+  Dali::Extents mUpdateAreaExtents;
+
   Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
   BlendingOptions                     mBlendingOptions;   ///< Local copy of blending options bitmask
 
index 5a99df2805c07886eabe029721241b615615cfa6..4f648dc6cee6465370c01e72ff480b30afb0a95f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -23,6 +23,7 @@
 #include <dali/internal/update/common/property-resetter.h>
 #include <dali/internal/update/manager/update-manager.h>
 #include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/public-api/common/extents.h>
 
 namespace Dali::Internal::SceneGraph
 {
@@ -322,6 +323,13 @@ inline void SetInstanceCountMessage(EventThreadServices& eventThreadServices, co
   new(slot) LocalType(&renderer, &SceneGraph::Renderer::SetInstanceCount, instanceCount);
 }
 
+inline void SetUpdateAreaExtentsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Extents& updateAreaExtents)
+{
+  using LocalType = MessageValue1<SceneGraph::Renderer, Extents>;
+  uint32_t* slot  = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+  new(slot) LocalType(&renderer, &SceneGraph::Renderer::SetUpdateAreaExtents, updateAreaExtents);
+}
+
 } // namespace Dali::Internal::SceneGraph
 
 #endif //DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H
index d600f750e4a6b4c2e4713c378b3f161050f6307e..eef4926ebca64cfdae16a553a925181ed0b072ac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -83,6 +83,19 @@ enum Flags
   RESEND_SET_RENDER_CALLBACK         = 1 << 21
 };
 
+inline Vector4 AdjustExtents(const Vector4& updateArea, const Dali::Extents& updateAreaExtents)
+{
+  if(DALI_LIKELY(updateAreaExtents == Dali::Extents()))
+  {
+    return updateArea;
+  }
+  const float left   = updateArea.x - updateArea.z * 0.5f - static_cast<float>(updateAreaExtents.start);
+  const float right  = updateArea.x + updateArea.z * 0.5f + static_cast<float>(updateAreaExtents.end);
+  const float top    = updateArea.y - updateArea.w * 0.5f - static_cast<float>(updateAreaExtents.top);
+  const float bottom = updateArea.y + updateArea.w * 0.5f + static_cast<float>(updateAreaExtents.bottom);
+  return Vector4((left + right) * 0.5f, (top + bottom) * 0.5f, (right - left), (bottom - top));
+}
+
 } // Anonymous namespace
 
 RendererKey Renderer::NewKey()
@@ -110,6 +123,7 @@ Renderer::Renderer()
   mIndexedDrawElementsCount(0u),
   mBlendBitmask(0u),
   mResendFlag(0u),
+  mUpdateAreaExtents(),
   mDepthFunction(DepthFunction::LESS),
   mFaceCullingMode(FaceCullingMode::NONE),
   mBlendMode(BlendMode::AUTO),
@@ -617,6 +631,15 @@ void Renderer::SetStencilOperationOnZPass(StencilOperation::Type stencilOperatio
   mResendFlag |= RESEND_STENCIL_OPERATION_ON_Z_PASS;
 }
 
+void Renderer::SetUpdateAreaExtents(const Dali::Extents& updateAreaExtents)
+{
+  if(mUpdateAreaExtents != updateAreaExtents)
+  {
+    mUpdateAreaExtents = updateAreaExtents;
+    SetUpdated(true);
+  }
+}
+
 void Renderer::SetRenderCallback(RenderCallback* callback)
 {
   if(mRenderCallback != callback)
@@ -917,9 +940,9 @@ Vector4 Renderer::GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex,
 {
   if(mVisualProperties)
   {
-    return mVisualProperties->GetVisualTransformedUpdateArea(updateBufferIndex, originalUpdateArea);
+    return AdjustExtents(mVisualProperties->GetVisualTransformedUpdateArea(updateBufferIndex, originalUpdateArea), mUpdateAreaExtents);
   }
-  return originalUpdateArea;
+  return AdjustExtents(originalUpdateArea, mUpdateAreaExtents);
 }
 
 void Renderer::OnVisualRendererPropertyUpdated(bool bake)
index 252f0dd61f8457436072ba4ffe03215fddeaf46e..83d5ce28dae352dd2c1e6fc613ad6e99e3383b18 100644 (file)
@@ -467,6 +467,19 @@ public:
     mInstanceCount = instanceCount;
   }
 
+  /**
+   * @brief Set the extents of update area. It will be used when we calculate damaged rect.
+   */
+  void SetUpdateAreaExtents(const Dali::Extents& updateAreaExtents);
+
+  /**
+   * @brief Get the extents of update area. It will be used when we calculate damaged rect.
+   */
+  Dali::Extents GetUpdateAreaExtents() const
+  {
+    return mUpdateAreaExtents;
+  }
+
   /**
    * Sets RenderCallback object
    *
@@ -613,6 +626,8 @@ private:
   UniformMap::SizeType mUniformMapChangeCounter{0u}; ///< Value to check if uniform data should be updated
   UniformMap::SizeType mShaderMapChangeCounter{0u};  ///< Value to check if uniform data should be updated
 
+  Dali::Extents mUpdateAreaExtents;
+
   DepthFunction::Type            mDepthFunction : 4;              ///< Local copy of the depth function
   FaceCullingMode::Type          mFaceCullingMode : 3;            ///< Local copy of the mode of face culling
   BlendMode::Type                mBlendMode : 3;                  ///< Local copy of the mode of blending