Merge "Clean up the code to build successfully on macOS" into 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) 2020 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
27 namespace DevelBlendEquation
28 {
29
30 /**
31  * @brief Enumeration for blend equation.
32  */
33 enum Type
34 {
35   ADD                           = Dali::BlendEquation::ADD,
36   SUBTRACT                      = Dali::BlendEquation::SUBTRACT,
37   REVERSE_SUBTRACT              = Dali::BlendEquation::REVERSE_SUBTRACT,
38
39   // OpenGL es 3.0 enumeration
40   MIN                           = 0x8007,
41   MAX                           = 0x8008,
42
43   // OpenGL es 3.2 or KHR_Blend_Equation_Advanced enumeration
44   MULTIPLY                      = 0x9294,
45   SCREEN                        = 0x9295,
46   OVERLAY                       = 0x9296,
47   DARKEN                        = 0x9297,
48   LIGHTEN                       = 0x9298,
49   COLOR_DODGE                   = 0x9299,
50   COLOR_BURN                    = 0x929A,
51   HARD_LIGHT                    = 0x929B,
52   SOFT_LIGHT                    = 0x929C,
53   DIFFERENCE                    = 0x929E,
54   EXCLUSION                     = 0x92A0,
55   HUE                           = 0x92AD,
56   SATURATION                    = 0x92AE,
57   COLOR                         = 0x92AF,
58   LUMINOSITY                    = 0x92B0
59 };
60
61 } // namespace DevelBlendEquation
62
63 namespace DevelRenderer
64 {
65 /**
66  * The index of render queue used by the DrawCommand
67  */
68 using RenderQueueIndex = uint32_t;
69
70 constexpr RenderQueueIndex RENDER_QUEUE_OPAQUE      = 0; ///< Queue for opaque elements
71 constexpr RenderQueueIndex RENDER_QUEUE_TRANSPARENT = 1; ///<Queue for transparent elements
72 constexpr RenderQueueIndex RENDER_QUEUE_MAX         = 2;
73
74 /**
75  * Enum describing way of rendering the primitives (indexed draw, array draw)
76  */
77 enum class DrawType
78 {
79   INDEXED,
80   ARRAY,
81 };
82
83 /**
84  * Draw command can be attached to the Dali::Renderer and override the default
85  * rendering functionality. Renderer may have several DrawCommands attached to it
86  * and the will be executed sequentially in the order of the 'queue' index.
87  */
88 struct DrawCommand
89 {
90   DrawType         drawType;     ///< Type of drawing (indexed, array)
91   uint32_t         firstIndex;   ///< First index into the geometry array
92   uint32_t         elementCount; ///< Number of elements to draw
93   RenderQueueIndex queue;        ///< Queue index
94 };
95
96 /**
97  * @brief Adds a draw command to the renderer
98  * Once the draw command is added, the default Renderer's behaviour is overriden.
99  * @param[in] renderer a valid Renderer object
100  * @param[in] drawCommand Valid DrawCommand to add to the Renderer
101  */
102 DALI_CORE_API void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand);
103
104 namespace Property
105 {
106 enum Type
107 {
108   DEPTH_INDEX                 = Dali::Renderer::Property::DEPTH_INDEX,
109   FACE_CULLING_MODE           = Dali::Renderer::Property::FACE_CULLING_MODE,
110   BLEND_MODE                  = Dali::Renderer::Property::BLEND_MODE,
111   BLEND_EQUATION_RGB          = Dali::Renderer::Property::BLEND_EQUATION_RGB,
112   BLEND_EQUATION_ALPHA        = Dali::Renderer::Property::BLEND_EQUATION_ALPHA,
113   BLEND_FACTOR_SRC_RGB        = Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB,
114   BLEND_FACTOR_DEST_RGB       = Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB,
115   BLEND_FACTOR_SRC_ALPHA      = Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA,
116   BLEND_FACTOR_DEST_ALPHA     = Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA,
117   BLEND_COLOR                 = Dali::Renderer::Property::BLEND_COLOR,
118   BLEND_PRE_MULTIPLIED_ALPHA  = Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA,
119   INDEX_RANGE_FIRST           = Dali::Renderer::Property::INDEX_RANGE_FIRST,
120   INDEX_RANGE_COUNT           = Dali::Renderer::Property::INDEX_RANGE_COUNT,
121   DEPTH_WRITE_MODE            = Dali::Renderer::Property::DEPTH_WRITE_MODE,
122   DEPTH_FUNCTION              = Dali::Renderer::Property::DEPTH_FUNCTION,
123   DEPTH_TEST_MODE             = Dali::Renderer::Property::DEPTH_TEST_MODE,
124   RENDER_MODE                 = Dali::Renderer::Property::RENDER_MODE,
125   STENCIL_FUNCTION            = Dali::Renderer::Property::STENCIL_FUNCTION,
126   STENCIL_FUNCTION_MASK       = Dali::Renderer::Property::STENCIL_FUNCTION_MASK,
127   STENCIL_FUNCTION_REFERENCE  = Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE,
128   STENCIL_MASK                = Dali::Renderer::Property::STENCIL_MASK,
129   STENCIL_OPERATION_ON_FAIL   = Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL,
130   STENCIL_OPERATION_ON_Z_FAIL = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL,
131   STENCIL_OPERATION_ON_Z_PASS = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS,
132
133   /**
134      * @brief The opacity of the renderer.
135      * @details Name "opacity", type Property::FLOAT.
136      */
137   OPACITY = STENCIL_OPERATION_ON_Z_PASS + 1,
138
139   /**
140      * @brief The rendering behavior of the renderer.
141      * @details Name "renderingBehavior", type Property::INTEGER.
142      */
143   RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2,
144
145   /**
146    * @brief name "blendEquation", type INTEGER
147    * @note The default value is BlendEquation::ADD
148    */
149   BLEND_EQUATION,
150 };
151 } // namespace Property
152
153 namespace Rendering
154 {
155 /**
156  * @brief Enumeration for the rendering behavior
157  */
158 enum Type
159 {
160   IF_REQUIRED, ///< Default. Will only render if required to do so.
161   CONTINUOUSLY ///< Will render continuously.
162 };
163
164 } // namespace Rendering
165
166
167 /**
168  * @brief Query whether current blend equation is advanced option.
169  * @param[in] renderer to be checked whether it has been applied advanced blend equation or not
170  * @return True if current blend equation is advanced.
171  */
172 DALI_CORE_API bool IsAdvancedBlendEquationApplied( const Renderer& renderer );
173
174 } // namespace DevelRenderer
175
176 } // namespace Dali
177
178 #endif // DALI_RENDERER_DEVEL_H