Merge "Remove RenderableActor" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / shader-impl.h
1 #ifndef DALI_INTERNAL_SHADER_H
2 #define DALI_INTERNAL_SHADER_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/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
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace SceneGraph
35 {
36 class Shader;
37 }
38
39 class Shader;
40 typedef IntrusivePtr<Shader> ShaderPtr;
41
42 /**
43  * Shader is an object that contains an array of structures of values that
44  * can be accessed as properties.
45  */
46 class Shader : public Object, public Connectable
47 {
48 public:
49
50   /**
51    * @copydoc Dali::Shader::New()
52    */
53   static ShaderPtr New( const std::string& vertexShader,
54                         const std::string& fragmentShader,
55                         Dali::Shader::ShaderHints hints );
56
57   /**
58    * @brief Get the shader scene object
59    *
60    * @return the shader scene object
61    */
62   const SceneGraph::Shader* GetShaderSceneObject() const;
63
64 public: // Default property extensions from Object
65
66   /**
67    * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
68    */
69   virtual unsigned int GetDefaultPropertyCount() const;
70
71   /**
72    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
73    */
74   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
75
76   /**
77    * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
78    */
79   virtual const char* GetDefaultPropertyName(Property::Index index) const;
80
81   /**
82    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
83    */
84   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
85
86   /**
87    * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
88    */
89   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
90
91   /**
92    * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
93    */
94   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
95
96   /**
97    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
98    */
99   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
100
101   /**
102    * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
103    */
104   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
105
106   /**
107    * @copydoc Dali::Internal::Object::SetDefaultProperty()
108    */
109   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
110
111   /**
112    * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
113    */
114   virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
115
116   /**
117    * @copydoc Dali::Internal::Object::GetDefaultProperty()
118    */
119   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
120
121   /**
122    * @copydoc Dali::Internal::Object::GetPropertyOwner()
123    */
124   virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
125
126   /**
127    * @copydoc Dali::Internal::Object::GetSceneObject()
128    */
129   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
130
131   /**
132    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
133    */
134   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
135
136   /**
137    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
138    */
139   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
140
141   /**
142    * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
143    */
144   virtual int GetPropertyComponentIndex( Property::Index index ) const;
145
146 public: // Functions from Connectable
147   /**
148    * @copydoc Dali::Internal::Connectable::OnStage()
149    */
150   virtual bool OnStage() const;
151
152   /**
153    * @copydoc Dali::Internal::Connectable::Connect()
154    */
155   virtual void Connect();
156
157   /**
158    * @copydoc Dali::Internal::Connectable::Disconnect()
159    */
160   virtual void Disconnect();
161
162 private: // implementation
163   Shader();
164
165   /**
166    * Second stage initialization
167    */
168   void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::ShaderHints hints );
169
170 protected:
171   /**
172    * A reference counted object may only be deleted by calling Unreference()
173    */
174   virtual ~Shader();
175
176 private: // unimplemented methods
177   Shader( const Shader& );
178   Shader& operator=( const Shader& );
179
180 private:
181   SceneGraph::Shader* mSceneObject;
182   bool mOnStage;
183 };
184
185 } // namespace Internal
186
187 // Helpers for public-api forwarding methods
188 inline Internal::Shader& GetImplementation( Dali::Shader& handle )
189 {
190   DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
191
192   BaseObject& object = handle.GetBaseObject();
193
194   return static_cast<Internal::Shader&>(object);
195 }
196
197 inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
198 {
199   DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
200
201   const BaseObject& object = handle.GetBaseObject();
202
203   return static_cast<const Internal::Shader&>(object);
204 }
205
206 } // namespace Dali
207
208 #endif // DALI_INTERNAL_SHADER_H