(Properties) Added ability to add non-animatable event-thread only properties via...
[platform/core/uifw/dali-core.git] / dali / internal / event / actor-attachments / renderable-attachment-impl.h
1 #ifndef __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__
2 #define __DALI_INTERNAL_RENDERABLE_ATTACHMENT_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 // INTERNAL INCLUDES
21 #include <dali/public-api/actors/renderable-actor.h>
22 #include <dali/public-api/actors/blending.h>
23 #include <dali/internal/common/blending-options.h>
24 #include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace SceneGraph
33 {
34 class RenderableAttachment;
35 }
36
37 /**
38  * An base class for renderable actor attachments
39  */
40 class RenderableAttachment : public ActorAttachment
41 {
42 public:
43
44   /**
45    * Set the depth-sort modifier for the renderable.
46    * This modifies the back-to-front distance calculation, when rendering with transparency.
47    * This is useful for ordering transparent objects that are positioned close to each other.
48    * @param[in] modifier The depth-sort modifier.
49    */
50   void SetSortModifier(float modifier);
51
52   /**
53    * From Renderable; Retrieve the depth-sort modifier for the renderable.
54    * @return The depth-sort modifier.
55    */
56   float GetSortModifier() const;
57
58   /**
59    * Set the face-culling mode for this attachment.
60    * @param[in] mode The culling mode.
61    */
62   void SetCullFace(CullFaceMode mode);
63
64   /**
65    * Retrieve the face-culling mode for this attachment.
66    * @return mode The culling mode.
67    */
68   CullFaceMode GetCullFace() const;
69
70   /**
71    * @copydoc Dali::RenderableActor::SetBlendMode()
72    */
73   void SetBlendMode( BlendingMode::Type mode );
74
75   /**
76    * @copydoc Dali::RenderableActor::GetBlendMode()
77    */
78   BlendingMode::Type GetBlendMode() const;
79
80   /**
81    * @copydoc Dali::RenderableActor::SetBlendFunc()
82    */
83   void SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
84                      BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
85
86   /**
87    * @copydoc Dali::RenderableActor::GetBlendFunc()
88    */
89   void GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   BlendingFactor::Type& destFactorRgb,
90                      BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
91
92   /**
93    * @copydoc Dali::RenderableActor::SetBlendEquation()
94    */
95   void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
96
97   /**
98    * @copydoc Dali::RenderableActor::GetBlendEquation()
99    */
100   void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
101
102   /**
103    * @copydoc Dali::RenderableActor::SetBlendColor()
104    */
105   void SetBlendColor( const Vector4& color );
106
107   /**
108    * @copydoc Dali::RenderableActor::GetBlendColor()
109    */
110   const Vector4& GetBlendColor() const;
111
112 protected:
113
114   /**
115    * Protected constructor; only base classes are instantiatable.
116    * @param[in] stage Used to send messages to scene-graph.
117    */
118   RenderableAttachment( Stage& stage );
119
120   /**
121    * A reference counted object may only be deleted by calling Unreference()
122    */
123   virtual ~RenderableAttachment();
124
125 private:
126
127   // Undefined
128   RenderableAttachment(const RenderableAttachment&);
129
130   // Undefined
131   RenderableAttachment& operator=(const RenderableAttachment& rhs);
132
133   /**
134    * Helper for getting the scene-graph renderable attachment.
135    * @return The scene object.
136    */
137   const SceneGraph::RenderableAttachment& GetSceneAttachment() const;
138
139   /**
140    * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
141    */
142   virtual void OnStageConnection();
143
144   /**
145    * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
146    */
147   virtual void OnStageDisconnection();
148
149   /**
150    * For derived classes, chained from OnStageConnection()
151    */
152   virtual void OnStageConnection2() = 0;
153
154   /**
155    * For derived classes, chained from OnStageDisconnection()
156    */
157   virtual void OnStageDisconnection2() = 0;
158
159   /**
160    * For derived classes to provide a corresponding scene-graph object
161    * @return The scene-object.
162    */
163   virtual const SceneGraph::RenderableAttachment& GetSceneObject() const = 0;
164
165 private:
166
167   // Cached for actor-thread getters
168   float              mSortModifier;
169   CullFaceMode       mCullFaceMode;
170   BlendingMode::Type mBlendingMode;
171   BlendingOptions    mBlendingOptions;
172 };
173
174 } // namespace Internal
175
176 } // namespace Dali
177
178 #endif // __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__