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::SetImage()
64 void SetImage( ImagePtr& image );
67 * @copydoc Dali::Sampler::GetImage()
69 ImagePtr GetImage() const;
72 * @copydoc Dali::Sampler::SetFilterMode()
74 void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
77 * @copydoc Dali::Sampler::SetWrapMode()
79 void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
82 * @copydoc Dali::Sampler::SetAffectsTransparency()
84 void SetAffectsTransparency( bool affectsTransparency );
87 * @brief Get the sampler scene object
89 * @return the sampler scene object
91 const SceneGraph::Sampler* GetSamplerSceneObject() const;
94 * Retrieve the scene-graph sampler added by this object.
95 * @return A pointer to the sampler, or NULL if no sampler has been added to the scene-graph.
97 SceneGraph::Sampler* GetSamplerSceneObject();
99 public: // Default property extensions from Object
102 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
104 virtual unsigned int GetDefaultPropertyCount() const;
107 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
109 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
112 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
114 virtual const char* GetDefaultPropertyName(Property::Index index) const;
117 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
119 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
122 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
124 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
127 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
129 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
132 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
134 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
137 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
139 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
142 * @copydoc Dali::Internal::Object::SetDefaultProperty()
144 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
147 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
149 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
152 * @copydoc Dali::Internal::Object::GetDefaultProperty()
154 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
157 * @copydoc Dali::Internal::Object::GetPropertyOwner()
159 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
162 * @copydoc Dali::Internal::Object::GetSceneObject()
164 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
167 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
169 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
172 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
174 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
177 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
179 virtual int GetPropertyComponentIndex( Property::Index index ) const;
181 public: // Functions from Connectable
183 * @copydoc Dali::Internal::Connectable::OnStage()
185 virtual bool OnStage() const;
188 * @copydoc Dali::Internal::Connectable::Connect()
190 virtual void Connect();
193 * @copydoc Dali::Internal::Connectable::Disconnect()
195 virtual void Disconnect();
201 * Second stage initialization
203 void Initialize( const std::string& textureUnitUniformName );
207 * A reference counted object may only be deleted by calling Unreference()
212 //TODO: MESH_REWORK : change to ObjectConnector
213 ImageConnector mImageConnector;
214 SceneGraph::Sampler* mSceneObject;
218 } // namespace Internal
220 // Helpers for public-api forwarding methods
221 inline Internal::Sampler& GetImplementation(Dali::Sampler& handle)
223 DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
225 BaseObject& object = handle.GetBaseObject();
227 return static_cast<Internal::Sampler&>(object);
230 inline const Internal::Sampler& GetImplementation(const Dali::Sampler& handle)
232 DALI_ASSERT_ALWAYS(handle && "Sampler handle is empty");
234 const BaseObject& object = handle.GetBaseObject();
236 return static_cast<const Internal::Sampler&>(object);
241 #endif // DALI_INTERNAL_SAMPLER_H