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/object-connector.h> // Dali::Internal::ObjectConnector
26 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
27 #include <dali/internal/event/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
39 typedef IntrusivePtr<Shader> ShaderPtr;
42 * Shader is an object that contains an array of structures of values that
43 * can be accessed as properties.
45 class Shader : public Object
50 * @copydoc Dali::Shader::New()
52 static ShaderPtr New( const std::string& vertexShader,
53 const std::string& fragmentShader,
54 Dali::Shader::ShaderHints hints );
57 * @brief Get the shader scene object
59 * @return the shader scene object
61 const SceneGraph::Shader* GetShaderSceneObject() const;
63 public: // Default property extensions from Object
66 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
68 virtual unsigned int GetDefaultPropertyCount() const;
71 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
73 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
76 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
78 virtual const char* GetDefaultPropertyName(Property::Index index) const;
81 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
83 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
86 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
88 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
91 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
93 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
96 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
98 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
101 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
103 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
106 * @copydoc Dali::Internal::Object::SetDefaultProperty()
108 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
111 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
113 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
116 * @copydoc Dali::Internal::Object::GetDefaultProperty()
118 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
121 * @copydoc Dali::Internal::Object::GetPropertyOwner()
123 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
126 * @copydoc Dali::Internal::Object::GetSceneObject()
128 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
131 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
133 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
136 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
138 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
141 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
143 virtual int GetPropertyComponentIndex( Property::Index index ) const;
145 private: // implementation
149 * Second stage initialization
151 void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::ShaderHints hints );
155 * A reference counted object may only be deleted by calling Unreference()
159 private: // unimplemented methods
160 Shader( const Shader& );
161 Shader& operator=( const Shader& );
164 SceneGraph::Shader* mSceneObject;
167 } // namespace Internal
169 // Helpers for public-api forwarding methods
170 inline Internal::Shader& GetImplementation( Dali::Shader& handle )
172 DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
174 BaseObject& object = handle.GetBaseObject();
176 return static_cast<Internal::Shader&>(object);
179 inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
181 DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
183 const BaseObject& object = handle.GetBaseObject();
185 return static_cast<const Internal::Shader&>(object);
190 #endif // DALI_INTERNAL_SHADER_H