shader effect removal - cleanup of the API
[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 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/actors/blending.h>
24 #include <dali/internal/common/blending-options.h>
25 #include <dali/internal/common/image-sampler.h>
26 #include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
27 #include <dali/internal/event/effects/shader-declarations.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace SceneGraph
36 {
37 class RenderableAttachment;
38 }
39
40 /**
41  * An base class for renderable actor attachments
42  */
43 class RenderableAttachment : public ActorAttachment
44 {
45 public:
46
47   /**
48    * Set the depth-sort modifier for the renderable.
49    * This modifies the back-to-front distance calculation, when rendering with transparency.
50    * This is useful for ordering transparent objects that are positioned close to each other.
51    * @param[in] modifier The depth-sort modifier.
52    */
53   void SetSortModifier(float modifier);
54
55   /**
56    * From Renderable; Retrieve the depth-sort modifier for the renderable.
57    * @return The depth-sort modifier.
58    */
59   float GetSortModifier() const;
60
61   /**
62    * Set the face-culling mode for this attachment.
63    * @param[in] mode The culling mode.
64    */
65   void SetCullFace(CullFaceMode mode);
66
67   /**
68    * Retrieve the face-culling mode for this attachment.
69    * @return mode The culling mode.
70    */
71   CullFaceMode GetCullFace() const;
72
73   /**
74    * @copydoc Dali::RenderableActor::SetBlendMode()
75    */
76   void SetBlendMode( BlendingMode::Type mode );
77
78   /**
79    * @copydoc Dali::RenderableActor::GetBlendMode()
80    */
81   BlendingMode::Type GetBlendMode() const;
82
83   /**
84    * @copydoc Dali::RenderableActor::SetBlendFunc()
85    */
86   void SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
87                      BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
88
89   /**
90    * @copydoc Dali::RenderableActor::GetBlendFunc()
91    */
92   void GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   BlendingFactor::Type& destFactorRgb,
93                      BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
94
95   /**
96    * @copydoc Dali::RenderableActor::SetBlendEquation()
97    */
98   void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
99
100   /**
101    * @copydoc Dali::RenderableActor::GetBlendEquation()
102    */
103   void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
104
105   /**
106    * @copydoc Dali::RenderableActor::SetBlendColor()
107    */
108   void SetBlendColor( const Vector4& color );
109
110   /**
111    * @copydoc Dali::RenderableActor::GetBlendColor()
112    */
113   const Vector4& GetBlendColor() const;
114
115   /**
116    * @copydoc Dali::RenderableActor::SetFilterMode()
117    */
118   void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
119
120   /**
121    * @copydoc Dali::RenderableActor::GetFilterMode()
122    */
123   void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const;
124
125   /**
126    * @copydoc Dali::RenderableActor::SetShaderEffect
127    */
128   void SetShaderEffect(ShaderEffect& effect);
129
130   /**
131    * @copydoc Dali::RenderableActor::GetShaderEffect
132    */
133   ShaderEffectPtr GetShaderEffect() const;
134
135   /**
136    * @copydoc Dali::RenderableActor::RemoveShaderEffect
137    */
138   void RemoveShaderEffect();
139
140 protected:
141
142   /**
143    * Protected constructor; only base classes are instantiatable.
144    * @param[in] stage Used to send messages to scene-graph.
145    */
146   RenderableAttachment( Stage& stage );
147
148   /**
149    * A reference counted object may only be deleted by calling Unreference()
150    */
151   virtual ~RenderableAttachment();
152
153 private:
154
155   // Undefined
156   RenderableAttachment(const RenderableAttachment&);
157
158   // Undefined
159   RenderableAttachment& operator=(const RenderableAttachment& rhs);
160
161   /**
162    * Helper for getting the scene-graph renderable attachment.
163    * @return The scene object.
164    */
165   const SceneGraph::RenderableAttachment& GetSceneAttachment() const;
166
167   /**
168    * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
169    */
170   virtual void OnStageConnection();
171
172   /**
173    * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
174    */
175   virtual void OnStageDisconnection();
176
177   /**
178    * For derived classes, chained from OnStageConnection()
179    */
180   virtual void OnStageConnection2() = 0;
181
182   /**
183    * For derived classes, chained from OnStageDisconnection()
184    */
185   virtual void OnStageDisconnection2() = 0;
186
187   /**
188    * For derived classes to provide a corresponding scene-graph object
189    * @return The scene-object.
190    */
191   virtual const SceneGraph::RenderableAttachment& GetSceneObject() const = 0;
192
193 private: // Data, cached for actor-thread getters
194
195   ShaderEffectPtr    mShaderEffect;    ///< Optional referenced shader effect
196   BlendingOptions    mBlendingOptions;
197   unsigned int       mSamplerBitfield;
198   float              mSortModifier;
199   CullFaceMode       mCullFaceMode:3;  ///< cullface mode, 3 bits enough for 4 values
200   BlendingMode::Type mBlendingMode:2;  ///< blending mode, 2 bits enough for 3 values
201
202
203 };
204
205 } // namespace Internal
206
207 } // namespace Dali
208
209 #endif // __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__