(ImageSize) Add natural image size handling
[platform/core/uifw/dali-core.git] / capi / dali / public-api / actors / renderable-actor.h
1 #ifndef __DALI_RENDERABLE_ACTOR_H__
2 #define __DALI_RENDERABLE_ACTOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20
21 /**
22  * @addtogroup CAPI_DALI_FRAMEWORK
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/actors/actor.h>
28 #include <dali/public-api/actors/blending.h>
29
30 namespace Dali DALI_IMPORT_API
31 {
32 namespace Internal DALI_INTERNAL
33 {
34 class RenderableActor;
35 }
36
37 /**
38  * Face culling modes
39  */
40 enum CullFaceMode
41 {
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
46 };
47
48
49 /**
50  * An base class for renderable actors
51  */
52 class DALI_IMPORT_API RenderableActor : public Actor
53 {
54 public:
55
56   static const BlendingMode::Type DEFAULT_BLENDING_MODE; ///< default value is BlendingMode::AUTO
57
58   /**
59    * Create an uninitialized actor.
60    * Calling member functions with an uninitialized Dali::Object is not allowed.
61    */
62   RenderableActor();
63
64   /**
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
69    */
70   static RenderableActor DownCast( BaseHandle handle );
71
72   /**
73    * Virtual destructor.
74    * Dali::Object derived classes typically do not contain member data.
75    */
76   virtual ~RenderableActor();
77
78   /**
79    * @copydoc Dali::BaseHandle::operator=
80    */
81   using BaseHandle::operator=;
82
83   /**
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.
88    */
89   void SetSortModifier(float depthOffset);
90
91   /**
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.
96    */
97   float GetSortModifier() const;
98
99   /**
100    * Set the face-culling mode for this actor.
101    * @param[in] mode The culling mode.
102    */
103   void SetCullFace(CullFaceMode mode);
104
105   /**
106    * Retrieve the face-culling mode for this actor.
107    * @return mode The culling mode.
108    */
109   CullFaceMode GetCullFace() const;
110
111   /**
112    * Sets the blending mode.
113    *
114    * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
115    *
116    * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work.
117    *
118    * <ul>
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.
122    * </ul>
123    *
124    * @param[in] mode The blending mode.
125    */
126   void SetBlendMode( BlendingMode::Type mode );
127
128   /**
129    * Retrieves the blending mode.
130    *
131    * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON.
132    */
133   BlendingMode::Type GetBlendMode() const;
134
135   /**
136    * Specify the pixel arithmetic used when the actor is blended.
137    *
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.
142    *
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.
147    */
148   void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
149
150   /**
151    * Specify the pixel arithmetic used when the actor is blended.
152    *
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.
157    *
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.
162    *
163    * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
164    * The options are the same as for srcFactorRgb.
165    *
166    * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
167    * The options are the same as for destFactorRgb.
168    */
169   void SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
170                      BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
171
172   /**
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.
178    */
179   void GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   BlendingFactor::Type& destFactorRgb,
180                      BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
181
182   /**
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.
186    */
187   void SetBlendEquation( BlendingEquation::Type equationRgba );
188
189   /**
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.
194    */
195   void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
196
197   /**
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.
201    */
202   void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
203
204   /**
205    * Specify the color used when the actor is blended; the default is Vector4::ZERO.
206    * @param[in] color The blend color.
207    */
208   void SetBlendColor( const Vector4& color );
209
210   /**
211    * Query the color used when the actor is blended.
212    * @return The blend color.
213    */
214   const Vector4& GetBlendColor() const;
215
216 public: // Not intended for application developers
217
218   /**
219    * This constructor is used by Dali New() methods
220    * @param [in] actor A pointer to a newly allocated Dali resource
221    */
222   explicit DALI_INTERNAL RenderableActor(Internal::RenderableActor* actor);
223 };
224
225 } // namespace Dali
226
227 /**
228  * @}
229  */
230 #endif // __DALI_RENDERABLE_ACTOR_H__