Add Rendered flag for PreRender the Scene 93/321993/6
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 2 Apr 2025 02:07:31 +0000 (11:07 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 8 Apr 2025 04:55:49 +0000 (13:55 +0900)
Let we make some interface whether given scene rendered previous frame or not.

Until now, we only had "current" scene has render instruction to scene or not.
But also, we should clear the scene if "previous" scene had render instruction
but not now.

Since it could not be known by single boolean value, we make another class
to communicate the PreRender result.

By this infomation, we should determine whether we should call
ClearScene() or not even if fullSwap keyword not applied.

Furthermore, Let we make PreRender(Scene) API name as PreRenderScene,
pairwise with RenderScene().

Change-Id: Iab820942aff1d136cef1ab111901dc99c7ccdcf7
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
12 files changed:
automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
dali/integration-api/core.cpp
dali/integration-api/core.h
dali/integration-api/file.list
dali/integration-api/scene-pre-render-status.h [new file with mode: 0644]
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/update/common/scene-graph-scene.cpp
dali/internal/update/common/scene-graph-scene.h

index e5a943a51a052f1419b17f2124b86db19ac38150..e8745370db7ef2b460b2293b23d700e67c40b286 100644 (file)
@@ -220,6 +220,9 @@ bool TestApplication::Render(uint32_t intervalMilliseconds, const char* location
   {
     for(auto&& scene : mScenes)
     {
+      std::vector<Rect<int>> damagedRects;
+
+      mCore->PreRenderScene(scene, mScenePreRenderStatus, damagedRects);
       mCore->RenderScene(mRenderStatus, scene, true /*render the off-screen buffers*/);
       mCore->RenderScene(mRenderStatus, scene, false /*render the surface*/);
     }
@@ -236,7 +239,7 @@ bool TestApplication::PreRenderWithPartialUpdate(uint32_t intervalMilliseconds,
   DoUpdate(intervalMilliseconds, location);
 
   mCore->PreRender(mRenderStatus, false /*do not force clear*/);
-  mCore->PreRender(mScene, damagedRects);
+  mCore->PreRenderScene(mScene, mScenePreRenderStatus, damagedRects);
 
   return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
 }
@@ -267,7 +270,7 @@ bool TestApplication::RenderWithPartialUpdate(uint32_t intervalMilliseconds, con
     std::vector<Rect<int>> damagedRects;
     Rect<int>              clippingRect{};
 
-    mCore->PreRender(scene, damagedRects);
+    mCore->PreRenderScene(scene, mScenePreRenderStatus, damagedRects);
     mCore->RenderScene(mRenderStatus, scene, true /*render the off-screen buffers*/);
     for(auto&& iter : damagedRects)
     {
@@ -305,8 +308,11 @@ bool TestApplication::GetRenderNeedsPostRender()
 
 bool TestApplication::RenderOnly()
 {
+  std::vector<Rect<int>> damagedRects;
+
   // Update Time values
   mCore->PreRender(mRenderStatus, false /*do not force clear*/);
+  mCore->PreRenderScene(mScene, mScenePreRenderStatus, damagedRects);
   mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
   mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/);
   mCore->PostRender();
index 6876dc8c28c9d4bc159c6ca09ef21f1faa5588e1..57713b119193f483131a5456115b89cf94944a8b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_APPLICATION_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.
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/resource-policies.h>
+#include <dali/integration-api/scene-pre-render-status.h>
 #include <dali/integration-api/scene.h>
 #include <dali/integration-api/trace.h>
 
@@ -105,8 +106,9 @@ protected:
   TestGraphicsController  mGraphicsController;
   TestRenderSurface*      mRenderSurface;
 
-  Integration::UpdateStatus mStatus;
-  Integration::RenderStatus mRenderStatus;
+  Integration::UpdateStatus         mStatus;
+  Integration::RenderStatus         mRenderStatus;
+  Integration::ScenePreRenderStatus mScenePreRenderStatus;
 
   Integration::Core*              mCore;
   Dali::Integration::Scene        mScene;
index 9e352f1787f264121aee59b7bd335ceea1e87b9d..1a7e2f142a18cfa4cf547757981ea527a3560830 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/events/event.h>
 #include <dali/integration-api/processor-interface.h>
+#include <dali/integration-api/scene-pre-render-status.h>
 #include <dali/internal/common/core-impl.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/common/dali-common.h>
@@ -109,9 +110,9 @@ void Core::PreRender(RenderStatus& status, bool forceClear)
   mImpl->PreRender(status, forceClear);
 }
 
-bool Core::PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects)
+void Core::PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects)
 {
-  return mImpl->PreRender(scene, damagedRects);
+  mImpl->PreRenderScene(scene, status, damagedRects);
 }
 
 void Core::RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo)
index 4fbb1f183de8190f2c974aca64302420dff7afed..d6e2e6f2598f050e0b64186a128a3ee0572bdade 100644 (file)
@@ -51,6 +51,7 @@ class PlatformAbstraction;
 class Processor;
 class RenderController;
 class Scene;
+class ScenePreRenderStatus;
 struct Event;
 struct TouchEvent;
 
@@ -364,10 +365,11 @@ public:
    * Multi-threading note: this method should be called from a dedicated rendering thread.
    * @pre The GL context must have been created, and made current.
    * @param[in] scene The scene to be rendered.
+   * @param[out] status The status of pre render operation.
    * @param[out] damagedRects containing damaged render items rects for this pass.
    * @return true if the scene has something to render, false if there is nothing to render
    */
-  bool PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
+  void PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects);
 
   /**
    * Render a scene in the next frame. This method should be preceded by a call up PreRender.
index d7feadfef7502374513d2e92339a9ab47eb7bb6f..8866b22d6e2ee5ab9b19e34cddfbffb6d12f7dd5 100644 (file)
@@ -54,6 +54,7 @@ SET( platform_abstraction_header_files
    ${platform_abstraction_src_dir}/resource-policies.h
    ${platform_abstraction_src_dir}/resource-types.h
    ${platform_abstraction_src_dir}/scene.h
+   ${platform_abstraction_src_dir}/scene-pre-render-status.h
    ${platform_abstraction_src_dir}/shader-integ.h
    ${platform_abstraction_src_dir}/testing.h
    ${platform_abstraction_src_dir}/texture-integ.h
diff --git a/dali/integration-api/scene-pre-render-status.h b/dali/integration-api/scene-pre-render-status.h
new file mode 100644 (file)
index 0000000..f02777c
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef DALI_SCENE_PRE_RENDER_STATUS_H
+#define DALI_SCENE_PRE_RENDER_STATUS_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-controller.h>
+#include <dali/graphics-api/graphics-render-target-create-info.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/gesture-enumerations.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/handle.h>
+
+namespace Dali::Integration
+{
+/**
+* The status of the Core::PreRenderScene operation.
+*/
+class DALI_CORE_API ScenePreRenderStatus
+{
+public:
+  /**
+  * Constructor
+  */
+  ScenePreRenderStatus()
+  : hasRenderInstructionToScene(false),
+    hadRenderInstructionToScene(false)
+  {
+  }
+
+  void SetHasRenderInstructionToScene(bool renderInstructionExist)
+  {
+    hasRenderInstructionToScene = renderInstructionExist;
+  }
+
+  bool HasRenderInstructionToScene() const
+  {
+    return hasRenderInstructionToScene;
+  }
+
+  void SetHadRenderInstructionToScene(bool renderInstructionExisted)
+  {
+    hadRenderInstructionToScene = renderInstructionExisted;
+  }
+
+  bool HadRenderInstructionToScene() const
+  {
+    return hadRenderInstructionToScene;
+  }
+
+private:
+  bool hasRenderInstructionToScene : 1; ///< True if has render instruction to the scene.
+  bool hadRenderInstructionToScene : 1; ///< True if had render instruction to the scene.
+};
+
+} // namespace Dali::Integration
+
+#endif // DALI_SCENE_PRE_RENDER_STATUS_H
index a364255aad95bba32389160f783ccd6e1b4e8f5d..2f3d333c10c3e3b79f548b55ab336e9b7b8b0bc5 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali/integration-api/platform-abstraction.h>
 #include <dali/integration-api/processor-interface.h>
 #include <dali/integration-api/render-controller.h>
