1 #ifndef DALI_INTERNAL_SHADER_H
2 #define DALI_INTERNAL_SHADER_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/shader.h> // Dali::Shader
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/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
40 typedef IntrusivePtr<Shader> ShaderPtr;
43 * Shader is an object that contains an array of structures of values that
44 * can be accessed as properties.
46 class Shader : public Object, public Connectable
51 * @copydoc Dali::Shader::New()
53 static ShaderPtr New( const std::string& vertexShader,
54 const std::string& fragmentShader,
55 Dali::Shader::ShaderHints hints );
58 * @brief Get the shader scene object
60 * @return the shader scene object
62 const SceneGraph::Shader* GetShaderSceneObject() const;
64 public: // Default property extensions from Object
67 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
69 virtual unsigned int GetDefaultPropertyCount() const;
72 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
74 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
77 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
79 virtual const char* GetDefaultPropertyName(Property::Index index) const;
82 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
84 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
87 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
89 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
92 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
94 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
97 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
99 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
102 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
104 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
107 * @copydoc Dali::Internal::Object::SetDefaultProperty()
109 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
112 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
114 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
117 * @copydoc Dali::Internal::Object::GetDefaultProperty()
119 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
122 * @copydoc Dali::Internal::Object::GetPropertyOwner()
124 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
127 * @copydoc Dali::Internal::Object::GetSceneObject()
129 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
132 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
134 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
137 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
139 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
142 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
144 virtual int GetPropertyComponentIndex( Property::Index index ) const;
146 public: // Functions from Connectable
148 * @copydoc Dali::Internal::Connectable::OnStage()
150 virtual bool OnStage() const;
153 * @copydoc Dali::Internal::Connectable::Connect()
155 virtual void Connect();
158 * @copydoc Dali::Internal::Connectable::Disconnect()
160 virtual void Disconnect();
162 private: // implementation
166 * Second stage initialization
168 void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::ShaderHints hints );
172 * A reference counted object may only be deleted by calling Unreference()
176 private: // unimplemented methods
177 Shader( const Shader& );
178 Shader& operator=( const Shader& );
181 SceneGraph::Shader* mSceneObject;
182 ResourceTicketPtr mTicket;
186 } // namespace Internal
188 // Helpers for public-api forwarding methods
189 inline Internal::Shader& GetImplementation( Dali::Shader& handle )
191 DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
193 BaseObject& object = handle.GetBaseObject();
195 return static_cast<Internal::Shader&>(object);
198 inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
200 DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
202 const BaseObject& object = handle.GetBaseObject();
204 return static_cast<const Internal::Shader&>(object);
209 #endif // DALI_INTERNAL_SHADER_H