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