Add Post Constraint that works after transform
[platform/core/uifw/dali-core.git] / dali / graphics-api / graphics-shader-create-info.h
1 #ifndef DALI_GRAPHICS_SHADER_CREATE_INFO_H
2 #define DALI_GRAPHICS_SHADER_CREATE_INFO_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <cstring>
23 #include <memory>
24
25 // INTERNAL INCLUDES
26 #include "graphics-shader.h"
27 #include "graphics-types.h"
28
29 namespace Dali
30 {
31 namespace Graphics
32 {
33 /**
34  * @brief ShaderCreateInfo contains details of a single shader (not a GL program!)
35  * attached to a specified pipeline stage (ie. vertex shader, fragment shader etc.)
36  */
37 struct ShaderCreateInfo
38 {
39   /**
40    * @brief Sets pointer to the extension
41    *
42    * The pointer to the extension must be set either to nullptr
43    * or to the valid structure. The structures may create
44    * a chain. The last structure in a chain must point at
45    * nullptr.
46    *
47    * @param[in] value pointer to the valid extension structure
48    * @return reference to this structure
49    */
50   auto& SetNextExtension(ExtensionCreateInfo* value)
51   {
52     nextExtension = value;
53     return *this;
54   }
55
56   /**
57    * @brief Sets pipeline stage the shader will be executed in
58    *
59    * @param[in] value valid pipeline stage
60    * @return reference to this structure
61    */
62   auto& SetPipelineStage(PipelineStage value)
63   {
64     pipelineStage = value;
65     return *this;
66   }
67
68   /**
69    * @brief Sets shader source language
70    *
71    * @param[in] value valid source language
72    * @return reference to this structure
73    */
74   auto& SetShaderlanguage(ShaderLanguage value)
75   {
76     shaderlanguage = value;
77     return *this;
78   }
79
80   /**
81    * @brief Sets pointer to the source data
82    *
83    * @param[in] value pointer to the source data
84    * @return reference to this structure
85    */
86   auto& SetSourceData(const void* value)
87   {
88     sourceData = value;
89     return *this;
90   }
91
92   /**
93    * @brief Sets size of the source data (in bytes)
94    *
95    * If the shader mode is TEXT, the size must include
96    * null-terminator.
97    *
98    * @param[in] value size in bytes
99    * @return reference to this structure
100    */
101   auto& SetSourceSize(uint32_t value)
102   {
103     sourceSize = value;
104     return *this;
105   }
106
107   /**
108    * @brief Sets shader source mode
109    *
110    * @param[in] value shader mode
111    * @return reference to this structure
112    */
113   auto& SetSourceMode(ShaderSourceMode value)
114   {
115     sourceMode = value;
116     return *this;
117   }
118
119   /**
120    * @brief Sets allocation callbacks which will be used when object is created
121    * and destroyed.
122    *
123    * @param[in] value Valid reference to AllocationCallbacksStructure
124    * @return reference to this structure
125    */
126   auto& SetAllocationCallbacks(const AllocationCallbacks& value)
127   {
128     allocationCallbacks = &value;
129     return *this;
130   }
131
132   /**
133    * @brief Equality operator.
134    *
135    * @param[in] rhs The ShaderCreateInfo to test against
136    * @return True if the ShaderCreateInfo are equal
137    */
138   bool operator==(const ShaderCreateInfo& rhs) const
139   {
140     return (sourceSize == rhs.sourceSize && 0 == memcmp(sourceData, rhs.sourceData, sourceSize) && pipelineStage == rhs.pipelineStage && allocationCallbacks == rhs.allocationCallbacks);
141   }
142
143   GraphicsStructureType type{GraphicsStructureType::SHADER_CREATE_INFO_STRUCT};
144   ExtensionCreateInfo*  nextExtension{nullptr};
145
146   PipelineStage    pipelineStage{};
147   ShaderLanguage   shaderlanguage{};
148   const void*      sourceData{nullptr};
149   uint32_t         sourceSize{0u};
150   ShaderSourceMode sourceMode{};
151
152   const AllocationCallbacks* allocationCallbacks{nullptr};
153 };
154
155 } // namespace Graphics
156 } // namespace Dali
157
158 #endif // DALI_GRAPHICS_SHADER_CREATE_INFO_H