[dali_2.3.27] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / scene-graph-layer.h
index ca9a0e0..5f2c70a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_LAYER_H
 
 /*
- * Copyright (c) 2021 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.
@@ -48,22 +48,35 @@ class Camera;
  */
 struct Renderable
 {
-  Renderable()
-  : mNode(nullptr),
-    mRenderer(nullptr)
-  {
-  }
+  Renderable() = default;
 
-  Renderable(Node* node, Renderer* renderer)
+  Renderable(Node* node, RendererKey renderer)
   : mNode(node),
     mRenderer(renderer)
   {
   }
 
-  Node*     mNode;
-  Renderer* mRenderer;
+  Node*       mNode{nullptr};
+  RendererKey mRenderer{};
+};
+
+} // namespace SceneGraph
+} // Namespace Internal
+
+/// Enable Renderable to be used as a trivial type in Dali::Vector.
+template<>
+struct TypeTraits<Internal::SceneGraph::Renderable> : public Dali::BasicTypes<Internal::SceneGraph::Renderable>
+{
+  enum
+  {
+    IS_TRIVIAL_TYPE = true
+  };
 };
 
+namespace Internal
+{
+namespace SceneGraph
+{
 using RenderableContainer = Dali::Vector<Renderable>;
 
 /**
@@ -175,7 +188,7 @@ public:
   /**
    * Enables the reuse of the model view matrices of all renderers for this layer
    * @param[in] updateBufferIndex The current update buffer index.
-   * @param value to set
+   * @param[in] value to set
    */
   void SetReuseRenderers(BufferIndex updateBufferIndex, bool value)
   {
@@ -183,6 +196,16 @@ public:
   }
 
   /**
+   * Get the reuse of the model view matrices of all renderers for this layer is enabled.
+   * @param[in] updateBufferIndex The current update buffer index.
+   * @return Whether all child transform was clean or not.
+   */
+  bool GetReuseRenderers(BufferIndex updateBufferIndex) const
+  {
+    return mAllChildTransformsClean[updateBufferIndex];
+  }
+
+  /**
    * Checks if it is ok to reuse renderers. Renderers can be reused if ModelView transform for all the renderers
    * has not changed from previous use.
    * @param[in] camera A pointer to the camera that we want to use to render the list.
@@ -190,7 +213,7 @@ public:
    * to use is the same than the one used before ( Otherwise View transform will be different )
    *
    */
-  bool CanReuseRenderers(Camera* camera)
+  bool CanReuseRenderers(const Camera* camera)
   {
     bool bReturn(mAllChildTransformsClean[0] && mAllChildTransformsClean[1] && camera == mLastCamera);
     mLastCamera = camera;
@@ -218,11 +241,11 @@ private:
    */
   Layer();
 
-  // Undefined
-  Layer(const Layer&);
-
-  // Undefined
-  Layer& operator=(const Layer& rhs);
+  // Delete copy and move
+  Layer(const Layer&) = delete;
+  Layer(Layer&&)      = delete;
+  Layer& operator=(const Layer& rhs) = delete;
+  Layer& operator=(Layer&& rhs) = delete;
 
 public: // For update-algorithms
   RenderableContainer colorRenderables;
@@ -231,8 +254,8 @@ public: // For update-algorithms
 private:
   SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
 
-  ClippingBox mClippingBox; ///< The clipping box, in window coordinates
-  Camera*     mLastCamera;  ///< Pointer to the last camera that has rendered the layer
+  ClippingBox   mClippingBox; ///< The clipping box, in window coordinates
+  const Camera* mLastCamera;  ///< Pointer to the last camera that has rendered the layer
 
   Dali::Layer::Behavior mBehavior; ///< The behavior of the layer