1 #ifndef DALI_GRAPHICS_API_TYPES
2 #define DALI_GRAPHICS_API_TYPES
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
27 #include <dali/public-api/images/pixel-data.h>
28 #include <dali/public-api/signals/callback.h>
42 * @brief Structure describes 2D offset
51 * @brief Structure describes 2D dimensions
60 * @brief Structure describes 2D rectangle (offset, extent)
71 * @brief Structure represents area of viewport
79 float minDepth = 0.0f;
80 float maxDepth = 0.0f;
84 * @brief Describes vertex attribute input rate
86 enum class VertexInputRate
88 PER_VERTEX, ///< Attribute read per vertex
89 PER_INSTANCE ///< Attribute read per instance
93 * @brief Vertex input format
95 * When UNDEFINED, the reflection is used to determine what
96 * the actual format is.
98 enum class VertexInputFormat
112 * @brief Logic operators used by color blending state
113 * when logicOpEnable is set.
136 * @brief Blend factors
138 enum class BlendFactor
143 ONE_MINUS_SRC_COLOR = 3,
145 ONE_MINUS_DST_COLOR = 5,
147 ONE_MINUS_SRC_ALPHA = 7,
149 ONE_MINUS_DST_ALPHA = 9,
151 ONE_MINUS_CONSTANT_COLOR = 11,
153 ONE_MINUS_CONSTANT_ALPHA = 13,
154 SRC_ALPHA_SATURATE = 14,
156 ONE_MINUS_SRC1_COLOR = 16,
158 ONE_MINUS_SRC1_ALPHA = 18,
162 * @brief Blend operators
168 REVERSE_SUBTRACT = 2,
188 const BlendOp ADVANCED_BLEND_OPTIONS_START(BlendOp::MULTIPLY);
191 * @brief Compare operators
206 * @brief Stencil operators
221 * @brief Backface culling modes
232 * @brief Polygon drawing modes
234 enum class PolygonMode
242 * @brief Front face direction
251 * @brief Primitive geometry topology
253 enum class PrimitiveTopology
265 * @brief Sampler address ( wrapping ) mode
267 enum class SamplerAddressMode
277 * @brief Filtering mode
279 enum class SamplerFilter
288 enum class SamplerMipmapMode
296 * @brief Describes pipeline's color blend state
298 struct ColorBlendState
300 bool logicOpEnable = false;
301 LogicOp logicOp = {};
302 float blendConstants[4] = {0.0f, 0.0f, 0.0f, 0.0f};
303 bool blendEnable = false;
304 BlendFactor srcColorBlendFactor = BlendFactor::ZERO;
305 BlendFactor dstColorBlendFactor = BlendFactor::ZERO;
306 BlendOp colorBlendOp = {};
307 BlendFactor srcAlphaBlendFactor = BlendFactor::ZERO;
308 BlendFactor dstAlphaBlendFactor = BlendFactor::ZERO;
309 BlendOp alphaBlendOp = {};
310 uint32_t colorComponentWriteBits = {0u};
312 auto& SetLogicOpEnable(bool value)
314 logicOpEnable = value;
318 auto& SetLogicOp(LogicOp value)
324 auto& SetBlendConstants(float value[4])
326 std::copy(value, value + 4, blendConstants);
330 auto& SetBlendEnable(bool value)
336 auto& SetSrcColorBlendFactor(BlendFactor value)
338 srcColorBlendFactor = value;
342 auto& SetDstColorBlendFactor(BlendFactor value)
344 dstColorBlendFactor = value;
348 auto& SetColorBlendOp(BlendOp value)
350 colorBlendOp = value;
354 auto& SetSrcAlphaBlendFactor(BlendFactor value)
356 srcAlphaBlendFactor = value;
360 auto& SetDstAlphaBlendFactor(BlendFactor value)
362 dstAlphaBlendFactor = value;
366 auto& SetAlphaBlendOp(BlendOp value)
368 alphaBlendOp = value;
372 auto& SetColorComponentsWriteBits(uint32_t value)
374 colorComponentWriteBits = value;
380 * @brief Program State
384 const Program* program{nullptr};
386 auto& SetProgram(const Program& value)
394 * @brief Framebuffer state.
396 struct FramebufferState
398 const Framebuffer* framebuffer{nullptr};
400 auto& SetFramebuffer(const Framebuffer& value)
402 framebuffer = &value;
408 * @brief Describes pipeline's viewport and scissor state
412 Viewport viewport{0.0, 0.0, 0.0, 0.0};
413 Rect2D scissor{0, 0, 0, 0};
414 bool scissorTestEnable{false};
416 auto& SetViewport(const Viewport& value)
422 auto& SetScissor(const Rect2D& value)
428 auto& SetScissorTestEnable(bool value)
430 scissorTestEnable = value;
436 * @brief Describes stencil operation state
438 struct StencilOpState
442 StencilOp depthFailOp{};
443 CompareOp compareOp{};
444 uint32_t compareMask{0u};
445 uint32_t writeMask{0u};
446 uint32_t reference{0u};
448 auto& SetFailOp(StencilOp value)
454 auto& SetPassOp(StencilOp value)
460 auto& SetDepthFailOp(StencilOp value)
466 auto& SetCompareOp(CompareOp value)
472 auto& SetCompareMask(uint32_t value)
478 auto& SetWriteMask(uint32_t value)
484 auto& SetReference(uint32_t value)
492 * @brief Describes pipeline's viewport and scissor state
494 struct DepthStencilState
496 bool depthTestEnable{false};
497 bool depthWriteEnable{false};
498 CompareOp depthCompareOp{};
500 bool stencilTestEnable{false};
501 StencilOpState front{};
502 StencilOpState back{};
504 auto& SetDepthTestEnable(bool value)
506 depthTestEnable = value;
510 auto& SetDepthWriteEnable(bool value)
512 depthWriteEnable = value;
516 auto& SetDepthCompareOp(CompareOp value)
518 depthCompareOp = value;
522 auto& SetFront(StencilOpState value)
528 auto& SetBack(StencilOpState value)
534 auto& SetStencilTestEnable(bool value)
536 stencilTestEnable = value;
542 * @brief Rasterization state descriptor
544 struct RasterizationState
547 PolygonMode polygonMode{};
548 FrontFace frontFace{};
550 auto& SetCullMode(CullMode value)
556 auto& SetPolygonMode(PolygonMode value)
562 auto& SetFrontFace(FrontFace value)
570 * @brief Input assembly state descriptor.
572 * Structure describes the topology for submitted
575 struct InputAssemblyState
577 PrimitiveTopology topology{};
578 bool primitiveRestartEnable{true};
580 auto& SetTopology(PrimitiveTopology value)
586 auto& SetPrimitiveRestartEnable(bool value)
588 primitiveRestartEnable = true;
594 * @brief Pipeline dynamic state bits
596 namespace PipelineDynamicStateBits
598 const uint32_t VIEWPORT_BIT = 1 << 0;
599 const uint32_t SCISSOR_BIT = 1 << 1;
600 const uint32_t LINE_WIDTH_BIT = 1 << 2;
601 const uint32_t DEPTH_BIAS_BIT = 1 << 3;
602 const uint32_t BLEND_CONSTANTS_BIT = 1 << 4;
603 const uint32_t DEPTH_BOUNDS_BIT = 1 << 5;
604 const uint32_t STENCIL_COMPARE_MASK_BIT = 1 << 6;
605 const uint32_t STENCIL_WRITE_MASK_BIT = 1 << 7;
606 const uint32_t STENCIL_REFERENCE_BIT = 1 << 8;
607 } // namespace PipelineDynamicStateBits
609 const uint32_t PIPELINE_DYNAMIC_STATE_COUNT(9u);
611 using PipelineDynamicStateMask = uint32_t;
614 * @brief Structure describes vertex input state of the pipeline.
615 * It specifies buffer binding and attribute format to be used.
617 struct VertexInputState
619 VertexInputState() = default;
622 * @brief Vertex buffer binding
626 Binding(uint32_t _stride, VertexInputRate _inputRate)
628 inputRate(_inputRate)
632 VertexInputRate inputRate;
636 * @brief Attribute description
640 Attribute(uint32_t _location, uint32_t _binding, uint32_t _offset, VertexInputFormat _format)
641 : location(_location),
651 VertexInputFormat format;
654 VertexInputState(std::vector<Binding> _bufferBindings, std::vector<Attribute> _attributes)
655 : bufferBindings(std::move(_bufferBindings)),
656 attributes(std::move(_attributes))
660 std::vector<Binding> bufferBindings{};
661 std::vector<Attribute> attributes{};
665 * @brief List of all possible formats
666 * Not all formats may be supported
671 // GLES compatible, luminance doesn't exist in Vulkan
677 R4G4B4A4_UNORM_PACK16,
678 B4G4R4A4_UNORM_PACK16,
681 R5G5B5A1_UNORM_PACK16,
682 B5G5R5A1_UNORM_PACK16,
683 A1R5G5B5_UNORM_PACK16,
726 A8B8G8R8_UNORM_PACK32,
727 A8B8G8R8_SNORM_PACK32,
728 A8B8G8R8_USCALED_PACK32,
729 A8B8G8R8_SSCALED_PACK32,
730 A8B8G8R8_UINT_PACK32,
731 A8B8G8R8_SINT_PACK32,
732 A8B8G8R8_SRGB_PACK32,
733 A2R10G10B10_UNORM_PACK32,
734 A2R10G10B10_SNORM_PACK32,
735 A2R10G10B10_USCALED_PACK32,
736 A2R10G10B10_SSCALED_PACK32,
737 A2R10G10B10_UINT_PACK32,
738 A2R10G10B10_SINT_PACK32,
739 A2B10G10R10_UNORM_PACK32,
740 A2B10G10R10_SNORM_PACK32,
741 A2B10G10R10_USCALED_PACK32,
742 A2B10G10R10_SSCALED_PACK32,
743 A2B10G10R10_UINT_PACK32,
744 A2B10G10R10_SINT_PACK32,
768 R16G16B16A16_USCALED,
769 R16G16B16A16_SSCALED,
797 R11G11B10_UFLOAT_PACK32,
798 B10G11R11_UFLOAT_PACK32,
799 E5B9G9R9_UFLOAT_PACK32,
809 BC1_RGBA_UNORM_BLOCK,
823 ETC2_R8G8B8_UNORM_BLOCK,
824 ETC2_R8G8B8_SRGB_BLOCK,
825 ETC2_R8G8B8A1_UNORM_BLOCK,
826 ETC2_R8G8B8A1_SRGB_BLOCK,
827 ETC2_R8G8B8A8_UNORM_BLOCK,
828 ETC2_R8G8B8A8_SRGB_BLOCK,
831 EAC_R11G11_UNORM_BLOCK,
832 EAC_R11G11_SNORM_BLOCK,
833 ASTC_4x4_UNORM_BLOCK,
835 ASTC_5x4_UNORM_BLOCK,
837 ASTC_5x5_UNORM_BLOCK,
839 ASTC_6x5_UNORM_BLOCK,
841 ASTC_6x6_UNORM_BLOCK,
843 ASTC_8x5_UNORM_BLOCK,
845 ASTC_8x6_UNORM_BLOCK,
847 ASTC_8x8_UNORM_BLOCK,
849 ASTC_10x5_UNORM_BLOCK,
850 ASTC_10x5_SRGB_BLOCK,
851 ASTC_10x6_UNORM_BLOCK,
852 ASTC_10x6_SRGB_BLOCK,
853 ASTC_10x8_UNORM_BLOCK,
854 ASTC_10x8_SRGB_BLOCK,
855 ASTC_10x10_UNORM_BLOCK,
856 ASTC_10x10_SRGB_BLOCK,
857 ASTC_12x10_UNORM_BLOCK,
858 ASTC_12x10_SRGB_BLOCK,
859 ASTC_12x12_UNORM_BLOCK,
860 ASTC_12x12_SRGB_BLOCK,
861 PVRTC1_2BPP_UNORM_BLOCK_IMG,
862 PVRTC1_4BPP_UNORM_BLOCK_IMG,
863 PVRTC2_2BPP_UNORM_BLOCK_IMG,
864 PVRTC2_4BPP_UNORM_BLOCK_IMG,
865 PVRTC1_2BPP_SRGB_BLOCK_IMG,
866 PVRTC1_4BPP_SRGB_BLOCK_IMG,
867 PVRTC2_2BPP_SRGB_BLOCK_IMG,
868 PVRTC2_4BPP_SRGB_BLOCK_IMG,
872 * @brief Flags specifying a buffer usage
874 enum class BufferUsage
876 TRANSFER_SRC = 1 << 0,
877 TRANSFER_DST = 1 << 1,
878 UNIFORM_TEXEL_BUFFER = 1 << 2,
879 STORAGE_TEXEL_BUFFER = 1 << 3,
880 UNIFORM_BUFFER = 1 << 4,
881 STORAGE_BUFFER = 1 << 5,
882 INDEX_BUFFER = 1 << 6,
883 VERTEX_BUFFER = 1 << 7,
884 INDIRECT_BUFFER = 1 << 8,
887 using BufferUsageFlags = uint32_t;
889 inline BufferUsageFlags operator|(BufferUsageFlags flags, BufferUsage usage)
891 flags |= static_cast<uint32_t>(usage);
896 * @brief Buffer property bits
898 * Use these bits to set BufferPropertiesFlags.
900 enum class BufferPropertiesFlagBit : uint32_t
902 CPU_ALLOCATED = 1 << 0, ///< Buffer is allocated on the CPU side
903 TRANSIENT_MEMORY = 1 << 1, ///< Buffer memory will be short-lived
907 * @brief BufferPropetiesFlags alters behaviour of implementation
909 using BufferPropertiesFlags = uint32_t;
911 inline BufferPropertiesFlags operator|(BufferPropertiesFlags flags, BufferPropertiesFlagBit usage)
913 flags |= static_cast<uint32_t>(usage);
918 * @brief The structure describes memory requirements of GPU resource (texture, buffer)
920 struct MemoryRequirements
926 using TextureUpdateFlags = uint32_t;
927 enum class TextureUpdateFlagBits
929 KEEP_SOURCE = 1 << 0,
933 * @brief Texture update info
935 * Describes the texture update to be executed by
936 * Controller::UpdateTextures()
938 struct TextureUpdateInfo
940 Texture* dstTexture{};
941 Offset2D dstOffset2D;
945 uint32_t srcReference{};
946 Extent2D srcExtent2D{};
947 uint32_t srcOffset{};
949 uint32_t srcStride{};
950 Format srcFormat{}; ///< Should match dstTexture's format, otherwise conversion may occur
954 * @brief Texture update source info
956 * Describes the source of data (memory, buffer or another texture)
957 * to be used when updating textures using Controller::UpdateTextures().
959 struct TextureUpdateSourceInfo
981 struct PixelDataSource
983 Dali::PixelData pixelData;
993 * @brief Properties of texture
995 struct TextureProperties
997 Format format; ///< Texture format
998 Format format1; ///< Texture format (if emulated)
999 bool emulated; ///< Format is emulated (for example RGB as RGBA)
1000 bool compressed; ///< Texture is compressed
1001 bool packed; ///< Texture is packed
1002 Extent2D extent2D; ///< Size of texture
1003 bool directWriteAccessEnabled; ///< Direct write access (mappable textures)
1004 uint32_t nativeHandle; ///< Native texture handle
1008 * @brief Texture tiling that directly refers to the tiling
1009 * mode supported by the Vulkan. Other implementations
1010 * of the backend may ignore the value.
1012 enum class TextureTiling
1019 * @brief Texture color attachment used by FramebufferCreateInfo
1021 struct ColorAttachment
1023 uint32_t attachmentId;
1030 * @brief Depth stencil attachment used by FramebufferCreateInfo
1032 struct DepthStencilAttachment
1036 WRITE, // If no texture, will create a RenderBuffer instead
1037 NONE // If no attachment/RenderBuffer required
1039 Texture* depthTexture{nullptr};
1040 Texture* stencilTexture{nullptr};
1041 uint32_t depthLevel{0};
1042 uint32_t stencilLevel{0};
1043 Usage depthUsage{Usage::NONE};
1044 Usage stencilUsage{Usage::NONE};
1048 * @brief Submit flags
1050 using SubmitFlags = uint32_t;
1055 enum class SubmitFlagBits : uint32_t
1057 FLUSH = 1 << 0, // Flush immediately
1058 DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
1061 template<typename T>
1062 inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
1064 return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
1068 * @brief Describes command buffers submission
1072 std::vector<CommandBuffer*> cmdBuffer;
1077 * @brief Shader language enum
1079 enum class ShaderLanguage
1089 * @brief Pipeline stages
1091 enum class PipelineStage
1098 TESSELATION_CONTROL,
1099 TESSELATION_EVALUATION,
1104 * @brief Vertex attribute format
1106 * TODO: to be replaced with Format
1108 enum class VertexInputAttributeFormat
1119 * @brief Uniform class
1121 enum class UniformClass
1125 COMBINED_IMAGE_SAMPLER,
1132 * @brief Type of texture
1134 enum class TextureType
1142 * @brief The information of the uniform
1146 std::string name{""};
1147 UniformClass uniformClass{UniformClass::UNDEFINED};
1148 uint32_t binding{0u};
1149 uint32_t bufferIndex{0u};
1150 uint32_t offset{0u};
1151 uint32_t location{0u};
1153 bool operator==(const UniformInfo& rhs)
1155 return name == rhs.name &&
1156 uniformClass == rhs.uniformClass &&
1157 binding == rhs.binding &&
1158 bufferIndex == rhs.bufferIndex &&
1159 offset == rhs.offset &&
1160 location == rhs.location;
1165 * @brief The information of the uniform block
1167 struct UniformBlockInfo
1169 std::string name{""};
1170 uint32_t descriptorSet{0u};
1171 uint32_t binding{0u};
1173 std::vector<UniformInfo> members{};
1177 * @brief Describes pipeline's shading stages
1179 * Shader state binds shader and pipeline stage that the
1180 * shader will be executed. The shader may be created with
1181 * pipeline stage and the pipelineStage member may be ignored
1182 * by setting inheritPipelineStage to true.
1186 const Shader* shader{nullptr}; // shader to attach
1187 PipelineStage pipelineStage{}; // pipeline stage to execute the shader
1188 bool inheritPipelineStage{false}; // stage inheritance
1190 auto& SetShader(const Shader& value)
1196 auto& SetPipelineStage(PipelineStage value)
1198 pipelineStage = value;
1202 auto& SetInheritPipelineStage(bool value)
1204 inheritPipelineStage = value;
1210 * @brief Flag determining usage of texture
1212 using TextureUsageFlags = uint32_t;
1213 enum class TextureUsageFlagBits : uint32_t
1216 COLOR_ATTACHMENT = 1 << 1,
1217 DEPTH_STENCIL_ATTACHMENT = 1 << 2,
1221 template<typename T>
1222 inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
1224 return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
1227 using TextureFormat = Dali::Graphics::Format;
1230 * @brief Texture mipmap disable/enable enum
1232 enum class TextureMipMapFlag
1239 * @brief Depth/stencil attachment flag
1241 enum class TextureDepthStencilFlag
1250 * @brief Layout of texture
1252 * Specifies how the memory will be allocated, organized and accessed.
1254 enum class TextureLayout
1256 LINEAR, ///< Creates linear memory, mapping possible
1257 OPTIMAL ///< Usually, read-only memory, driver-optimal layout
1261 * @brief Level of command buffer
1263 enum class CommandBufferLevel
1265 PRIMARY, ///< Primary buffer can be executed on its own
1266 SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
1270 * @brief Enum indicating whether shader source
1271 * is text-based or binary.
1273 enum class ShaderSourceMode
1280 * @brief Memory usage flags to be set when mapping the buffer
1282 using MemoryUsageFlags = uint32_t;
1283 enum class MemoryUsageFlagBits : uint32_t
1287 PERSISTENT = 1 << 2,
1288 ASYNCHRONOUS = 1 << 3,
1292 template<typename T>
1293 inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
1295 return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
1299 * @brief Describes buffer mapping details
1301 struct MapBufferInfo
1304 MemoryUsageFlags usage;
1310 * @brief Describes buffer mapping details
1311 * TODO: mapping by texture level and layer
1313 struct MapTextureInfo
1316 MemoryUsageFlags usage;
1322 * @brief GraphicsStructureType enum is used by all create info structures
1323 * in order to identify by the implementation which structure it is
1326 enum class GraphicsStructureType : uint32_t
1328 BUFFER_CREATE_INFO_STRUCT,
1329 COMMAND_BUFFER_CREATE_INFO_STRUCT,
1330 FRAMEBUFFER_CREATE_INFO_STRUCT,
1331 PROGRAM_CREATE_INFO_STRUCT,
1332 PIPELINE_CREATE_INFO_STRUCT,
1333 RENDERPASS_CREATE_INFO_STRUCT,
1334 SAMPLER_CREATE_INFO_STRUCT,
1335 SHADER_CREATE_INFO_STRUCT,
1336 TEXTURE_CREATE_INFO_STRUCT,
1337 RENDER_TARGET_CREATE_INFO_STRUCT,
1338 SYNC_OBJECT_CREATE_INFO_STRUCT
1342 * @brief Enum describes load operation associated
1343 * with particular framebuffer attachment
1345 enum class AttachmentLoadOp
1347 LOAD, ///< Load previous content
1348 CLEAR, ///< Clear the attachment
1349 DONT_CARE ///< Let driver decide
1353 * @brief Enum describes store operation associated
1354 * with particular framebuffer attachment
1356 enum class AttachmentStoreOp
1358 STORE, ///< Store content (color attachemnts)
1359 DONT_CARE ///< Let driver decide (depth/stencil attachemnt with no intention of reading)
1363 * @brief The structure describes the read/write
1364 * modes of a single framebuffer attachment
1366 * The attachment description specifies what is going to
1367 * happen to the attachment at the beginning and end of the
1370 * The stencil operation is separated as it may be set
1371 * independent from the depth component (use loadOp, storeOp
1372 * to set up the depth component and stencilLoadOp, stencilStoreOp
1373 * for stencil component).
1375 struct AttachmentDescription
1378 * @brief Sets load operation for the attachment
1380 * @param value Load operation
1381 * @return this structure
1383 auto& SetLoadOp(AttachmentLoadOp value)
1390 * @brief Sets store operation for the attachment
1392 * @param value Store operation
1393 * @return this structure
1395 auto& SetStoreOp(AttachmentStoreOp value)
1402 * @brief Sets load operation for the stencil part of attachment
1404 * @param value load operation
1405 * @return this structure
1407 auto& SetStencilLoadOp(AttachmentLoadOp value)
1409 stencilLoadOp = value;
1414 * @brief Sets store operation for the stencil part of attachment
1416 * @param value store operation
1417 * @return this structure
1419 auto& SetStencilStoreOp(AttachmentStoreOp value)
1421 stencilStoreOp = value;
1425 AttachmentLoadOp loadOp{};
1426 AttachmentStoreOp storeOp{};
1427 AttachmentLoadOp stencilLoadOp{};
1428 AttachmentStoreOp stencilStoreOp{};
1432 * @brief Helper function to be used by the extension developers
1434 * The value of custom type must be unique and recognizable by the
1437 * @param customValue Custom value of GraphicsStructureType
1438 * @return Integer converted to GraphicsStructureType
1440 inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
1442 return static_cast<GraphicsStructureType>(customValue);
1446 * @brief The allocation callbacks may be passed when the object is created.
1448 struct AllocationCallbacks
1450 void* userData = nullptr; ///< User data passed to the allocator
1451 void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
1452 void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
1453 void (*freeCallback)(void* memory, void* userData) = nullptr;
1457 * @brief The ExtensionCreateInfo structure should be a base of any
1458 * extension create info structure. The structure isn't virtual
1459 * so the implementation must prevent slicing it.
1461 struct ExtensionCreateInfo
1463 GraphicsStructureType type{};
1464 ExtensionCreateInfo* nextExtension{};
1468 * @brief Default deleter for graphics unique pointers
1470 * Returned unique_ptr may require custom deleter. To get it working
1471 * with std::unique_ptr the custom type is used with polymorphic deleter
1474 struct DefaultDeleter
1476 DefaultDeleter() = default;
1479 * @brief Conversion constructor
1481 * This constructor will set the lambda for type passed
1484 template<class P, template<typename> typename U>
1485 DefaultDeleter(const U<P>& deleter)
1487 deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
1491 * @brief Conversion constructor from DefaultDelete<P>
1493 * This constructor transfers deleteFunction only
1496 explicit DefaultDeleter(const DefaultDeleter<P>& deleter)
1498 deleteFunction = decltype(deleteFunction)(deleter.deleteFunction);
1502 * @brief Default deleter
1504 * Default deleter will use standard 'delete' call in order
1505 * to discard graphics objects unless a custom deleter was
1508 * @param[in] object Object to delete
1510 void operator()(T* object)
1514 deleteFunction(object);
1522 void (*deleteFunction)(T* object){nullptr}; ///< Custom delete function
1526 * Surface type is just a void* to any native object.
1528 using Surface = void;
1531 * @brief Enum describing preTransform of render target
1533 enum class RenderTargetTransformFlagBits
1535 TRANSFORM_IDENTITY_BIT = 0x00000001,
1536 ROTATE_90_BIT = 0x00000002,
1537 ROTATE_180_BIT = 0x00000004,
1538 ROTATE_270_BIT = 0x00000008,
1539 HORIZONTAL_MIRROR_BIT = 0x00000010,
1540 HORIZONTAL_MIRROR_ROTATE_90_BIT = 0x00000020,
1541 HORIZONTAL_MIRROR_ROTATE_180_BIT = 0x00000040,
1542 HORIZONTAL_MIRROR_ROTATE_270_BIT = 0x00000080,
1545 using RenderTargetTransformFlags = uint32_t;
1547 template<typename T>
1548 inline RenderTargetTransformFlags operator|(T flags, RenderTargetTransformFlagBits bit)
1550 return static_cast<RenderTargetTransformFlags>(flags) | static_cast<RenderTargetTransformFlags>(bit);
1554 * unique_ptr defined in the Graphics scope
1556 template<class T, class D = DefaultDeleter<T>>
1557 using UniquePtr = std::unique_ptr<T, D>;
1560 * @brief MakeUnique<> version that returns Graphics::UniquePtr
1561 * @param[in] args Arguments for construction
1564 template<class T, class Deleter = DefaultDeleter<T>, class... Args>
1565 std::enable_if_t<!std::is_array<T>::value, Graphics::UniquePtr<T>>
1566 MakeUnique(Args&&... args)
1568 return UniquePtr<T>(new T(std::forward<Args>(args)...), Deleter());
1571 } // namespace Graphics
1574 #endif //DALI_GRAPHICS_API_TYPES_H