1 #ifndef __DALI_RENDERABLE_ACTOR_H__
2 #define __DALI_RENDERABLE_ACTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 * @addtogroup CAPI_DALI_FRAMEWORK
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/blending.h>
30 namespace Dali DALI_IMPORT_API
32 namespace Internal DALI_INTERNAL
34 class RenderableActor;
42 CullNone, ///< Face culling disabled
43 CullFront, ///< Cull front facing polygons
44 CullBack, ///< Cull back facing polygons
45 CullFrontAndBack ///< Cull front and back facing polygons
50 * An base class for renderable actors
52 class DALI_IMPORT_API RenderableActor : public Actor
56 static const BlendingMode::Type DEFAULT_BLENDING_MODE; ///< default value is BlendingMode::AUTO
59 * Create an uninitialized actor.
60 * Calling member functions with an uninitialized Dali::Object is not allowed.
65 * Downcast an Object handle to RenderableActor. If handle points to a RenderableActor the
66 * downcast produces valid handle. If not the returned handle is left uninitialized.
67 * @param[in] handle to An object
68 * @return handle to a RenderableActor or an uninitialized handle
70 static RenderableActor DownCast( BaseHandle handle );
74 * Dali::Object derived classes typically do not contain member data.
76 virtual ~RenderableActor();
79 * @copydoc Dali::BaseHandle::operator=
81 using BaseHandle::operator=;
84 * Allows modification of an actors position in the depth sort algorithm.
85 * The offset can be altered for each coplanar actor hence allowing an order of painting.
86 * @pre The Actor has been initialized.
87 * @param [in] depthOffset the offset to be given to the actor. Positive values pushing it further back.
89 void SetSortModifier(float depthOffset);
92 * Retrieves the offset used to modify an actors position in the depth sort algorithm.
93 * The offset can be altered for each coplanar actor hence allowing an order of painting.
94 * @pre The Actor has been initialized.
95 * @return the offset that has been given to the actor. Positive values pushing it further back.
97 float GetSortModifier() const;
100 * Set the face-culling mode for this actor.
101 * @param[in] mode The culling mode.
103 void SetCullFace(CullFaceMode mode);
106 * Retrieve the face-culling mode for this actor.
107 * @return mode The culling mode.
109 CullFaceMode GetCullFace() const;
112 * Sets the blending mode.
114 * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
116 * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
119 * <li> \e OFF Blending is disabled.
120 * <li> \e AUTO Blending is enabled only if the renderable actor has alpha channel.
121 * <li> \e ON Blending is enabled.
124 * @param[in] mode The blending mode.
126 void SetBlendMode( BlendingMode::Type mode );
129 * Retrieves the blending mode.
131 * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
133 BlendingMode::Type GetBlendMode() const;
136 * Specify the pixel arithmetic used when the actor is blended.
138 * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
139 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
140 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
141 * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
143 * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
144 * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
145 * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
146 * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
148 void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
151 * Specify the pixel arithmetic used when the actor is blended.
153 * @param[in] srcFactorRgb Specifies how the red, green, and blue 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] destFactorRgb 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 * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
164 * The options are the same as for srcFactorRgb.
166 * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
167 * The options are the same as for destFactorRgb.
169 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
170 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
173 * Query the pixel arithmetic used when the actor is blended.
174 * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
175 * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
176 * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
177 * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
179 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
180 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
183 * Specify the equation used when the actor is blended.
184 * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
185 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
187 void SetBlendEquation( BlendingEquation::Type equationRgba );
190 * Specify the equation used when the actor is blended.
191 * @param[in] equationRgb The equation used for combining red, green, and blue components.
192 * @param[in] equationAlpha The equation used for combining the alpha component.
193 * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
195 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
198 * Query the equation used when the actor is blended.
199 * @param[out] equationRgb The equation used for combining red, green, and blue components.
200 * @param[out] equationAlpha The equation used for combining the alpha component.
202 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
205 * Specify the color used when the actor is blended; the default is Vector4::ZERO.
206 * @param[in] color The blend color.
208 void SetBlendColor( const Vector4& color );
211 * Query the color used when the actor is blended.
212 * @return The blend color.
214 const Vector4& GetBlendColor() const;
216 public: // Not intended for application developers
219 * This constructor is used by Dali New() methods
220 * @param [in] actor A pointer to a newly allocated Dali resource
222 explicit DALI_INTERNAL RenderableActor(Internal::RenderableActor* actor);
230 #endif // __DALI_RENDERABLE_ACTOR_H__