Added connection for sampler texture
[platform/core/uifw/dali-core.git] / dali / internal / event / effects / 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/public-api/shader-effects/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 SetUniformName( const std::string& name );
60
61   /**
62    * @copydoc Dali::Sampler::SetImage()
63    */
64   void SetImage( ImagePtr& image );
65
66   /**
67    * @copydoc Dali::Sampler::SetFilterMode()
68    */
69   void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
70
71   /**
72    * @copydoc Dali::Sampler::SetWrapMode()
73    */
74   void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
75
76   /**
77    * @copydoc Dali::Sampler::SetAffectsTransparency()
78    */
79   void SetAffectsTransparency( bool affectsTransparency );
80
81   /**
82    * @brief Get the sampler scene object
83    *
84    * @return the sampler scene object
85    */
86   const SceneGraph::Sampler* GetSamplerSceneObject() const;
87
88 public: // Default property extensions from Object
89
90   /**
91    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
92    */
93   virtual unsigned int GetDefaultPropertyCount() const;
94
95   /**
96    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
97    */
98   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
99
100   /**
101    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
102    */
103   virtual const char* GetDefaultPropertyName(Property::Index index) const;
104
105   /**
106    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
107    */
108   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
109
110   /**
111    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
112    */
113   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
114
115   /**
116    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
117    */
118   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
119
120   /**
121    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
122    */
123   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
124
125   /**
126    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
127    */
128   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
129
130   /**
131    * @copydoc Dali::Internal::Object::SetDefaultProperty()
132    */
133   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
134
135   /**
136    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
137    */
138   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
139
140   /**
141    * @copydoc Dali::Internal::Object::GetDefaultProperty()
142    */
143   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
144
145   /**
146    * @copydoc Dali::Internal::Object::GetPropertyOwner()
147    */
148   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
149
150   /**
151    * @copydoc Dali::Internal::Object::GetSceneObject()
152    */
153   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
154
155   /**
156    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
157    */
158   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
159
160   /**
161    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
162    */
163   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
164
165   /**
166    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
167    */
168   virtual int GetPropertyComponentIndex( Property::Index index ) const;
169
170 public: // Functions from Connectable
171   /**
172    * @copydoc Dali::Internal::Connectable::OnStage()
173    */
174   virtual bool OnStage() const;
175
176   /**
177    * @copydoc Dali::Internal::Connectable::Connect()
178    */
179   virtual void Connect();
180
181   /**
182    * @copydoc Dali::Internal::Connectable::Disconnect()
183    */
184   virtual void Disconnect();
185
186 private:
187   Sampler();
188
189   /**
190    * Second stage initialization
191    */
192   void Initialize( const std::string& textureUnitUniformName );
193
194 protected:
195   /**
196    * A reference counted object may only be deleted by calling Unreference()
197    */
198   virtual ~Sampler();
199
200 private: // data
201   //TODO: MESH_REWORK : change to ObjectConnector
202   ImageConnector mImageConnector;
203   SceneGraph::Sampler* mSceneObject;
204   bool mOnStage;
205 };
206
207 } // namespace Internal
208
209 // Helpers for public-api forwarding methods
210 inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
211 {
212   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
213
214   BaseObject& object = handle.GetBaseObject();
215
216   return static_cast<Internal::Sampler&>(object);
217 }
218
219 inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
220 {
221   DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
222
223   const BaseObject& object = handle.GetBaseObject();
224
225   return static_cast<const Internal::Sampler&>(object);
226 }
227
228 } // namespace Dali
229
230 #endif // DALI_INTERNAL_SAMPLER_H