[Tizen] Remove useless flag at SceneGraph::Renderer.mDirtyFlag
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / scene-graph-renderer.h
index 889a791..5dabf05 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -26,6 +26,7 @@
 #include <dali/internal/update/common/animatable-property.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/uniform-map.h>
+#include <dali/internal/update/rendering/scene-graph-visual-renderer.h>
 #include <dali/public-api/rendering/geometry.h>
 #include <dali/public-api/rendering/renderer.h> // Dali::Renderer
 
@@ -66,97 +67,11 @@ namespace Internal
 {
 namespace SceneGraph
 {
+class NodeDataProvider;
 using RendererContainer = Dali::Vector<RendererKey>;
 using RendererIter      = RendererContainer::Iterator;
 using RendererConstIter = RendererContainer::ConstIterator;
 
-namespace VisualRenderer
-{
-struct AnimatableVisualProperties
-{
-  AnimatableVisualProperties()
-  : mTransformOffset(Vector2::ZERO),
-    mTransformSize(Vector2::ONE),
-    mTransformOrigin(Vector2::ZERO),
-    mTransformAnchorPoint(Vector2::ZERO),
-    mTransformOffsetSizeMode(Vector4::ZERO),
-    mExtraSize(Vector2::ZERO),
-    mMixColor(Vector3::ONE),
-    mPreMultipliedAlpha(0.0f),
-    mExtendedPropertiesDeleteFunction(nullptr)
-  {
-  }
-
-  ~AnimatableVisualProperties()
-  {
-    if(mExtendedProperties && mExtendedPropertiesDeleteFunction)
-    {
-      mExtendedPropertiesDeleteFunction(mExtendedProperties);
-    }
-  }
-
-  /**
-   * @brief Cached coefficient value when we calculate visual transformed update size.
-   * It can reduce complexity of calculate the vertex position.
-   *
-   * Vector2 vertexPosition = (XA * aPosition + XB) * originalSize + (CA * aPosition + CB) + Vector2(D, D) * aPosition
-   */
-  struct VisualTransformedUpdateSizeCoefficientCache
-  {
-    Vector2 coefXA{Vector2::ZERO};
-    Vector2 coefXB{Vector2::ZERO};
-    Vector2 coefCA{Vector2::ZERO};
-    Vector2 coefCB{Vector2::ZERO};
-    float   coefD{0.0f};
-
-    uint64_t hash{0u};
-    uint64_t decoratedHash{0u};
-  };
-  VisualTransformedUpdateSizeCoefficientCache mCoefficient; ///< Coefficient value to calculate visual transformed update size by VisualProperties more faster.
-
-  AnimatableProperty<Vector2> mTransformOffset;
-  AnimatableProperty<Vector2> mTransformSize;
-  AnimatableProperty<Vector2> mTransformOrigin;
-  AnimatableProperty<Vector2> mTransformAnchorPoint;
-  AnimatableProperty<Vector4> mTransformOffsetSizeMode;
-  AnimatableProperty<Vector2> mExtraSize;
-  AnimatableProperty<Vector3> mMixColor;
-  AnimatableProperty<float>   mPreMultipliedAlpha;
-
-  void* mExtendedProperties{nullptr};                        // Enable derived class to extend properties further
-  void (*mExtendedPropertiesDeleteFunction)(void*){nullptr}; // Derived class's custom delete functor
-};
-
-struct AnimatableDecoratedVisualProperties
-{
-  AnimatableDecoratedVisualProperties()
-  : mCornerRadius(Vector4::ZERO),
-    mCornerRadiusPolicy(1.0f),
-    mBorderlineWidth(0.0f),
-    mBorderlineColor(Color::BLACK),
-    mBorderlineOffset(0.0f),
-    mBlurRadius(0.0f)
-  {
-  }
-  ~AnimatableDecoratedVisualProperties()
-  {
-  }
-
-  // Delete function of AnimatableDecoratedVisualProperties* converted as void*
-  static void DeleteFunction(void* data)
-  {
-    delete static_cast<AnimatableDecoratedVisualProperties*>(data);
-  }
-
-  AnimatableProperty<Vector4> mCornerRadius;
-  AnimatableProperty<float>   mCornerRadiusPolicy;
-  AnimatableProperty<float>   mBorderlineWidth;
-  AnimatableProperty<Vector4> mBorderlineColor;
-  AnimatableProperty<float>   mBorderlineOffset;
-  AnimatableProperty<float>   mBlurRadius;
-};
-} // namespace VisualRenderer
-
 class Renderer : public PropertyOwner,
                  public UniformMapDataProvider,
                  public RenderDataProvider
@@ -476,14 +391,15 @@ public:
    * Retrieve the Render thread renderer
    * @return The associated render thread renderer
    */
-  Render::RendererKey GetRenderer();
+  Render::RendererKey GetRenderer() const;
 
   /**
    * Query whether the renderer is fully opaque, fully transparent or transparent.
    * @param[in] updateBufferIndex The current update buffer index.
+   * @param[in] renderPass render pass for this render instruction
    * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
    */
-  OpacityType GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const;
+  OpacityType GetOpacityType(BufferIndex updateBufferIndex, uint32_t renderPass, const Node& node) const;
 
   /**
    * Connect the object to the scene graph
@@ -501,6 +417,12 @@ public:
   void DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
 
   /**
+   * Detached from the scene graph object.
+   * @param[in] node node who detach this renderer.
+   */
+  void DetachFromNodeDataProvider(const NodeDataProvider& node);
+
+  /**
    * @copydoc RenderDataProvider::GetUniformMapDataProvider()
    */
   const UniformMapDataProvider& GetUniformMapDataProvider() const override
@@ -511,16 +433,23 @@ public:
   /**
    * @copydoc RenderDataProvider::IsUpdated()
    */
-  bool IsUpdated() const override
-  {
-    return Updated();
-  }
+  bool IsUpdated() const override;
 
   /**
    * @copydoc RenderDataProvider::GetVisualTransformedUpdateArea()
    */
   Vector4 GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex, const Vector4& originalUpdateArea) noexcept override;
 
+  uint32_t GetInstanceCount() const override
+  {
+    return mInstanceCount;
+  }
+
+  void SetInstanceCount(uint32_t instanceCount)
+  {
+    mInstanceCount = instanceCount;
+  }
+
   /**
    * Sets RenderCallback object
    *
@@ -559,10 +488,16 @@ public:
   bool IsDirty() const;
 
   /**
-   * Reset both dirty flag and updated flag.
-   * @note This is called after rendering has completed.
+   * @brief Reset to base values of all animatable properties.
+   *
+   * @param[in] updateBufferIndex the current buffer index
    */
-  void ResetDirtyFlag();
+  void ResetToBaseValues(BufferIndex updateBufferIndex);
+
+  /**
+   * @brief Mark all animatable properties as dirty.
+   */
+  void MarkAsDirty();
 
   /**
    * Get the capacity of the memory pools
@@ -582,6 +517,11 @@ public: // PropertyOwner implementation
    */
   virtual void ResetDefaultProperties(BufferIndex updateBufferIndex){};
 
+  /**
+   * @copydoc Dali::Internal::SceneGraph::PropertyOwner::AddInitializeResetter
+   */
+  void AddInitializeResetter(ResetterManager& manager) const override;
+
 public: // From UniformMapDataProvider
   /**
    * @copydoc UniformMapDataProvider::GetCollectedUniformMap
@@ -633,9 +573,9 @@ private:
 
   Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
 
-  uint64_t             mUniformsHash{0};             ///< Hash of uniform map property values
   uint32_t             mIndexedDrawFirstElement;     ///< first element index to be drawn using indexed draw
   uint32_t             mIndexedDrawElementsCount;    ///< number of elements to be drawn using indexed draw
+  uint32_t             mInstanceCount{0};            ///< The number of instances to be drawn
   uint32_t             mBlendBitmask;                ///< The bitmask of blending options
   uint32_t             mResendFlag;                  ///< Indicate whether data should be resent to the renderer
   UniformMap::SizeType mUniformMapChangeCounter{0u}; ///< Value to check if uniform data should be updated
@@ -651,7 +591,6 @@ private:
 
   bool mRegenerateUniformMap : 1;     ///< true if the map should be regenerated
   bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
-  bool mDirtyFlag : 1;                ///< Flag indicating whether the properties are changed
 
   std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands;
   Dali::RenderCallback*                         mRenderCallback{nullptr};