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/shader-effects/shader-effect.h>
25 #include <dali/public-api/actors/blending.h>
26 #include <dali/public-api/actors/sampling.h>
30 namespace Internal DALI_INTERNAL
32 class RenderableActor;
36 * @brief Face culling modes.
40 CullNone, ///< Face culling disabled
41 CullFront, ///< Cull front facing polygons
42 CullBack, ///< Cull back facing polygons
43 CullFrontAndBack ///< Cull front and back facing polygons
48 * @brief A base class for renderable actors.
50 class DALI_IMPORT_API RenderableActor : public Actor
54 static const BlendingMode::Type DEFAULT_BLENDING_MODE; ///< default value is BlendingMode::AUTO
57 * @brief Create an uninitialized actor.
59 * Calling member functions with an uninitialized Dali::Object is not allowed.
64 * @brief Downcast an Object handle to RenderableActor.
66 * If handle points to a RenderableActor the
67 * downcast produces valid handle. If not the returned handle is left uninitialized.
68 * @param[in] handle to An object
69 * @return handle to a RenderableActor or an uninitialized handle
71 static RenderableActor DownCast( BaseHandle handle );
76 * This is non-virtual since derived Handle types must not contain data or virtual methods.
81 * @brief Copy constructor
83 * @param [in] copy The actor to copy.
85 RenderableActor(const RenderableActor& copy);
88 * @brief Assignment operator
90 * @param [in] rhs The actor to copy.
92 RenderableActor& operator=(const RenderableActor& rhs);
95 * @brief Allows modification of an actors position in the depth sort algorithm.
97 * The offset can be altered for each coplanar actor hence allowing an order of painting.
98 * @pre The Actor has been initialized.
99 * @param [in] depthOffset the offset to be given to the actor. Positive values pushing it further back.
101 void SetSortModifier(float depthOffset);
104 * @brief Retrieves the offset used to modify an actors position in the depth sort algorithm.
106 * The offset can be altered for each coplanar actor hence allowing an order of painting.
107 * @pre The Actor has been initialized.
108 * @return the offset that has been given to the actor. Positive values pushing it further back.
110 float GetSortModifier() const;
113 * @brief Set the face-culling mode for this actor.
115 * @param[in] mode The culling mode.
117 void SetCullFace(CullFaceMode mode);
120 * @brief Retrieve the face-culling mode for this actor.
122 * @return mode The culling mode.
124 CullFaceMode GetCullFace() const;
127 * @brief Sets the blending mode.
129 * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
131 * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
134 * <li> \e OFF Blending is disabled.
135 * <li> \e AUTO Blending is enabled only if the renderable actor has alpha channel.
136 * <li> \e ON Blending is enabled.
139 * @param[in] mode The blending mode.
141 void SetBlendMode( BlendingMode::Type mode );
144 * @brief Retrieves the blending mode.
146 * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
148 BlendingMode::Type GetBlendMode() const;
151 * @brief Specify the pixel arithmetic used when the actor is blended.
153 * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
154 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
155 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
156 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
158 * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
159 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
160 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
161 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
163 void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
166 * @brief Specify the pixel arithmetic used when the actor is blended.
168 * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
169 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
170 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
171 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
173 * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
174 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
175 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
176 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
178 * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
179 * The options are the same as for srcFactorRgb.
181 * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
182 * The options are the same as for destFactorRgb.
184 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
185 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
188 * @brief Query the pixel arithmetic used when the actor is blended.
190 * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
191 * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
192 * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
193 * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
195 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
196 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
199 * @brief Specify the equation used when the actor is blended.
201 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
202 * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
204 void SetBlendEquation( BlendingEquation::Type equationRgba );
207 * @brief Specify the equation used when the actor is blended.
209 * @param[in] equationRgb The equation used for combining red, green, and blue components.
210 * @param[in] equationAlpha The equation used for combining the alpha component.
211 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
213 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
216 * @brief Query the equation used when the actor is blended.
218 * @param[out] equationRgb The equation used for combining red, green, and blue components.
219 * @param[out] equationAlpha The equation used for combining the alpha component.
221 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
224 * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO.
226 * @param[in] color The blend color.
228 void SetBlendColor( const Vector4& color );
231 * @brief Query the color used when the actor is blended.
233 * @return The blend color.
235 const Vector4& GetBlendColor() const;
238 * @brief Sets the filtering mode.
240 * Possible values are: FilterMode::NEAREST and FilterMode::LINEAR. Default is FilterMode::LINEAR.
243 * <li> \e NEAREST Use nearest filtering
244 * <li> \e LINEAR Use linear filtering
247 * @param[in] minFilter The minification filtering mode.
248 * @param[in] magFilter The magnification filtering mode.
250 void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
253 * @brief Retrieves the filtering mode.
255 * @param[out] minFilter The return minification value
256 * @param[out] magFilter The return magnification value
258 void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter) const;
261 * @brief Sets the shader effect for the RenderableActor.
263 * Shader effects provide special effects like ripple and bend.
264 * Setting a shader effect removes any shader effect previously set by SetShaderEffect.
265 * @pre The actor has been initialized.
266 * @pre effect has been initialized.
267 * @param [in] effect The shader effect.
269 void SetShaderEffect( ShaderEffect effect );
272 * @brief Retrieve the custom shader effect for the RenderableActor.
273 * If default shader is used an empty handle is returned.
275 * @pre The Actor has been initialized.
276 * @return The shader effect
278 ShaderEffect GetShaderEffect() const;
281 * @brief Removes the current shader effect.
283 * @pre The Actor has been initialized.
285 void RemoveShaderEffect();
287 public: // Not intended for application developers
290 * @brief This constructor is used by Dali New() methods
292 * @param [in] actor A pointer to a newly allocated Dali resource
294 explicit DALI_INTERNAL RenderableActor(Internal::RenderableActor* actor);
298 * @brief Sets the shader effect for all RenderableActors in a tree of Actors.
300 * @see RenderableActor::SetShaderEffect
302 * @param [in] actor root of a tree of actors.
303 * @param [in] effect The shader effect.
305 DALI_IMPORT_API void SetShaderEffectRecursively( Actor actor, ShaderEffect effect );
308 * @brief Removes the shader effect from all RenderableActors in a tree of Actors.
310 * @see RenderableActor::RemoveShaderEffect
312 * @param [in] actor root of a tree of actors.
314 DALI_IMPORT_API void RemoveShaderEffectRecursively( Actor actor );
318 #endif // __DALI_RENDERABLE_ACTOR_H__