[dali_1.1.3] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / sampler-impl.h
1 #ifndef DALI_INTERNAL_SAMPLER_H
2 #define DALI_INTERNAL_SAMPLER_H
3
4 /*
5  * Copyright (c) 2015 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/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
25 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
26 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
27 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
28 #include <dali/internal/event/images/image-connector.h> // Dali::Internal::ImageConnector
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace SceneGraph
35 {
36 class Sampler;
37 }
38
39 class Sampler;
40 typedef IntrusivePtr<Sampler> SamplerPtr;
41
42 /**
43  * Sampler is an object that contains an array of structures of values that
44  * can be accessed as properties.
45  */
46 class Sampler : public Object, public Connectable
47 {
48 public:
49
50   /**
51    * Create a new Sampler.
52    * @return A smart-pointer to the newly allocated Sampler.
53    */
54   static SamplerPtr New( const std::string& textureUnitUniformName );
55
56   /**
57    * @copydoc Dali::Sampler::SetUniformName()
58    */
59   void SetTextureUnitUniformName( const std::string& name );
60
61   /**
62    * @copydoc Dali::Sampler::GetUniformName()
63    */
64   const std::string& GetTextureUnitUniformName() const;
65
66   /**
67    * @copydoc Dali::Sampler::SetImage()
68    */
69   void SetImage( ImagePtr& image );
70
71   /**
72    * @copydoc Dali::Sampler::GetImage()
73    */
74   ImagePtr GetImage() const;
75
76   /**
77    * @copydoc Dali::Sampler::SetFilterMode()
78    */
79   void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
80
81   /**
82    * @copydoc Dali::Sampler::SetWrapMode()
83    */
84   void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
85
86   /**
87    * @copydoc Dali::Sampler::SetAffectsTransparency()
88    */
89   void SetAffectsTransparency( bool affectsTransparency );
90
91   /**
92    * @brief Get the sampler scene object
93    *
94    * @return the sampler scene object
95    */
96   const SceneGraph::Sampler* GetSamplerSceneObject() const;
97
98   /**
99    * Retrieve the scene-graph sampler added by this object.
100    * @return A pointer to the sampler, or NULL if no sampler has been added to the scene-graph.
101    */
102   SceneGraph::Sampler* GetSamplerSceneObject();
103
104 public: // Default property extensions from Object
105
106   /**
107    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
108    */
109   virtual unsigned int GetDefaultPropertyCount() const;
110
111   /**
112    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
113    */
114   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
115
116   /**
117    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
118    */
119   virtual const char* GetDefaultPropertyName(Property::Index index) const;
120
121   /**
122    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
123    */
124   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
125
126   /**
127    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
128    */
129   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
130
131   /**
132    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
133    */
134   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
135
136   /**
137    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
138    */
139   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
140
141   /**
142    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
143    */
144   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
145
146   /**
147    * @copydoc Dali::Internal::Object::SetDefaultProperty()
148    */
149   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
150
151   /**
152    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
153    */
154   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
155
156   /**
157    * @copydoc Dali::Internal::Object::GetDefaultProperty()
158    */
159   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
160
161   /**
162    * @copydoc Dali::Internal::Object::GetPropertyOwner()
163    */
164   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
165
166   /**
167    * @copydoc Dali::Internal::Object::GetSceneObject()
168    */
169   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
170
171   /**
172    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
173    */
174   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
175
176   /**
177    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
178    */
179   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
180
181   /**
182    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
183    */
184   virtual int GetPropertyComponentIndex( Property::Index index ) const;
185
186 public: // Functions from Connectable
187   /**
188    * @copydoc Dali::Internal::Connectable::OnStage()
189    */
190   virtual bool OnStage() const;
191
192   /**
193    * @copydoc Dali::Internal::Connectable::Connect()
194    */
195   virtual void Connect();
196
197   /**
198    * @copydoc Dali::Internal::Connectable::Disconnect()
199    */
200   virtual void Disconnect();
201
202 private:
203   Sampler();
204
205   /**
206    * Second stage initialization
207    */
208   void Initialize( const std::string& textureUnitUniformName );
209
210 protected:
211   /**
212    * A reference counted object may only be deleted by calling Unreference()
213    */
214   virtual ~Sampler();
215
216 private: // data
217   //TODO: MESH_REWORK : change to ObjectConnector
218   ImageConnector mImageConnector;
219   SceneGraph::Sampler* mSceneObject;
220   bool mOnStage;
221 };
222
223 } // namespace Internal
224
225 // Helpers for public-api forwarding methods
226 inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
227 {
228   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
229
230   BaseObject& object = handle.GetBaseObject();
231
232   return static_cast<Internal::Sampler&>(object);
233 }
234
235 inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
236 {
237   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
238
239   const BaseObject& object = handle.GetBaseObject();
240
241   return static_cast<const Internal::Sampler&>(object);
242 }
243
244 } // namespace Dali
245
246 #endif // DALI_INTERNAL_SAMPLER_H