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_RENDERER_PROPERTY_START_INDEX
24 #include <dali/public-api/rendering/geometry.h> // Dali::Geometry
25 #include <dali/public-api/rendering/texture-set.h> // Dali::TextureSet
30 namespace Internal DALI_INTERNAL
35 namespace FaceCullingMode
39 * @brief Face culling mode.
44 NONE, ///< None of the faces should be culled @SINCE_1_1.43
45 FRONT, ///< Cull front face, front faces should never be shown @SINCE_1_1.43
46 BACK, ///< Cull back face, back faces should never be shown @SINCE_1_1.43
47 FRONT_AND_BACK, ///< Cull front and back faces; if the geometry is composed of triangles none of the faces will be shown @SINCE_1_1.43
50 } // namespace FaceCullingMode
61 OFF, ///< Blending is disabled. @SINCE_1_1.43
62 AUTO, ///< Blending is enabled if there is alpha channel. This is the default mode. @SINCE_1_1.43
63 ON ///< Blending is enabled. @SINCE_1_1.43
66 } // namespace BlendMode
68 namespace BlendEquation
72 * @brief Blend Equation.
77 ADD = 0x8006, ///< The source and destination colors are added to each other. @SINCE_1_1.43
78 SUBTRACT = 0x800A, ///< Subtracts the destination from the source. @SINCE_1_1.43
79 REVERSE_SUBTRACT = 0x800B ///< Subtracts the source from the destination. @SINCE_1_1.43
82 } // namespace BlendEquation
88 * @brief Blend Factor.
93 ZERO = 0, ///< ZERO @SINCE_1_1.43
94 ONE = 1, ///< ONE @SINCE_1_1.43
95 SRC_COLOR = 0x0300, ///< SRC_COLOR @SINCE_1_1.43
96 ONE_MINUS_SRC_COLOR = 0x0301, ///< ONE_MINUS_SRC_COLOR @SINCE_1_1.43
97 SRC_ALPHA = 0x0302, ///< SRC_ALPHA @SINCE_1_1.43
98 ONE_MINUS_SRC_ALPHA = 0x0303, ///< ONE_MINUS_SRC_ALPHA @SINCE_1_1.43
99 DST_ALPHA = 0x0304, ///< DST_ALPHA @SINCE_1_1.43
100 ONE_MINUS_DST_ALPHA = 0x0305, ///< ONE_MINUS_DST_ALPHA @SINCE_1_1.43
101 DST_COLOR = 0x0306, ///< DST_COLOR @SINCE_1_1.43
102 ONE_MINUS_DST_COLOR = 0x0307, ///< ONE_MINUS_DST_COLOR @SINCE_1_1.43
103 SRC_ALPHA_SATURATE = 0x0308, ///< SRC_ALPHA_SATURATE @SINCE_1_1.43
104 CONSTANT_COLOR = 0x8001, ///< CONSTANT_COLOR @SINCE_1_1.43
105 ONE_MINUS_CONSTANT_COLOR = 0x8002, ///< ONE_MINUS_CONSTANT_COLOR @SINCE_1_1.43
106 CONSTANT_ALPHA = 0x8003, ///< CONSTANT_ALPHA @SINCE_1_1.43
107 ONE_MINUS_CONSTANT_ALPHA = 0x8004 ///< ONE_MINUS_CONSTANT_ALPHA @SINCE_1_1.43
110 } // namespace BlendFactor
112 namespace DepthWriteMode
116 * @brief Depth buffer write modes.
121 OFF, ///< Renderer doesn't write to the depth buffer @SINCE_1_1.43
122 AUTO, ///< Renderer only writes to the depth buffer if it's opaque @SINCE_1_1.43
123 ON ///< Renderer writes to the depth buffer @SINCE_1_1.43
126 } // namespace DepthWriteMode
128 namespace DepthTestMode
132 * @brief Depth buffer test (read) modes.
137 OFF, ///< Renderer does not read from the depth buffer @SINCE_1_1.43
138 AUTO, ///< Renderer only reads from the depth buffer if in a 3D layer @SINCE_1_1.43
139 ON ///< Renderer reads from the depth buffer based on the DepthFunction @SINCE_1_1.43
142 } // namespace DepthTestMode
144 namespace DepthFunction
148 * @brief Depth functions.
153 NEVER, ///< Depth test never passes @SINCE_1_1.43
154 ALWAYS, ///< Depth test always passes @SINCE_1_1.43
155 LESS, ///< Depth test passes if the incoming depth value is less than the stored depth value @SINCE_1_1.43
156 GREATER, ///< Depth test passes if the incoming depth value is greater than the stored depth value @SINCE_1_1.43
157 EQUAL, ///< Depth test passes if the incoming depth value is equal to the stored depth value @SINCE_1_1.43
158 NOT_EQUAL, ///< Depth test passes if the incoming depth value is not equal to the stored depth value @SINCE_1_1.43
159 LESS_EQUAL, ///< Depth test passes if the incoming depth value is less than or equal to the stored depth value @SINCE_1_1.43
160 GREATER_EQUAL ///< Depth test passes if the incoming depth value is greater than or equal to the stored depth value @SINCE_1_1.43
163 } // namespace DepthFunction
169 * @brief Controls how this renderer uses its stencil properties and writes to the color buffer.
174 NONE, ///< Don’t write to either color or stencil buffer (But will potentially render to depth buffer). @SINCE_1_2_5
175 AUTO, ///< Managed by the Actor Clipping API. This is the default. @SINCE_1_2_5
176 COLOR, ///< Ingore stencil properties. Write to the color buffer. @SINCE_1_2_5
177 STENCIL, ///< Use the stencil properties. Do not write to the color buffer. @SINCE_1_2_5
178 COLOR_STENCIL ///< Use the stencil properties AND Write to the color buffer. @SINCE_1_2_5
181 } // namespace RenderMode
183 namespace StencilFunction
187 * @brief The comparison function used on the stencil buffer.
192 NEVER, ///< Always fails @SINCE_1_1.43
193 LESS, ///< Passes if ( reference & mask ) < ( stencil & mask ) @SINCE_1_1.43
194 EQUAL, ///< Passes if ( reference & mask ) = ( stencil & mask ) @SINCE_1_1.43
195 LESS_EQUAL, ///< Passes if ( reference & mask ) <= ( stencil & mask ) @SINCE_1_1.43
196 GREATER, ///< Passes if ( reference & mask ) > ( stencil & mask ) @SINCE_1_1.43
197 NOT_EQUAL, ///< Passes if ( reference & mask ) != ( stencil & mask ) @SINCE_1_1.43
198 GREATER_EQUAL, ///< Passes if ( reference & mask ) >= ( stencil & mask ) @SINCE_1_1.43
199 ALWAYS, ///< Always passes @SINCE_1_1.43
202 } // namespace StencilFunction
204 namespace StencilOperation
208 * @brief Specifies the action to take when the stencil (or depth) test fails during stencil test.
213 ZERO, ///< Sets the stencil buffer value to 0 @SINCE_1_1.43
214 KEEP, ///< Keeps the current value @SINCE_1_1.43
215 REPLACE, ///< Sets the stencil buffer value to ref, as specified by glStencilFunc @SINCE_1_1.43
216 INCREMENT, ///< Increments the current stencil buffer value. Clamps to the maximum representable unsigned value @SINCE_1_1.43
217 DECREMENT, ///< Decrements the current stencil buffer value. Clamps to 0 @SINCE_1_1.43
218 INVERT, ///< Bitwise inverts the current stencil buffer value @SINCE_1_1.43
219 INCREMENT_WRAP, ///< Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value @SINCE_1_1.43
220 DECREMENT_WRAP ///< Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of zero @SINCE_1_1.43
223 } // namespace StencilOperation
227 * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader
231 class DALI_IMPORT_API Renderer : public Handle
236 * @brief An enumeration of properties belonging to the Renderer class.
242 * @brief An enumeration of properties belonging to the Renderer class.
248 * @brief name "depthIndex", type INTEGER
249 * @note The default value is 0
252 DEPTH_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX,
255 * @brief name "faceCullingMode", type INTEGER
256 * @note The default value is FaceCullingMode::NONE
262 * @brief name "blendMode", type INTEGER
263 * @note The default value is BlendMode::AUTO
269 * @brief name "blendEquationRgb", type INTEGER
270 * @note The default value is BlendEquation::ADD
276 * @brief name "blendEquationAlpha", type INTEGER
277 * @note The default value is BlendEquation::ADD
280 BLEND_EQUATION_ALPHA,
283 * @brief name "blendFactorSrcRgb", type INTEGER
284 * @note The default value is BlendFactor::SRC_ALPHA
287 BLEND_FACTOR_SRC_RGB,
290 * @brief name "blendFactorDestRgb", type INTEGER
291 * @note The default value is BlendFactor::ONE_MINUS_SRC_ALPHA
294 BLEND_FACTOR_DEST_RGB,
297 * @brief name "blendFactorSrcAlpha", type INTEGER
298 * @note The default value is BlendFactor::ONE
301 BLEND_FACTOR_SRC_ALPHA,
304 * @brief name "blendFactorDestAlpha", type INTEGER
305 * @note The default value is BlendFactor::ONE_MINUS_SRC_ALPHA
308 BLEND_FACTOR_DEST_ALPHA,
311 * @brief name "blendColor", type VECTOR4
312 * @note The default value is Color::TRANSPARENT
318 * @brief name "blendPreMultipledAlpha", type BOOLEAN
319 * @note The default value is false
322 BLEND_PRE_MULTIPLIED_ALPHA,
325 * @brief name "indexRangeFirst", type INTEGER
326 * @note The default value is 0
332 * @brief name "indexRangeCount", type INTEGER
333 * @note The default (0) means that whole range of indices will be used
339 * @brief name "depthWriteMode", type INTEGER
340 * @see DepthWriteMode
341 * @note The default value is DepthWriteMode::AUTO
347 * @brief name "depthFunction", type INTEGER
349 * @note The default value is DepthFunction::LESS
355 * @brief name "depthTestMode", type INTEGER
357 * @note The default value is DepthTestMode::AUTO
363 * @brief name "renderMode", type INTEGER
365 * @note The default value is RenderMode::AUTO
371 * @brief name "stencilFunction", type INTEGER
372 * @see StencilFunction
373 * @note The default value is StencilFunction::ALWAYS
379 * @brief name "stencilFunctionMask", type INTEGER
380 * @note The default value is 0xFF
383 STENCIL_FUNCTION_MASK,
386 * @brief name "stencilFunctionReference", type INTEGER
387 * @note The default value is 0
390 STENCIL_FUNCTION_REFERENCE,
393 * @brief name "stencilMask", type INTEGER
394 * @note The default value is 0xFF
400 * @brief name "stencilOperationOnFail", type INTEGER
401 * @see StencilOperation
402 * @note The default value is StencilOperation::KEEP
405 STENCIL_OPERATION_ON_FAIL,
408 * @brief name "stencilOperationOnZFail", type INTEGER
409 * @see StencilOperation
410 * @note The default value is StencilOperation::KEEP
413 STENCIL_OPERATION_ON_Z_FAIL,
416 * @brief name "stencilOperationOnZPass", type INTEGER
417 * @see StencilOperation
418 * @note The default value is StencilOperation::KEEP
421 STENCIL_OPERATION_ON_Z_PASS,
424 * @brief name "batchingEnabled", type BOOLEAN
427 * @note The default value is 'false'
434 * @brief Creates a new Renderer object
437 * @param[in] geometry Geometry to be used by this renderer
438 * @param[in] shader Shader to be used by this renderer
439 * @return A handle to the Renderer
441 static Renderer New( Geometry& geometry, Shader& shader );
444 * @brief Default constructor, creates an empty handle
458 * @brief Copy constructor, creates a new handle to the same object
461 * @param[in] handle Handle to an object
463 Renderer( const Renderer& handle );
466 * @brief Downcast to a renderer handle.
467 * If not a renderer the returned renderer handle is left uninitialized.
470 * @param[in] handle Handle to an object
471 * @return Renderer handle or an uninitialized handle
473 static Renderer DownCast( BaseHandle handle );
476 * @brief Assignment operator, changes this handle to point at the same object
479 * @param[in] handle Handle to an object
480 * @return Reference to the assigned object
482 Renderer& operator=( const Renderer& handle );
485 * @brief Sets the geometry to be used by this renderer
488 * @param[in] geometry The geometry to be used by this renderer
490 void SetGeometry( Geometry& geometry );
493 * @brief Gets the geometry used by this renderer
496 * @return The geometry used by the renderer
498 Geometry GetGeometry() const;
501 * @brief Sets effective range of indices to draw from bound index buffer
504 * @param[in] firstElement The First element to draw
505 * @param[in] elementsCount The number of elements to draw
507 inline void SetIndexRange( int firstElement, int elementsCount )
509 SetProperty( Property::INDEX_RANGE_FIRST, firstElement );
510 SetProperty( Property::INDEX_RANGE_COUNT, elementsCount );
514 * @brief Sets the texture set to be used by this renderer
517 * @param[in] textureSet The texture set to be used by this renderer
519 void SetTextures( TextureSet& textureSet );
522 * @brief Gets the texture set used by this renderer
525 * @return The texture set used by the renderer
527 TextureSet GetTextures() const;
530 * @brief Set the shader used by this renderer
533 * @param[in] shader The shader to be used by this renderer
535 void SetShader( Shader& shader );
538 * @brief Get the shader used by this renderer
541 * @return The shader used by the renderer
543 Shader GetShader() const;
548 * @brief The constructor.
549 * @note Not intended for application developers.
551 * @param[in] pointer A pointer to a newly allocated Renderer
553 explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
558 #endif // DALI_RENDERER_H