1 #ifndef DALI_RENDERER_H
2 #define DALI_RENDERER_H
5 * Copyright (c) 2015 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 <string> // std::string
25 #include <dali/public-api/actors/blending.h> // Dali::BlendingMode, Dali::BlendingEquation, Dali::BlendingFactor
26 #include <dali/public-api/object/handle.h> // Dali::Handle
27 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_OBJECT_PROPERTY_START_INDEX
28 #include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
29 #include <dali/devel-api/rendering/material.h> // Dali::Material
34 namespace Internal DALI_INTERNAL
40 * @brief Renderer is a handle to an object that can be used to provide an image to a material.
42 class DALI_IMPORT_API Renderer : public Handle
47 * @brief Set face culling mode.
51 NONE, ///< None of the faces should be culled
52 CULL_FRONT, ///< Cull front face, back face should never be shown
53 CULL_BACK, ///< Cull back face, back face should never be shown
54 CULL_BACK_AND_FRONT, ///< Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
58 * @brief An enumeration of properties belonging to the Renderer class.
64 DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depthIndex", type INTEGER
65 FACE_CULLING_MODE, ///< name "faceCullingMode", type INTEGER
66 BLENDING_MODE, ///< name "blendingMode", type INTEGER
67 BLEND_EQUATION_RGB, ///< name "blendEquationRgb", type INTEGER
68 BLEND_EQUATION_ALPHA, ///< name "blendEquationAlpha", type INTEGER
69 BLENDING_SRC_FACTOR_RGB, ///< name "sourceBlendFactorRgb", type INTEGER
70 BLENDING_DEST_FACTOR_RGB, ///< name "destinationBlendFactorRgb", type INTEGER
71 BLENDING_SRC_FACTOR_ALPHA, ///< name "sourceBlendFactorAlpha", type INTEGER
72 BLENDING_DEST_FACTOR_ALPHA, ///< name "destinationBlendFactorAlpha", type INTEGER
73 BLENDING_COLOR, ///< name "blendingColor", type VECTOR4
74 BLEND_PRE_MULTIPLIED_ALPHA, ///< name "blendPreMultipledAlpha", type BOOLEAN
79 * @brief Creates a new Renderer object
81 * @param[in] geometry Geometry to be used by this renderer
82 * @param[in] material Material to be used by this renderer
84 static Renderer New( Geometry& geometry, Material& material );
87 * @brief Default constructor, creates an empty handle
97 * @brief Copy constructor, creates a new handle to the same object
99 * @param[in] handle Handle to an object
101 Renderer( const Renderer& handle );
104 * @brief Downcast to a renderer handle.
106 * If not a renderer the returned renderer handle is left uninitialized.
107 * @param[in] handle to an object
108 * @return renderer handle or an uninitialized handle
110 static Renderer DownCast( BaseHandle handle );
113 * @brief Assignment operator, changes this handle to point at the same object
115 * @param[in] handle Handle to an object
116 * @return Reference to the assigned object
118 Renderer& operator=( const Renderer& handle );
121 * @brief Sets the geometry to be used by this renderer
123 * @param[in] geometry The geometry to be used by this renderer
125 void SetGeometry( Geometry& geometry );
128 * @brief Gets the geometry used by this renderer
130 * @return The geometry used by the renderer
132 Geometry GetGeometry() const;
135 * @brief Sets the material to be used by this renderer
137 * @param[in] material The material to be used by this renderer
139 void SetMaterial( Material& material );
142 * @brief Gets the material used by this renderer
144 * @return The material used by the renderer
146 Material GetMaterial() const;
149 * @brief Specify the pixel arithmetic used when the actor is blended.
151 * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
152 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
153 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
154 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
156 * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
157 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
158 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
159 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
161 void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
164 * @brief Specify the pixel arithmetic used when the actor is blended.
166 * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
167 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
168 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
169 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
171 * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
172 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
173 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
174 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
176 * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
177 * The options are the same as for srcFactorRgb.
179 * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
180 * The options are the same as for destFactorRgb.
182 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
183 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
186 * @brief Query the pixel arithmetic used when the actor is blended.
188 * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
189 * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
190 * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
191 * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
193 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
194 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
197 * @brief Specify the equation used when the actor is blended.
199 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
200 * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
202 void SetBlendEquation( BlendingEquation::Type equationRgba );
205 * @brief Specify the equation used when the actor is blended.
207 * @param[in] equationRgb The equation used for combining red, green, and blue components.
208 * @param[in] equationAlpha The equation used for combining the alpha component.
209 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
211 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
214 * @brief Query the equation used when the actor is blended.
216 * @param[out] equationRgb The equation used for combining red, green, and blue components.
217 * @param[out] equationAlpha The equation used for combining the alpha component.
219 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
223 * @brief The constructor
225 * @param [in] pointer A pointer to a newly allocated Renderer
227 explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer );
232 #endif // DALI_RENDERER_H