removal of shader inheritance, renderable actors now have shaders and there is a...
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / renderable-actor-impl.h
1 #ifndef __DALI_INTERNAL_RENDERABLE_ACTOR_H__
2 #define __DALI_INTERNAL_RENDERABLE_ACTOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/renderable-actor.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/internal/event/actors/actor-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class RenderableAttachment;
33
34 /**
35  * An abstract base class for renderable actors
36  */
37 class RenderableActor : public Actor
38 {
39 public:
40
41   /**
42    * @copydoc Dali::RenderableActor::SetSortModifier()
43    */
44   void SetSortModifier(float modifier);
45
46   /**
47    * @copydoc Dali::RenderableActor::GetSortModifier()
48    */
49   float GetSortModifier() const;
50
51   /**
52    * @copydoc Dali::RenderableActor::SetCullFace()
53    */
54   void SetCullFace(CullFaceMode mode);
55
56   /**
57    * @copydoc Dali::RenderableActor::GetCullFace()
58    */
59   CullFaceMode GetCullFace() const;
60
61   /**
62    * @copydoc Dali::RenderableActor::SetBlendMode()
63    */
64   void SetBlendMode( BlendingMode::Type mode );
65
66   /**
67    * @copydoc Dali::RenderableActor::GetBlendMode()
68    */
69   BlendingMode::Type GetBlendMode() const;
70
71   /**
72    * @copydoc Dali::RenderableActor::SetBlendFunc()
73    */
74   void SetBlendFunc( BlendingFactor::Type srcFactorRgba,   BlendingFactor::Type destFactorRgba );
75
76   /**
77    * @copydoc Dali::RenderableActor::SetBlendFunc()
78    */
79   void SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
80                      BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
81
82   /**
83    * @copydoc Dali::RenderableActor::GetBlendFunc()
84    */
85   void GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   BlendingFactor::Type& destFactorRgb,
86                      BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
87
88   /**
89    * @copydoc Dali::RenderableActor::SetBlendEquation()
90    */
91   void SetBlendEquation( BlendingEquation::Type equationRgba );
92
93   /**
94    * @copydoc Dali::RenderableActor::SetBlendEquation()
95    */
96   void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
97
98   /**
99    * @copydoc Dali::RenderableActor::GetBlendEquation()
100    */
101   void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
102
103   /**
104    * @copydoc Dali::RenderableActor::SetBlendColor()
105    */
106   void SetBlendColor( const Vector4& color );
107
108   /**
109    * @copydoc Dali::RenderableActor::GetBlendColor()
110    */
111   const Vector4& GetBlendColor() const;
112
113   /**
114    * @copydoc Dali::RenderableActor::SetFilterMode()
115    */
116   void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
117
118   /**
119    * @copydoc Dali::RenderableActor::GetFilterMode()
120    */
121   void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const;
122
123 protected:
124
125   /**
126    * Protected constructor; only derived classes are instantiatable.
127    */
128   RenderableActor();
129
130   /**
131    * A reference counted object may only be deleted by calling Unreference()
132    */
133   virtual ~RenderableActor();
134
135 public: // from Actor, in future not virtual. Accessible also from RenderableActor
136
137   /**
138    * @copydoc Actor::SetShaderEffect
139    */
140   virtual void SetShaderEffect(ShaderEffect& effect);
141
142   /**
143    * @copydoc Actor::GetShaderEffect
144    */
145   virtual ShaderEffectPtr GetShaderEffect() const;
146
147   /**
148    * @copydoc Actor::RemoveShaderEffect
149    */
150   virtual void RemoveShaderEffect();
151
152 private:
153
154   /**
155    * @return a reference to the renderable attachment
156    */
157   virtual RenderableAttachment& GetRenderableAttachment() const = 0;
158
159   // Undefined
160   RenderableActor(const RenderableActor&);
161   // Undefined
162   RenderableActor& operator=(const RenderableActor& rhs);
163
164 };
165
166 } // namespace Internal
167
168 // Helpers for public-api forwarding methods
169
170 inline Internal::RenderableActor& GetImplementation(Dali::RenderableActor& renderable)
171 {
172   DALI_ASSERT_ALWAYS( renderable && "RenderableActor handle is empty" );
173
174   BaseObject& handle = renderable.GetBaseObject();
175
176   return static_cast<Internal::RenderableActor&>(handle);
177 }
178
179 inline const Internal::RenderableActor& GetImplementation(const Dali::RenderableActor& renderable)
180 {
181   DALI_ASSERT_ALWAYS(renderable && "RenderableActor handle is empty" );
182
183   const BaseObject& handle = renderable.GetBaseObject();
184
185   return static_cast<const Internal::RenderableActor&>(handle);
186 }
187
188 } // namespace Dali
189
190 #endif // __DALI_INTERNAL_RENDERABLE_ACTOR_H__