Clean up the code to build successfully on macOS
[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) 2018 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/public-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/common/shader-data.h> // ShaderPtr
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace SceneGraph
34 {
35 class Shader;
36 }
37
38 class Shader;
39 using ShaderPtr = IntrusivePtr<Shader>;
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::Hint::Value hints );
55
56   /**
57    * Retrieve the scene-graph shader added by this object.
58    * @return A pointer to the shader.
59    */
60   const SceneGraph::Shader& GetShaderSceneObject() const;
61
62 public: // Default property extensions from Object
63
64   /**
65    * @copydoc Dali::Internal::Object::SetDefaultProperty()
66    */
67   void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
68
69   /**
70    * @copydoc Dali::Internal::Object::GetDefaultProperty()
71    */
72   Property::Value GetDefaultProperty( Property::Index index ) const override;
73
74   /**
75    * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
76    */
77   Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
78
79 private: // implementation
80
81   /**
82    * Constructor
83    *
84    * @param sceneObject the scene object
85    */
86   Shader( const SceneGraph::Shader* sceneObject );
87
88   /**
89    * Second stage initialization
90    */
91   void SetShader( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::Hint::Value hints );
92
93 protected:
94   /**
95    * A reference counted object may only be deleted by calling Unreference()
96    */
97   ~Shader() override;
98
99 private: // unimplemented methods
100
101   Shader() = delete;
102   Shader( const Shader& ) = delete;
103   Shader& operator=( const Shader& ) = delete;
104
105 private:
106
107   Internal::ShaderDataPtr mShaderData;
108
109 };
110
111 } // namespace Internal
112
113 // Helpers for public-api forwarding methods
114 inline Internal::Shader& GetImplementation( Dali::Shader& handle )
115 {
116   DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
117
118   BaseObject& object = handle.GetBaseObject();
119
120   return static_cast<Internal::Shader&>(object);
121 }
122
123 inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
124 {
125   DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
126
127   const BaseObject& object = handle.GetBaseObject();
128
129   return static_cast<const Internal::Shader&>(object);
130 }
131
132 } // namespace Dali
133
134 #endif // DALI_INTERNAL_SHADER_H