1 #ifndef __DALI_RENDERABLE_ACTOR_H__
2 #define __DALI_RENDERABLE_ACTOR_H__
5 * Copyright (c) 2014 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.
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/actors/blending.h>
25 #include <dali/public-api/actors/sampling.h>
29 namespace Internal DALI_INTERNAL
31 class RenderableActor;
37 * @brief Face culling modes.
41 CullNone, ///< Face culling disabled
42 CullFront, ///< Cull front facing polygons
43 CullBack, ///< Cull back facing polygons
44 CullFrontAndBack ///< Cull front and back facing polygons
49 * @brief A base class for renderable actors.
51 class DALI_IMPORT_API RenderableActor : public Actor
55 static const BlendingMode::Type DEFAULT_BLENDING_MODE; ///< default value is BlendingMode::AUTO
58 * @brief Create an uninitialized actor.
60 * Calling member functions with an uninitialized Dali::Object is not allowed.
65 * @brief Downcast an Object handle to RenderableActor.
67 * If handle points to a RenderableActor the
68 * downcast produces valid handle. If not the returned handle is left uninitialized.
69 * @param[in] handle to An object
70 * @return handle to a RenderableActor or an uninitialized handle
72 static RenderableActor DownCast( BaseHandle handle );
77 * This is non-virtual since derived Handle types must not contain data or virtual methods.
82 * @brief Copy constructor
84 * @param [in] copy The actor to copy.
86 RenderableActor(const RenderableActor& copy);
89 * @brief Assignment operator
91 * @param [in] rhs The actor to copy.
93 RenderableActor& operator=(const RenderableActor& rhs);
96 * @brief Allows modification of an actors position in the depth sort algorithm.
98 * The offset can be altered for each coplanar actor hence allowing an order of painting.
99 * @pre The Actor has been initialized.
100 * @param [in] depthOffset the offset to be given to the actor. Positive values pushing it further back.
102 void SetSortModifier(float depthOffset);
105 * @brief Retrieves the offset used to modify an actors position in the depth sort algorithm.
107 * The offset can be altered for each coplanar actor hence allowing an order of painting.
108 * @pre The Actor has been initialized.
109 * @return the offset that has been given to the actor. Positive values pushing it further back.
111 float GetSortModifier() const;
114 * @brief Set the face-culling mode for this actor.
116 * @param[in] mode The culling mode.
118 void SetCullFace(CullFaceMode mode);
121 * @brief Retrieve the face-culling mode for this actor.
123 * @return mode The culling mode.
125 CullFaceMode GetCullFace() const;
128 * @brief Sets the blending mode.
130 * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
132 * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
135 * <li> \e OFF Blending is disabled.
136 * <li> \e AUTO Blending is enabled only if the renderable actor has alpha channel.
137 * <li> \e ON Blending is enabled.
140 * @param[in] mode The blending mode.
142 void SetBlendMode( BlendingMode::Type mode );
145 * @brief Retrieves the blending mode.
147 * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
149 BlendingMode::Type GetBlendMode() const;
152 * @brief Specify the pixel arithmetic used when the actor is blended.
154 * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
155 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
156 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
157 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
159 * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
160 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
161 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
162 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
164 void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
167 * @brief Specify the pixel arithmetic used when the actor is blended.
169 * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
170 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
171 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
172 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
174 * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
175 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
176 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
177 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
179 * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
180 * The options are the same as for srcFactorRgb.
182 * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
183 * The options are the same as for destFactorRgb.
185 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
186 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
189 * @brief Query the pixel arithmetic used when the actor is blended.
191 * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
192 * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
193 * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
194 * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
196 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
197 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
200 * @brief Specify the equation used when the actor is blended.
202 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
203 * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
205 void SetBlendEquation( BlendingEquation::Type equationRgba );
208 * @brief Specify the equation used when the actor is blended.
210 * @param[in] equationRgb The equation used for combining red, green, and blue components.
211 * @param[in] equationAlpha The equation used for combining the alpha component.
212 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
214 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
217 * @brief Query the equation used when the actor is blended.
219 * @param[out] equationRgb The equation used for combining red, green, and blue components.
220 * @param[out] equationAlpha The equation used for combining the alpha component.
222 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
225 * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO.
227 * @param[in] color The blend color.
229 void SetBlendColor( const Vector4& color );
232 * @brief Query the color used when the actor is blended.
234 * @return The blend color.
236 const Vector4& GetBlendColor() const;
239 * @brief Sets the filtering mode.
241 * Possible values are: FilterMode::NEAREST and FilterMode::LINEAR. Default is FilterMode::LINEAR.
244 * <li> \e NEAREST Use nearest filtering
245 * <li> \e LINEAR Use linear filtering
248 * @param[in] minFilter The minification filtering mode.
249 * @param[in] magFilter The magnification filtering mode.
251 void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
254 * @brief Retrieves the filtering mode.
256 * @param[out] minFilter The return minification value
257 * @param[out] magFilter The return magnification value
259 void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter) const;
262 * @brief Sets the shader effect for the RenderableActor.
264 * Shader effects provide special effects like ripple and bend.
265 * Setting a shader effect removes any shader effect previously set by SetShaderEffect.
266 * @pre The actor has been initialized.
267 * @pre effect has been initialized.
268 * @param [in] effect The shader effect.
270 void SetShaderEffect( ShaderEffect effect );
273 * @brief Retrieve the custom shader effect for the RenderableActor.
274 * If default shader is used an empty handle is returned.
276 * @pre The Actor has been initialized.
277 * @return The shader effect
279 ShaderEffect GetShaderEffect() const;
282 * @brief Removes the current shader effect.
284 * @pre The Actor has been initialized.
286 void RemoveShaderEffect();
288 public: // Not intended for application developers
291 * @brief This constructor is used by Dali New() methods
293 * @param [in] actor A pointer to a newly allocated Dali resource
295 explicit DALI_INTERNAL RenderableActor(Internal::RenderableActor* actor);
299 * @brief Sets the shader effect for all RenderableActors in a tree of Actors.
301 * @see RenderableActor::SetShaderEffect
303 * @param [in] actor root of a tree of actors.
304 * @param [in] effect The shader effect.
306 DALI_IMPORT_API void SetShaderEffectRecursively( Actor actor, ShaderEffect effect );
309 * @brief Removes the shader effect from all RenderableActors in a tree of Actors.
311 * @see RenderableActor::RemoveShaderEffect
313 * @param [in] actor root of a tree of actors.
315 DALI_IMPORT_API void RemoveShaderEffectRecursively( Actor actor );
319 #endif // __DALI_RENDERABLE_ACTOR_H__