Add Post Constraint that works after transform
[platform/core/uifw/dali-core.git] / dali / graphics-api / graphics-texture-create-info.h
1 #ifndef DALI_GRAPHICS_TEXTURE_CREATE_INFO_H
2 #define DALI_GRAPHICS_TEXTURE_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 <dali/public-api/images/native-image-interface.h>
23 #include <memory>
24
25 // INTERNAL INCLUDES
26 #include "graphics-texture.h"
27 #include "graphics-types.h"
28
29 namespace Dali
30 {
31 namespace Graphics
32 {
33 /**
34  * @brief Interface class for TextureCreateInfo types in the graphics API.
35  */
36 struct TextureCreateInfo
37 {
38   /**
39    * @brief Sets pointer to the extension
40    *
41    * The pointer to the extension must be set either to nullptr
42    * or to the valid structure. The structures may create
43    * a chain. The last structure in a chain must point at
44    * nullptr.
45    *
46    * @param[in] value pointer to the valid extension structure
47    * @return reference to this structure
48    */
49   auto& SetNextExtension(ExtensionCreateInfo* value)
50   {
51     nextExtension = value;
52     return *this;
53   }
54
55   /**
56    * @brief Sets type of the texture
57    *
58    * @param[in] value type of the texture
59    * @return reference to this structure
60    */
61   auto& SetTextureType(TextureType value)
62   {
63     textureType = value;
64     return *this;
65   }
66
67   /**
68    * @brief Sets size of the texture
69    *
70    * @param[in] value size of the texture
71    * @return reference to this structure
72    */
73   auto& SetSize(Extent2D value)
74   {
75     size = value;
76     return *this;
77   }
78
79   /**
80    * @brief Sets the texture format
81    *
82    * Not all texture formats are supported, some are emulated.
83    *
84    * @param[in] value valid texture format
85    * @return reference to this structure
86    */
87   auto& SetFormat(Format value)
88   {
89     format = value;
90     return *this;
91   }
92
93   /**
94    * @brief Sets mipmap state
95    *
96    * @param[in] value The mipmap state flag
97    * @return reference to this structure
98    */
99   auto& SetMipMapFlag(TextureMipMapFlag value)
100   {
101     mipMapFlag = value;
102     return *this;
103   }
104
105   /**
106    * @brief Sets pointer to the data
107    *
108    * The data of texture can be uploaded upon texture creation.
109    *
110    * @param[in] value pointer to valid data
111    * @return reference to this structure
112    */
113   auto& SetData(void* value)
114   {
115     data = value;
116     return *this;
117   }
118
119   /**
120    * @brief Sets size of the data
121    *
122    * @param[in] value size of data in bytes
123    * @return reference to this structure
124    */
125   auto& SetDataSize(uint32_t value)
126   {
127     dataSize = value;
128     return *this;
129   }
130
131   /**
132    * @brief Sets texture data layout
133    *
134    * By choosing LINEAR layout the texture can be accessed
135    * directly via mapped memory. This may mean allocating
136    * extra staging buffer if necessary (layout may be emulated).
137    *
138    * @param[in] value texture layout
139    * @return reference to this structure
140    */
141   auto& SetLayout(TextureLayout value)
142   {
143     layout = value;
144     return *this;
145   }
146
147   /**
148    * @brief Sets texture usage flags
149    *
150    * The usage flags may affect the way the texture is
151    * allocated and stored in the memory. It may also affect
152    * the way how data is writen/read.
153    *
154    * @param[in] value Flags of usage
155    * @return reference to this structure
156    */
157   auto& SetUsageFlags(TextureUsageFlags value)
158   {
159     usageFlags = value;
160     return *this;
161   }
162
163   /**
164    * @brief Sets native image interface pointer
165    *
166    * @param[in] value valid native image interface pointer
167    * @return reference to this structure
168    */
169   auto& SetNativeImage(NativeImageInterfacePtr value)
170   {
171     nativeImagePtr = value;
172     return *this;
173   }
174
175   /**
176    * @brief Sets allocation callbacks which will be used when object is created
177    * and destroyed.
178    *
179    * @param[in] value Valid reference to AllocationCallbacksStructure
180    * @return reference to this structure
181    */
182   auto& SetAllocationCallbacks(const AllocationCallbacks& value)
183   {
184     allocationCallbacks = &value;
185     return *this;
186   }
187
188   GraphicsStructureType type{GraphicsStructureType::TEXTURE_CREATE_INFO_STRUCT};
189   ExtensionCreateInfo*  nextExtension{nullptr};
190
191   TextureType             textureType{};
192   Extent2D                size{};
193   Format                  format{};
194   TextureMipMapFlag       mipMapFlag{};
195   TextureLayout           layout{};
196   TextureUsageFlags       usageFlags{};
197   void*                   data{};
198   uint32_t                dataSize{0u};
199   NativeImageInterfacePtr nativeImagePtr{};
200
201   const AllocationCallbacks* allocationCallbacks{nullptr};
202 };
203
204 } // namespace Graphics
205 } // namespace Dali
206
207 #endif // DALI_GRAPHICS_API_TEXTURE_CREATE_INFO_H