1 #ifndef DALI_INTERNAL_SAMPLER_H
2 #define DALI_INTERNAL_SAMPLER_H
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
40 typedef IntrusivePtr<Sampler> SamplerPtr;
43 * Sampler is an object that contains an array of structures of values that
44 * can be accessed as properties.
46 class Sampler : public Object, public Connectable
51 * Create a new Sampler.
52 * @return A smart-pointer to the newly allocated Sampler.
54 static SamplerPtr New( const std::string& textureUnitUniformName );
57 * @copydoc Dali::Sampler::SetUniformName()
59 void SetTextureUnitUniformName( const std::string& name );
62 * @copydoc Dali::Sampler::GetUniformName()
64 const std::string& GetTextureUnitUniformName() const;
67 * @copydoc Dali::Sampler::SetImage()
69 void SetImage( ImagePtr& image );
72 * @copydoc Dali::Sampler::GetImage()
74 ImagePtr GetImage() const;
77 * @copydoc Dali::Sampler::SetFilterMode()
79 void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
82 * @copydoc Dali::Sampler::SetWrapMode()
84 void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
87 * @copydoc Dali::Sampler::SetAffectsTransparency()
89 void SetAffectsTransparency( bool affectsTransparency );
92 * @brief Get the sampler scene object
94 * @return the sampler scene object
96 const SceneGraph::Sampler* GetSamplerSceneObject() const;
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.
102 SceneGraph::Sampler* GetSamplerSceneObject();
104 public: // Default property extensions from Object
107 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
109 virtual unsigned int GetDefaultPropertyCount() const;
112 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
114 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
117 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
119 virtual const char* GetDefaultPropertyName(Property::Index index) const;
122 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
124 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
127 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
129 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
132 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
134 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
137 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
139 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
142 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
144 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
147 * @copydoc Dali::Internal::Object::SetDefaultProperty()
149 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
152 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
154 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
157 * @copydoc Dali::Internal::Object::GetDefaultProperty()
159 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
162 * @copydoc Dali::Internal::Object::GetPropertyOwner()
164 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
167 * @copydoc Dali::Internal::Object::GetSceneObject()
169 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
172 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
174 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
177 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
179 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
182 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
184 virtual int GetPropertyComponentIndex( Property::Index index ) const;
186 public: // Functions from Connectable
188 * @copydoc Dali::Internal::Connectable::OnStage()
190 virtual bool OnStage() const;
193 * @copydoc Dali::Internal::Connectable::Connect()
195 virtual void Connect();
198 * @copydoc Dali::Internal::Connectable::Disconnect()
200 virtual void Disconnect();
206 * Second stage initialization
208 void Initialize( const std::string& textureUnitUniformName );
212 * A reference counted object may only be deleted by calling Unreference()
217 //TODO: MESH_REWORK : change to ObjectConnector
218 ImageConnector mImageConnector;
219 SceneGraph::Sampler* mSceneObject;
223 } // namespace Internal
225 // Helpers for public-api forwarding methods
226 inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
228 DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
230 BaseObject& object = handle.GetBaseObject();
232 return static_cast<Internal::Sampler&>(object);
235 inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
237 DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
239 const BaseObject& object = handle.GetBaseObject();
241 return static_cast<const Internal::Sampler&>(object);
246 #endif // DALI_INTERNAL_SAMPLER_H