1 #ifndef DALI_RENDERER_H
2 #define DALI_RENDERER_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/handle.h> // Dali::Handle
23 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_OBJECT_PROPERTY_START_INDEX
24 #include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
25 #include <dali/devel-api/rendering/texture-set.h> // Dali::TextureSet
30 namespace Internal DALI_INTERNAL
35 namespace FaceCullingMode
39 * @brief Set face culling mode.
44 NONE, ///< None of the faces should be culled
45 FRONT, ///< Cull front face, back face should never be shown
46 BACK, ///< Cull back face, back face should never be shown
47 FRONT_AND_BACK, ///< Cull front and back faces; if the geometry is composed of triangles none of the faces will be shown
50 } // namespace FaceCullingMode
61 OFF, ///< Blending is disabled. @SINCE_1_1.33
62 AUTO, ///< Blending is enabled if there is alpha channel. This is the default mode. @SINCE_1_1.33
63 ON ///< Blending is enabled. @SINCE_1_1.33
66 } // namespace BlendMode
68 namespace BlendEquation
71 * @brief Blend Equation.
74 * @remarks This is an experimental feature and might not be supported in the next release.
75 * We do recommend not to use it.
79 ADD = 0x8006, ///< The source and destination colors are added to each other. @SINCE_1_0.0
80 SUBTRACT = 0x800A, ///< Subtracts the destination from the source. @SINCE_1_0.0
81 REVERSE_SUBTRACT = 0x800B ///< Subtracts the source from the destination. @SINCE_1_0.0
84 } // namespace BlendEquation
89 * @brief Blend Factor.
92 * @remarks This is an experimental feature and might not be supported in the next release.
93 * We do recommend not to use it.
97 ZERO = 0, ///< ZERO @SINCE_1_0.0
98 ONE = 1, ///< ONE @SINCE_1_0.0
99 SRC_COLOR = 0x0300, ///< SRC_COLOR @SINCE_1_0.0
100 ONE_MINUS_SRC_COLOR = 0x0301, ///< ONE_MINUS_SRC_COLOR @SINCE_1_0.0
101 SRC_ALPHA = 0x0302, ///< SRC_ALPHA @SINCE_1_0.0
102 ONE_MINUS_SRC_ALPHA = 0x0303, ///< ONE_MINUS_SRC_ALPHA @SINCE_1_0.0
103 DST_ALPHA = 0x0304, ///< DST_ALPHA @SINCE_1_0.0
104 ONE_MINUS_DST_ALPHA = 0x0305, ///< ONE_MINUS_DST_ALPHA @SINCE_1_0.0
105 DST_COLOR = 0x0306, ///< DST_COLOR @SINCE_1_0.0
106 ONE_MINUS_DST_COLOR = 0x0307, ///< ONE_MINUS_DST_COLOR @SINCE_1_0.0
107 SRC_ALPHA_SATURATE = 0x0308, ///< SRC_ALPHA_SATURATE @SINCE_1_0.0
108 CONSTANT_COLOR = 0x8001, ///< CONSTANT_COLOR @SINCE_1_0.0
109 ONE_MINUS_CONSTANT_COLOR = 0x8002, ///< ONE_MINUS_CONSTANT_COLOR @SINCE_1_0.0
110 CONSTANT_ALPHA = 0x8003, ///< CONSTANT_ALPHA @SINCE_1_0.0
111 ONE_MINUS_CONSTANT_ALPHA = 0x8004 ///< ONE_MINUS_CONSTANT_ALPHA @SINCE_1_0.0
114 } // namespace BlendFactor
116 namespace DepthWriteMode
120 * @brief Depth buffer write modes
124 OFF, ///< Renderer doesn't write to the depth buffer
125 AUTO, ///< Renderer only writes to the depth buffer if it's opaque
126 ON ///< Renderer writes to the depth buffer
129 } // namespace DepthWriteMode
131 namespace DepthTestMode
135 * @brief Depth buffer test (reading) modes.
139 OFF, ///< Renderer does not read from the depth buffer @SINCE_1_1.38
140 AUTO, ///< Renderer only reads from the depth buffer if in a 3D layer @SINCE_1_1.38
141 ON ///< Renderer reads from the depth buffer based on the DepthFunction @SINCE_1_1.38
144 } // namespace DepthTestMode
146 namespace DepthFunction
150 * @brief Depth functions
154 NEVER, ///< Depth test never passes
155 ALWAYS, ///< Depth test always passes
156 LESS, ///< Depth test passes if the incoming depth value is less than the stored depth value
157 GREATER, ///< Depth test passes if the incoming depth value is greater than the stored depth value
158 EQUAL, ///< Depth test passes if the incoming depth value is equal to the stored depth value
159 NOT_EQUAL, ///< Depth test passes if the incoming depth value is not equal to the stored depth value
160 LESS_EQUAL, ///< Depth test passes if the incoming depth value is less than or equal to the stored depth value
161 GREATER_EQUAL ///< Depth test passes if the incoming depth value is greater than or equal to the stored depth value
164 } // namespace DepthFunction
167 * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader
169 class DALI_IMPORT_API Renderer : public Handle
174 * @brief An enumeration of properties belonging to the Renderer class.
181 * @brief name "depthIndex", type INTEGER
182 * @note The default value is 0
184 DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX,
187 * @brief name "faceCullingMode", type INTEGER
188 * @note The default value is FaceCullingMode::NONE
193 * @brief name "blendMode", type INTEGER
194 * @note The default value is BlendMode::AUTO
199 * @brief name "blendEquationRgb", type INTEGER
200 * @note The default value is BlendEquation::ADD
205 * @brief name "blendEquationAlpha", type INTEGER
206 * @note The default value is BlendEquation::ADD
208 BLEND_EQUATION_ALPHA,
211 * @brief name "blendFactorSrcRgb", type INTEGER
212 * @note The default value is BlendFactor::SRC_ALPHA
214 BLEND_FACTOR_SRC_RGB,
217 * @brief name "blendFactorDestRgb", type INTEGER
218 * @note The default value is BlendFactor::ONE_MINUS_SRC_ALPHA
220 BLEND_FACTOR_DEST_RGB,
223 * @brief name "blendFactorSrcAlpha", type INTEGER
224 * @note The default value is BlendFactor::ONE
226 BLEND_FACTOR_SRC_ALPHA,
229 * @brief name "blendFactorDestAlpha", type INTEGER
230 * @note The default value is BlendFactor::ONE_MINUS_SRC_ALPHA
232 BLEND_FACTOR_DEST_ALPHA,
235 * @brief name "blendColor", type VECTOR4
236 * @note The default value is Color::TRANSPARENT
241 * @brief name "blendPreMultipledAlpha", type BOOLEAN
242 * @note The default value is false
244 BLEND_PRE_MULTIPLIED_ALPHA,
247 * @brief name "indexRangeFirst", type INTEGER
248 * @note The default value is 0
253 * @brief name "indexRangeCount", type INTEGER
254 * @note The default (0) means that whole range of indices will be used
259 * @brief name "depthWriteMode", type INTEGER
260 * @see DepthWriteMode
261 * @note The default value is DepthWriteMode::AUTO
266 * @brief name "depthFunction", type INTEGER
268 * @note The default value is DepthFunction::LESS
273 * @brief name "depthTestMode", type INTEGER
275 * @note The default value is DepthTestMode::AUTO
283 * @brief Creates a new Renderer object
285 * @param[in] geometry Geometry to be used by this renderer
286 * @param[in] shader Shader to be used by this renderer
288 static Renderer New( Geometry& geometry, Shader& shader );
291 * @brief Default constructor, creates an empty handle
301 * @brief Copy constructor, creates a new handle to the same object
303 * @param[in] handle Handle to an object
305 Renderer( const Renderer& handle );
308 * @brief Downcast to a renderer handle.
310 * If not a renderer the returned renderer handle is left uninitialized.
311 * @param[in] handle to an object
312 * @return renderer handle or an uninitialized handle
314 static Renderer DownCast( BaseHandle handle );
317 * @brief Assignment operator, changes this handle to point at the same object
319 * @param[in] handle Handle to an object
320 * @return Reference to the assigned object
322 Renderer& operator=( const Renderer& handle );
325 * @brief Sets the geometry to be used by this renderer
327 * @param[in] geometry The geometry to be used by this renderer
329 void SetGeometry( Geometry& geometry );
332 * @brief Gets the geometry used by this renderer
334 * @return The geometry used by the renderer
336 Geometry GetGeometry() const;
339 * @brief Sets effective range of indices to draw from bound index buffer
340 * @param [in] firstElement first element to draw
341 * @param [in] elementsCount number of elements to draw
343 inline void SetIndexRange( int firstElement, int elementsCount )
345 SetProperty( Property::INDEX_RANGE_FIRST, firstElement );
346 SetProperty( Property::INDEX_RANGE_COUNT, elementsCount );
350 * @brief Sets the texture set to be used by this renderer
352 * @param[in] textureSet The texture set to be used by this renderer
354 void SetTextures( TextureSet& textureSet );
357 * @brief Gets the texture set used by this renderer
359 * @return The texture set used by the renderer
361 TextureSet GetTextures() const;
364 * @brief Set the shader used by this renderer
365 * @param[in] shader The shader to be used by this renderer
367 void SetShader( Shader& shader );
370 * @brief Get the shader used by this renderer
371 * @return THe shader used by the renderer
373 Shader GetShader() const;
377 * @brief The constructor
379 * @param [in] pointer A pointer to a newly allocated Renderer
381 explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
386 #endif // DALI_RENDERER_H