+#include <dali/integration-api/scene-pre-render-status.h>
 #include <dali/integration-api/trace.h>
 
 #include <dali/internal/event/actors/actor-impl.h>
@@ -221,9 +222,9 @@ void Core::PreRender(RenderStatus& status, bool forceClear)
   mRenderManager->PreRender(status, forceClear);
 }
 
-bool Core::PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects)
+void Core::PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects)
 {
-  return mRenderManager->PreRender(scene, damagedRects);
+  mRenderManager->PreRenderScene(scene, status, damagedRects);
 }
 
 void Core::RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo)
index 87a4a353b9853390d1b93ee11f19119edcf1029b..46e942aa7b19606a8007ef4b39550d8efae0e494 100644 (file)
@@ -44,6 +44,7 @@ class RenderController;
 class PlatformAbstraction;
 class UpdateStatus;
 class RenderStatus;
+class ScenePreRenderStatus;
 struct Event;
 struct TouchEvent;
 } // namespace Integration
@@ -127,9 +128,9 @@ public:
   void PreRender(Integration::RenderStatus& status, bool forceClear);
 
   /**
-   * @copydoc Dali::Integration::Core::PreRender()
+   * @copydoc Dali::Integration::Core::PreRenderScene()
    */
-  bool PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
+  void PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects);
 
   /**
    * @copydoc Dali::Integration::Core::RenderScene()
index d9d6bac3456e8340bdbeac586e7e9fa3931bc58d..7194f856de7bd5957a86484d0bb59736a9ccaa4a 100644 (file)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/ordered-set.h>
+#include <dali/integration-api/scene-pre-render-status.h>
 #include <dali/integration-api/trace.h>
 #include <dali/public-api/common/vector-wrapper.h>
 
@@ -678,18 +679,18 @@ void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear
   mImpl->commandBufferSubmitted = false;
 }
 
-bool RenderManager::PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects)
+void RenderManager::PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects)
 {
-  bool             renderToScene = false;
   Internal::Scene& sceneInternal = GetImplementation(scene);
   Scene*           sceneObject   = sceneInternal.GetSceneObject();
 
   if(!sceneObject)
   {
     // May not be a scene object if the window is being removed.
-    return renderToScene;
+    return;
   }
 
+  bool           renderToScene    = false;
   const uint32_t instructionCount = sceneObject->GetRenderInstructions().Count(mImpl->renderBufferIndex);
   for(uint32_t i = instructionCount; i > 0; --i)
   {
@@ -701,9 +702,13 @@ bool RenderManager::PreRender(Integration::Scene& scene, std::vector<Rect<int>>&
     }
   }
 
+  status.SetHadRenderInstructionToScene(sceneObject->HasRenderInstructionToScene());
+  status.SetHasRenderInstructionToScene(renderToScene);
+  sceneObject->SetHasRenderInstructionToScene(renderToScene);
+
   if(mImpl->partialUpdateAvailable != Integration::PartialUpdateAvailable::TRUE)
   {
-    return renderToScene;
+    return;
   }
 
   if(!sceneObject || sceneObject->IsRenderingSkipped())
@@ -717,7 +722,7 @@ bool RenderManager::PreRender(Integration::Scene& scene, std::vector<Rect<int>>&
     {
       DALI_LOG_RELEASE_INFO("RenderingSkipped was set true. Skip pre-rendering\n");
     }
-    return renderToScene;
+    return;
   }
 
   class DamagedRectsCleaner
@@ -763,7 +768,7 @@ bool RenderManager::PreRender(Integration::Scene& scene, std::vector<Rect<int>>&
     // Clear all dirty rects
     // The rects will be added when partial updated is enabled again
     itemsDirtyRects.clear();
-    return renderToScene;
+    return;
   }
 
   // Mark previous dirty rects in the std::unordered_map.
@@ -961,7 +966,6 @@ bool RenderManager::PreRender(Integration::Scene& scene, std::vector<Rect<int>>&
   {
     damagedRectCleaner.SetCleanOnReturn(false);
   }
-  return renderToScene;
 }
 
 void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo)
index 2f7ab509439b45775db08ca3c892b8e063dcd392..8828e693dc945294c14f1ceb97f87428c21b40c7 100644 (file)
@@ -35,6 +35,7 @@ namespace Integration
 {
 class RenderStatus;
 class Scene;
+class ScenePreRenderStatus;
 } // namespace Integration
 
 struct Vector4;
@@ -381,11 +382,12 @@ public:
    * by a call up Update.
    * Multi-threading note: this method should be called from a dedicated rendering thread.
    * @pre The graphics implementation must be initialized
+   * @param[out] status The status of pre render operation.
    * @param[in] scene The scene to be rendered.
    * @param[out] damagedRects The list of damaged rects for the current render pass.
    * @return True if this scene will present, false otherwise.
    */
