[dali_2.3.40] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / devel-api / rendering / renderer-devel.h
1 #ifndef DALI_RENDERER_DEVEL_H
2 #define DALI_RENDERER_DEVEL_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/rendering/renderer.h>
23
24 namespace Dali
25 {
26 namespace DevelBlendEquation
27 {
28 /**
29  * @brief Enumeration for blend equation.
30  */
31 enum Type
32 {
33   ADD              = Dali::BlendEquation::ADD,
34   SUBTRACT         = Dali::BlendEquation::SUBTRACT,
35   REVERSE_SUBTRACT = Dali::BlendEquation::REVERSE_SUBTRACT,
36
37   // OpenGL es 3.0 enumeration
38   MIN = 0x8007,
39   MAX = 0x8008,
40
41   // OpenGL es 3.2 or KHR_Blend_Equation_Advanced enumeration
42   MULTIPLY    = 0x9294,
43   SCREEN      = 0x9295,
44   OVERLAY     = 0x9296,
45   DARKEN      = 0x9297,
46   LIGHTEN     = 0x9298,
47   COLOR_DODGE = 0x9299,
48   COLOR_BURN  = 0x929A,
49   HARD_LIGHT  = 0x929B,
50   SOFT_LIGHT  = 0x929C,
51   DIFFERENCE  = 0x929E,
52   EXCLUSION   = 0x92A0,
53   HUE         = 0x92AD,
54   SATURATION  = 0x92AE,
55   COLOR       = 0x92AF,
56   LUMINOSITY  = 0x92B0
57 };
58
59 } // namespace DevelBlendEquation
60
61 namespace DevelRenderer
62 {
63 /**
64  * The index of render queue used by the DrawCommand
65  */
66 using RenderQueueIndex = uint32_t;
67
68 constexpr RenderQueueIndex RENDER_QUEUE_OPAQUE      = 0; ///< Queue for opaque elements
69 constexpr RenderQueueIndex RENDER_QUEUE_TRANSPARENT = 1; ///<Queue for transparent elements
70 constexpr RenderQueueIndex RENDER_QUEUE_MAX         = 2;
71
72 /**
73  * Enum describing way of rendering the primitives (indexed draw, array draw)
74  */
75 enum class DrawType
76 {
77   INDEXED,
78   ARRAY,
79 };
80
81 /**
82  * Draw command can be attached to the Dali::Renderer and override the default
83  * rendering functionality. Renderer may have several DrawCommands attached to it
84  * and the will be executed sequentially in the order of the 'queue' index.
85  */
86 struct DrawCommand
87 {
88   DrawType         drawType;     ///< Type of drawing (indexed, array)
89   uint32_t         firstIndex;   ///< First index into the geometry array
90   uint32_t         elementCount; ///< Number of elements to draw
91   RenderQueueIndex queue;        ///< Queue index
92 };
93
94 /**
95  * @brief Adds a draw command to the renderer
96  * Once the draw command is added, the default Renderer's behaviour is overriden.
97  * @param[in] renderer a valid Renderer object
98  * @param[in] drawCommand Valid DrawCommand to add to the Renderer
99  */
100 DALI_CORE_API void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand);
101
102 namespace Property
103 {
104 enum Type
105 {
106   DEPTH_INDEX                 = Dali::Renderer::Property::DEPTH_INDEX,
107   FACE_CULLING_MODE           = Dali::Renderer::Property::FACE_CULLING_MODE,
108   BLEND_MODE                  = Dali::Renderer::Property::BLEND_MODE,
109   BLEND_EQUATION_RGB          = Dali::Renderer::Property::BLEND_EQUATION_RGB,
110   BLEND_EQUATION_ALPHA        = Dali::Renderer::Property::BLEND_EQUATION_ALPHA,
111   BLEND_FACTOR_SRC_RGB        = Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB,
112   BLEND_FACTOR_DEST_RGB       = Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB,
113   BLEND_FACTOR_SRC_ALPHA      = Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA,
114   BLEND_FACTOR_DEST_ALPHA     = Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA,
115   BLEND_COLOR                 = Dali::Renderer::Property::BLEND_COLOR,
116   BLEND_PRE_MULTIPLIED_ALPHA  = Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA,
117   INDEX_RANGE_FIRST           = Dali::Renderer::Property::INDEX_RANGE_FIRST,
118   INDEX_RANGE_COUNT           = Dali::Renderer::Property::INDEX_RANGE_COUNT,
119   DEPTH_WRITE_MODE            = Dali::Renderer::Property::DEPTH_WRITE_MODE,
120   DEPTH_FUNCTION              = Dali::Renderer::Property::DEPTH_FUNCTION,
121   DEPTH_TEST_MODE             = Dali::Renderer::Property::DEPTH_TEST_MODE,
122   RENDER_MODE                 = Dali::Renderer::Property::RENDER_MODE,
123   STENCIL_FUNCTION            = Dali::Renderer::Property::STENCIL_FUNCTION,
124   STENCIL_FUNCTION_MASK       = Dali::Renderer::Property::STENCIL_FUNCTION_MASK,
125   STENCIL_FUNCTION_REFERENCE  = Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE,
126   STENCIL_MASK                = Dali::Renderer::Property::STENCIL_MASK,
127   STENCIL_OPERATION_ON_FAIL   = Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL,
128   STENCIL_OPERATION_ON_Z_FAIL = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL,
129   STENCIL_OPERATION_ON_Z_PASS = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS,
130
131   /**
132    * @brief The opacity of the renderer.
133    * @details Name "opacity", type Property::FLOAT.
134    */
135   OPACITY = STENCIL_OPERATION_ON_Z_PASS + 1,
136
137   /**
138    * @brief The rendering behavior of the renderer.
139    * @details Name "renderingBehavior", type Property::INTEGER.
140    */
141   RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2,
142
143   /**
144    * @brief name "blendEquation", type INTEGER
145    * @note The default value is BlendEquation::ADD
146    */
147   BLEND_EQUATION = STENCIL_OPERATION_ON_Z_PASS + 3,
148
149   /**
150    * @brief Which vertex to render first from a vertex buffer without indices
151    * @details name "vertexRangeFirst", type INTEGER
152    */
153   VERTEX_RANGE_FIRST = INDEX_RANGE_FIRST,
154
155   /**
156    * @brief How many vertices to render to render from a vertex buffer without indices
157    * @details name "vertexRangeCount", type INTEGER
158    */
159   VERTEX_RANGE_COUNT = INDEX_RANGE_COUNT,
160
161   /**
162    * @brief How many instances to render from a vertex buffer with non-zero divisor.
163    * @note Overrides computed instance count on vertex buffer.
164    * @details name "instanceCount", type INTEGER
165    */
166   INSTANCE_COUNT = STENCIL_OPERATION_ON_Z_PASS + 4,
167 };
168 } // namespace Property
169
170 namespace Rendering
171 {
172 /**
173  * @brief Enumeration for the rendering behavior
174  */
175 enum Type
176 {
177   IF_REQUIRED, ///< Default. Will only render if required to do so.
178   CONTINUOUSLY ///< Will render continuously.
179 };
180
181 } // namespace Rendering
182
183 /**
184  * @brief Query whether current blend equation is advanced option.
185  * @param[in] renderer to be checked whether it has been applied advanced blend equation or not
186  * @return True if current blend equation is advanced.
187  */
188 DALI_CORE_API bool IsAdvancedBlendEquationApplied(const Renderer& renderer);
189
190 } // namespace DevelRenderer
191
192 } // namespace Dali
193
194 #endif // DALI_RENDERER_DEVEL_H