Merge "Add initialize resetter to reduce AnimatableProperty life" into devel/master
authorDavid Steele <david.steele@samsung.com>
Mon, 27 Mar 2023 14:42:01 +0000 (14:42 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 27 Mar 2023 14:42:01 +0000 (14:42 +0000)
16 files changed:
automated-tests/src/dali/utc-Dali-Renderer.cpp
dali/devel-api/common/stage.cpp
dali/devel-api/common/stage.h
dali/internal/common/owner-pointer.h
dali/internal/event/events/actor-observer.cpp
dali/internal/event/events/actor-observer.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/update/controllers/render-message-dispatcher.cpp
dali/internal/update/controllers/render-message-dispatcher.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/rendering/scene-graph-renderer.cpp
dali/internal/update/rendering/scene-graph-texture-set.cpp
dali/internal/update/rendering/scene-graph-texture-set.h
dali/public-api/dali-core-version.cpp
packaging/dali.spec

index 763fa67..b99feb0 100644 (file)
@@ -4255,3 +4255,56 @@ int utcDaliRendererPartialUpdateAddRemoveRenderer(void)
 
   END_TEST;
 }
+
+int utcDaliRendererDoNotSkipRenderIfTextureSetChanged(void)
+{
+  TestApplication application;
+  tet_infoline("Check to not skip rendering in case of the TextureSet Changed");
+
+  TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
+  drawTrace.Enable(true);
+  drawTrace.Reset();
+
+  Actor actor = CreateRenderableActor();
+  actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  actor.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f));
+  application.GetScene().Add(actor);
+
+  // Make any animation to skip rendering.
+  // Delay duration must be bigger than 0.0f
+  Animation animation = Animation::New(2.0f);
+  animation.AnimateTo(Property(actor, Actor::Property::POSITION_X), 1.0f, TimePeriod(1.0f, 1.0f));
+  animation.Play();
+
+  DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+  Renderer renderer = actor.GetRendererAt(0u);
+
+  Texture    image      = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
+  TextureSet textureSet = CreateTextureSet(image);
+
+  // Render at least 2 frames
+  application.SendNotification();
+  application.Render();
+  application.SendNotification();
+  application.Render();
+
+  drawTrace.Reset();
+
+  application.SendNotification();
+  application.Render();
+
+  // Skip rendering
+  DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
+
+  // Change TextureSet
+  renderer.SetTextures(textureSet);
+
+  application.SendNotification();
+  application.Render(16u);
+
+  // Should not Skip rendering!
+  DALI_TEST_GREATER(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION);
+
+  END_TEST;
+}
\ No newline at end of file
index f554064..02f361f 100644 (file)
@@ -38,9 +38,9 @@ Stage::Stage(const Stage& handle) = default;
 
 Stage& Stage::operator=(const Stage& rhs) = default;
 
-Stage::Stage(Stage&& handle) = default;
+Stage::Stage(Stage&& handle) noexcept = default;
 
-Stage& Stage::operator=(Stage&& rhs) = default;
+Stage& Stage::operator=(Stage&& rhs) noexcept = default;
 
 Stage::Stage(Internal::Stage* internal)
 : BaseHandle(internal)
index 86d17c4..cf271cf 100644 (file)
@@ -140,7 +140,7 @@ public:
    *
    * @param[in] handle A reference to the moved handle
    */
-  Stage(Stage&& handle);
+  Stage(Stage&& handle) noexcept;
 
   /**
    * @brief This move assignment operator is required for (smart) pointer semantics.
@@ -148,7 +148,7 @@ public:
    * @param[in] rhs A reference to the moved handle
    * @return A reference to this
    */
-  Stage& operator=(Stage&& rhs);
+  Stage& operator=(Stage&& rhs) noexcept;
 
   // Containment
 
index 28fe69e..b821205 100644 (file)
@@ -64,7 +64,7 @@ public:
    * Move constructor. Passes the ownership of a pointer to another.
    * @param[in] other The pointer that gives away the ownership.
    */