-  bool PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
+  void PreRenderScene(Integration::Scene& scene, Integration::ScenePreRenderStatus& status, std::vector<Rect<int>>& damagedRects);
 
   // This method should be called from Core::RenderScene()
 
index a3268cd188c43f13b23b42a11cefa04e478d083a..1abd8d4bae5460e5b0ac381917eaf08f174058a2 100644 (file)
@@ -39,7 +39,8 @@ Scene::Scene()
   mRotationCompletedAcknowledgement(false),
   mSkipRendering(false),
   mNeedFullUpdate(false),
-  mPartialUpdateEnabled(true)
+  mPartialUpdateEnabled(true),
+  mHasRenderInstructionToScene(false)
 {
 }
 
index 6951a92c172a763fc0d42af321dd2ff8edc50bbf..4d9c3e1f4a136f5bc05e059dc6a5695afc4a60a4 100644 (file)
@@ -347,6 +347,16 @@ public:
     return mNeedFullUpdate;
   }
 
+  void SetHasRenderInstructionToScene(bool renderInstructionExist)
+  {
+    mHasRenderInstructionToScene = renderInstructionExist;
+  }
+
+  bool HasRenderInstructionToScene() const
+  {
+    return mHasRenderInstructionToScene;
+  }
+
   /**
    * Get the render target created for the scene
    *
@@ -439,10 +449,11 @@ private:
 
   float mKeepRenderingSeconds{0.0f}; ///< Time to keep rendering
 
-  bool mRotationCompletedAcknowledgement; ///< The flag of sending the acknowledgement to complete window rotation.
-  bool mSkipRendering;                    ///< A flag to skip rendering
-  bool mNeedFullUpdate;                   ///< A flag to update full area
-  bool mPartialUpdateEnabled;             ///< True if the partial update is enabled
+  bool mRotationCompletedAcknowledgement : 1; ///< The flag of sending the acknowledgement to complete window rotation.
+  bool mSkipRendering : 1;                    ///< A flag to skip rendering
+  bool mNeedFullUpdate : 1;                   ///< A flag to update full area
+  bool mPartialUpdateEnabled : 1;             ///< True if the partial update is enabled
+  bool mHasRenderInstructionToScene : 1;      ///< True if has render instruction to the scene. Update at PreRender time.
 
   // Render target, command buffer and render passes