Fix Rendering order issue when 3D layer render translucent
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-instruction-processor.h
index 3e2b524..abaa466 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
 // INTERNAL INCLUDES
 #include <dali/internal/common/buffer-index.h>
 #include <dali/internal/update/manager/sorted-layers.h>
-#include <dali/integration-api/resource-declarations.h>
 #include <dali/public-api/common/dali-vector.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace Render
 {
 class Geometry;
@@ -37,7 +34,6 @@ class Geometry;
 
 namespace SceneGraph
 {
-
 class RenderTracker;
 struct RenderItem;
 class Shader;
@@ -45,14 +41,12 @@ struct RenderList;
 class RenderTask;
 class RenderInstructionContainer;
 
-
 /**
  * @brief This class handles the sorting and preparation of Renderers for each layer.
  */
 class RenderInstructionProcessor
 {
 public:
-
   /**
    * @brief Constructor.
    */
@@ -70,28 +64,27 @@ public:
   struct SortAttributes
   {
     SortAttributes()
-    : renderItem( NULL ),
-      shader( NULL ),
-      textureSet( NULL ),
-      geometry( NULL ),
-      zValue( 0.0f )
+    : renderItem(nullptr),
+      shader(nullptr),
+      textureSet(nullptr),
+      geometry(nullptr),
+      zValue(0.0f)
     {
     }
 
-    RenderItem*             renderItem;        ///< The render item that is being sorted (includes depth index)
-    const Shader*           shader;            ///< The shader instance
-    const void*             textureSet;        ///< The textureSet instance
-    const Render::Geometry* geometry;          ///< The geometry instance
-    float                   zValue;            ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
+    RenderItem*             renderItem; ///< The render item that is being sorted (includes depth index)
+    const Shader*           shader;     ///< The shader instance
+    const void*             textureSet; ///< The textureSet instance
+    const Render::Geometry* geometry;   ///< The geometry instance
+    float                   zValue;     ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
   };
 
-
   /**
    * @brief Sorts and prepares the list of opaque/transparent Renderers for each layer.
    * Whilst iterating through each layer, update the RenderItems ModelView matrices
    *
    * The opaque and transparent render lists are sorted first by depth
-   * index, then by Z (for transparent only), then by shader, texture
+   * index, then by Z (for transparent only), then by shader
    * and geometry. The render algorithm should then work through both
    * lists simultaneously, working through opaque then transparent
    * items at each depth index, resetting the flags appropriately.
@@ -103,42 +96,40 @@ public:
    * @param[in]  hasClippingNodes  Whether any clipping nodes exist within this layer, to optimize sorting if not
    * @param[out] instructions      The rendering instructions for the next frame.
    */
-  void Prepare( BufferIndex updateBufferIndex,
-                SortedLayerPointers& sortedLayers,
-                RenderTask& renderTask,
-                bool cull,
-                bool hasClippingNodes,
-                RenderInstructionContainer& instructions );
+  void Prepare(BufferIndex                 updateBufferIndex,
+               SortedLayerPointers&        sortedLayers,
+               RenderTask&                 renderTask,
+               bool                        cull,
+               bool                        hasClippingNodes,
+               RenderInstructionContainer& instructions);
 
 private:
-
   /**
    * Undefine copy and assignment operators.
    */
-  RenderInstructionProcessor( const RenderInstructionProcessor& renderInstructionProcessor );             ///< No definition
-  RenderInstructionProcessor& operator=( const RenderInstructionProcessor& renderInstructionProcessor );  ///< No definition
+  RenderInstructionProcessor(const RenderInstructionProcessor& renderInstructionProcessor);            ///< No definition
+  RenderInstructionProcessor& operator=(const RenderInstructionProcessor& renderInstructionProcessor); ///< No definition
 
 private:
-
   /**
    * @brief Sort render items
    * @param bufferIndex The buffer to read from
    * @param renderList to sort
    * @param layer where the Renderers are from
    * @param respectClippingOrder Sort with the correct clipping hierarchy.
+   * @param isOrthographicCamera Whether the camera is orthographic or not.
    */
-  inline void SortRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder );
+  inline void SortRenderItems(BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder, bool isOrthographicCamera);
 
   /// Sort comparitor function pointer type.
-  typedef bool ( *ComparitorPointer )( const SortAttributes& lhs, const SortAttributes& rhs );
-  typedef std::vector< SortAttributes > SortingHelper;
+  using ComparitorPointer = bool (*)(const SortAttributes&, const SortAttributes&);
 
-  Dali::Vector< ComparitorPointer > mSortComparitors;       ///< Contains all sort comparitors, used for quick look-up
-  RenderInstructionProcessor::SortingHelper mSortingHelper; ///< Helper used to sort Renderers
+  using SortingHelper = std::vector<SortAttributes>;
 
+  Dali::Vector<ComparitorPointer>           mSortComparitors; ///< Contains all sort comparitors, used for quick look-up
+  RenderInstructionProcessor::SortingHelper mSortingHelper;   ///< Helper used to sort Renderers
 };
 
-
 } // namespace SceneGraph
 
 } // namespace Internal