-  OwnerPointer(OwnerPointer&& other)
+  OwnerPointer(OwnerPointer&& other) noexcept
   : mObject(nullptr)
   {
     Swap(other);
@@ -91,7 +91,7 @@ public:
    * Move assignment operator. Passes the ownership of a pointer to another.
    * @param[in] other The pointer that gives away the ownership.
    */
-  OwnerPointer& operator=(OwnerPointer&& other)
+  OwnerPointer& operator=(OwnerPointer&& other) noexcept
   {
     // Reuse operator=
     return operator=(other);
index aa8395e..f1da6e0 100644 (file)
@@ -52,13 +52,13 @@ ActorObserver::~ActorObserver()
   delete mRemoveCallback;
 }
 
-ActorObserver::ActorObserver(ActorObserver&& other)
+ActorObserver::ActorObserver(ActorObserver&& other) noexcept
 : ActorObserver(nullptr)
 {
   operator=(std::move(other));
 }
 
-ActorObserver& ActorObserver::operator=(ActorObserver&& other)
+ActorObserver& ActorObserver::operator=(ActorObserver&& other) noexcept
 {
   if(this != &other)
   {
index 329930a..032d891 100644 (file)
@@ -71,7 +71,7 @@ public:
    * @note The other's actor is appropriately disconnected.
    * @note Ownership of callback is passed onto this class.
    */
-  ActorObserver(ActorObserver&& other);
+  ActorObserver(ActorObserver&& other) noexcept;
 
   /**
    * Move assignment operator.
@@ -81,7 +81,7 @@ public:
    * @note The other's actor is appropriately disconnected.
    * @note Ownership of callback is passed onto this class.
    */
-  ActorObserver& operator=(ActorObserver&& other);
+  ActorObserver& operator=(ActorObserver&& other) noexcept;
 
   // Not copyable
 
index 4f8e236..9a895fc 100644 (file)
@@ -177,6 +177,7 @@ struct RenderManager::Impl
   std::unique_ptr<Dali::ThreadPool> threadPool;            ///< The thread pool
   Vector<Graphics::Texture*>        boundTextures;         ///< The textures bound for rendering
   Vector<Graphics::Texture*>        textureDependencyList; ///< The dependency list of bound textures
+  Vector<Render::TextureKey>        updatedTextures{};     ///< The updated texture list
 
   uint32_t    frameCount{0u};                                                    ///< The current frame count
   BufferIndex renderBufferIndex{SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX}; ///< The index of the buffer to read from; this is opposite of the "update" buffer
@@ -247,6 +248,7 @@ void RenderManager::AddTexture(const Render::TextureKey& textureKey)
 
   textureKey->Initialize(mImpl->graphicsController);
   mImpl->textureContainer.PushBack(textureKey);
+  mImpl->updatedTextures.PushBack(textureKey);
 }
 
 void RenderManager::RemoveTexture(const Render::TextureKey& textureKey)
@@ -267,12 +269,24 @@ void RenderManager::UploadTexture(const Render::TextureKey& textureKey, PixelDat
 {
   DALI_ASSERT_DEBUG(textureKey && "Trying to upload to empty texture key");
   textureKey->Upload(pixelData, params);
+
+  mImpl->updatedTextures.PushBack(textureKey);
 }
 
 void RenderManager::GenerateMipmaps(const Render::TextureKey& textureKey)
 {
   DALI_ASSERT_DEBUG(textureKey && "Trying to generate mipmaps on empty texture key");
   textureKey->GenerateMipmaps();
+
+  mImpl->updatedTextures.PushBack(textureKey);
+}
+
+void RenderManager::SetTextureUpdated(const Render::TextureKey& textureKey)
+{
+  DALI_ASSERT_DEBUG(textureKey && "Trying to set updated on empty texture key");
+  textureKey->SetUpdated(true);
+
+  mImpl->updatedTextures.PushBack(textureKey);
 }
 
 void RenderManager::SetFilterMode(Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode)
@@ -999,11 +1013,12 @@ void RenderManager::PostRender()
     iter->OnRenderFinished();
   }
 
-  // Notify RenderTexture that rendering has finished
-  for(auto&& iter : mImpl->textureContainer)
+  // Notify updated RenderTexture that rendering has finished
+  for(auto&& iter : mImpl->updatedTextures)
   {
     iter->OnRenderFinished();
   }
+  mImpl->updatedTextures.Clear();
 
   mImpl->UpdateTrackers();
 
index cf40117..6bd9a3d 100644 (file)
@@ -254,6 +254,12 @@ public:
   void GenerateMipmaps(const Render::TextureKey& texture);
 
   /**
+   * Sets the updated flag of a texture
+   * @param[in] texture The updated texture
+   */
+  void SetTextureUpdated(const Render::TextureKey& textureKey);
+
+  /**
    * Adds a framebuffer to the render manager
    * @param[in] frameBuffer The framebuffer to add
    */
index c0d7b20..df1fa69 100644 (file)
@@ -84,6 +84,16 @@ void RenderMessageDispatcher::RemoveRenderTracker(Render::RenderTracker& renderT
   new(slot) DerivedType(&mRenderManager, &RenderManager::RemoveRenderTracker, &renderTracker);
 }
 
+RenderManager& RenderMessageDispatcher::GetRenderManager()
+{
+  return mRenderManager;
+}
+
+uint32_t* RenderMessageDispatcher::ReserveMessageSlot(std::size_t size)
+{
+  return mRenderQueue.ReserveMessageSlot(mBuffers.GetUpdateBufferIndex(), size);
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal
index 59a6e81..4242c13 100644 (file)
@@ -82,6 +82,19 @@ public:
    */
   void RemoveRenderTracker(Render::RenderTracker& renderTracker);
 
+  /**
+   * Return the render manager.
+   * @return A reference to the render manager.
+   */
+  RenderManager& GetRenderManager();
+
+  /**
+   * Reserve space for another message in the queue.
+   * @param[in] size The message size with respect to the size of type "char".
+   * @return A pointer to the first char allocated for the message.
+   */
+  uint32_t* ReserveMessageSlot(std::size_t size);
+
 private:
   RenderManager& mRenderManager;
   RenderQueue&   mRenderQueue;
index 8ba1f40..4a2f1bb 100644 (file)
@@ -701,6 +701,7 @@ void UpdateManager::SetPanGestureProcessor(PanGesture* panGestureProcessor)
 
 void UpdateManager::AddTextureSet(OwnerPointer<TextureSet>& textureSet)
 {
+  textureSet->SetRenderMessageDispatcher(&mImpl->renderMessageDispatcher);
   mImpl->textureSets.PushBack(textureSet.Release());
 }
 
index 3916e37..b8ad3ae 100644 (file)
@@ -146,7 +146,7 @@ RendererKey Renderer::GetKey(Renderer* renderer)
 
 bool Renderer::PrepareRender(BufferIndex updateBufferIndex)
 {
-  bool rendererUpdated        = mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY || mUpdateDecay > 0;
+  bool rendererUpdated        = mDirtyFlag || mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY || mUpdateDecay > 0;
   auto shaderMapChangeCounter = mShader ? mShader->GetUniformMap().GetChangeCounter() : 0u;
   bool shaderMapChanged       = mShader && (mShaderMapChangeCounter != shaderMapChangeCounter);
   if(shaderMapChanged)
@@ -367,6 +367,7 @@ void Renderer::SetGeometry(Render::Geometry* geometry)
   DALI_ASSERT_DEBUG(geometry != NULL && "Geometry pointer is NULL");
   mGeometry = geometry;
 
+  mDirtyFlag = true;
   if(mRenderer)
   {
     mResendFlag |= RESEND_GEOMETRY;
@@ -592,6 +593,8 @@ float Renderer::GetOpacity(BufferIndex updateBufferIndex) const
 void Renderer::SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior)
 {
   mRenderingBehavior = renderingBehavior;
+
+  mDirtyFlag = true;
   SetUpdated(true);
 }
 
index 106b711..338c335 100644 (file)
@@ -20,7 +20,9 @@
 // INTERNAL HEADERS
 #include <dali/internal/common/internal-constants.h>
 #include <dali/internal/common/memory-pool-object-allocator.h>
+#include <dali/internal/render/common/render-manager.h>
 #include <dali/internal/render/renderers/render-texture.h>
+#include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/rendering/scene-graph-renderer.h>
 
 namespace //Unnamed namespace
@@ -75,7 +77,14 @@ void TextureSet::SetSampler(uint32_t index, Render::Sampler* sampler)
 
   if(index < static_cast<uint32_t>(mTextures.Size()))
   {
-    mTextures[index]->SetUpdated(true);
+    // Send a message to the RenderManagerReserveMessageSlot
+    using DerivedType = MessageValue1<RenderManager, Render::TextureKey>;
+
+    // Reserve some memory inside the render queue
+    uint32_t* slot = mRenderMessageDispatcher->ReserveMessageSlot(sizeof(DerivedType));
+
+    // Construct message in the render queue memory; note that delete should not be called on the return value
+    new(slot) DerivedType(&mRenderMessageDispatcher->GetRenderManager(), &RenderManager::SetTextureUpdated, mTextures[index]);
   }
 }
 
@@ -108,7 +117,15 @@ void TextureSet::SetTexture(uint32_t index, const Render::TextureKey& texture)
   if(texture)
   {
     mHasAlpha |= texture->HasAlphaChannel();
-    texture->SetUpdated(true);
+
+    // Send a message to the RenderManagerReserveMessageSlot
+    using DerivedType = MessageValue1<RenderManager, Render::TextureKey>;
+
+    // Reserve some memory inside the render queue
+    uint32_t* slot = mRenderMessageDispatcher->ReserveMessageSlot(sizeof(DerivedType));
+
+    // Construct message in the render queue memory; note that delete should not be called on the return value
+    new(slot) DerivedType(&mRenderMessageDispatcher->GetRenderManager(), &RenderManager::SetTextureUpdated, texture);
   }
 }
 
@@ -117,6 +134,11 @@ bool TextureSet::HasAlpha() const
   return mHasAlpha;
 }
 
+void TextureSet::SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher)
+{
+  mRenderMessageDispatcher = renderMessageDispatcher;
+}
+
 uint32_t TextureSet::GetMemoryPoolCapacity()
 {
   return GetTextureSetMemoryPool().GetCapacity();
index 8f58ce2..25336fd 100644 (file)
@@ -37,6 +37,7 @@ class Texture;
 namespace SceneGraph
 {
 class Renderer;
+class RenderMessageDispatcher;
 
 class TextureSet
 {
@@ -94,6 +95,12 @@ public:
   }
 
   /**
+   * Set the renderMessageDispatcher to send message.
+   * @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
+   */
+  void SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher);
+
+  /**
    * Get the capacity of the memory pools
    * @return the capacity of the memory pools
    */
@@ -106,9 +113,10 @@ private:
   TextureSet();
 
 private:
-  Vector<Render::Sampler*>   mSamplers; ///< List of samplers used by each texture. Not owned
-  Vector<Render::TextureKey> mTextures; ///< List of Textures. Not owned
-  bool                       mHasAlpha; ///< if any of the textures has an alpha channel
+  Vector<Render::Sampler*>   mSamplers;                         ///< List of samplers used by each texture. Not owned
+  Vector<Render::TextureKey> mTextures;                         ///< List of Textures. Not owned
+  RenderMessageDispatcher*   mRenderMessageDispatcher{nullptr}; ///< for sending messages to render thread. Not owned
+  bool                       mHasAlpha;                         ///< if any of the textures has an alpha channel
 };
 
 inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, const Render::TextureKey& textureKey)
index 18d47ab..4a726d2 100644 (file)
@@ -27,7 +27,7 @@ namespace Dali
 {
 const uint32_t    CORE_MAJOR_VERSION = 2;
 const uint32_t    CORE_MINOR_VERSION = 2;
-const uint32_t    CORE_MICRO_VERSION = 18;
+const uint32_t    CORE_MICRO_VERSION = 19;
 const char* const CORE_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 4f9f909..019ea4b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2
 Summary:    DALi 3D Engine
-Version:    2.2.18
+Version:    2.2.19
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT