Clean up the code to build successfully on macOS
[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 namespace DevelRenderer
27 {
28 /**
29  * The index of render queue used by the DrawCommand
30  */
31 using RenderQueueIndex = uint32_t;
32
33 constexpr RenderQueueIndex RENDER_QUEUE_OPAQUE      = 0; ///< Queue for opaque elements
34 constexpr RenderQueueIndex RENDER_QUEUE_TRANSPARENT = 1; ///<Queue for transparent elements
35 constexpr RenderQueueIndex RENDER_QUEUE_MAX         = 2;
36
37 /**
38  * Enum describing way of rendering the primitives (indexed draw, array draw)
39  */
40 enum class DrawType
41 {
42   INDEXED,
43   ARRAY,
44 };
45
46 /**
47  * Draw command can be attached to the Dali::Renderer and override the default
48  * rendering functionality. Renderer may have several DrawCommands attached to it
49  * and the will be executed sequentially in the order of the 'queue' index.
50  */
51 struct DrawCommand
52 {
53   DrawType         drawType;     ///< Type of drawing (indexed, array)
54   uint32_t         firstIndex;   ///< First index into the geometry array
55   uint32_t         elementCount; ///< Number of elements to draw
56   RenderQueueIndex queue;        ///< Queue index
57 };
58
59 /**
60  * @brief Adds a draw command to the renderer
61  * Once the draw command is added, the default Renderer's behaviour is overriden.
62  * @param[in] renderer a valid Renderer object
63  * @param[in] drawCommand Valid DrawCommand to add to the Renderer
64  */
65 DALI_CORE_API void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand);
66
67 namespace Property
68 {
69 enum Type
70 {
71   DEPTH_INDEX                 = Dali::Renderer::Property::DEPTH_INDEX,
72   FACE_CULLING_MODE           = Dali::Renderer::Property::FACE_CULLING_MODE,
73   BLEND_MODE                  = Dali::Renderer::Property::BLEND_MODE,
74   BLEND_EQUATION_RGB          = Dali::Renderer::Property::BLEND_EQUATION_RGB,
75   BLEND_EQUATION_ALPHA        = Dali::Renderer::Property::BLEND_EQUATION_ALPHA,
76   BLEND_FACTOR_SRC_RGB        = Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB,
77   BLEND_FACTOR_DEST_RGB       = Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB,
78   BLEND_FACTOR_SRC_ALPHA      = Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA,
79   BLEND_FACTOR_DEST_ALPHA     = Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA,
80   BLEND_COLOR                 = Dali::Renderer::Property::BLEND_COLOR,
81   BLEND_PRE_MULTIPLIED_ALPHA  = Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA,
82   INDEX_RANGE_FIRST           = Dali::Renderer::Property::INDEX_RANGE_FIRST,
83   INDEX_RANGE_COUNT           = Dali::Renderer::Property::INDEX_RANGE_COUNT,
84   DEPTH_WRITE_MODE            = Dali::Renderer::Property::DEPTH_WRITE_MODE,
85   DEPTH_FUNCTION              = Dali::Renderer::Property::DEPTH_FUNCTION,
86   DEPTH_TEST_MODE             = Dali::Renderer::Property::DEPTH_TEST_MODE,
87   RENDER_MODE                 = Dali::Renderer::Property::RENDER_MODE,
88   STENCIL_FUNCTION            = Dali::Renderer::Property::STENCIL_FUNCTION,
89   STENCIL_FUNCTION_MASK       = Dali::Renderer::Property::STENCIL_FUNCTION_MASK,
90   STENCIL_FUNCTION_REFERENCE  = Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE,
91   STENCIL_MASK                = Dali::Renderer::Property::STENCIL_MASK,
92   STENCIL_OPERATION_ON_FAIL   = Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL,
93   STENCIL_OPERATION_ON_Z_FAIL = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL,
94   STENCIL_OPERATION_ON_Z_PASS = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS,
95
96   /**
97      * @brief The opacity of the renderer.
98      * @details Name "opacity", type Property::FLOAT.
99      */
100   OPACITY = STENCIL_OPERATION_ON_Z_PASS + 1,
101
102   /**
103      * @brief The rendering behavior of the renderer.
104      * @details Name "renderingBehavior", type Property::INTEGER.
105      */
106   RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2,
107 };
108 } // namespace Property
109
110 namespace Rendering
111 {
112 /**
113  * @brief Enumeration for the rendering behavior
114  */
115 enum Type
116 {
117   IF_REQUIRED, ///< Default. Will only render if required to do so.
118   CONTINUOUSLY ///< Will render continuously.
119 };
120
121 } // namespace Rendering
122
123 } // namespace DevelRenderer
124
125 } // namespace Dali
126
127 #endif // DALI_RENDERER_DEVEL_H