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;
633 //@todo Add actual rate...
637 * @brief Attribute description
641 Attribute(uint32_t _location, uint32_t _binding, uint32_t _offset, VertexInputFormat _format)
642 : location(_location),
652 VertexInputFormat format;
655 VertexInputState(std::vector<Binding> _bufferBindings, std::vector<Attribute> _attributes)
656 : bufferBindings(std::move(_bufferBindings)),
657 attributes(std::move(_attributes))
661 std::vector<Binding> bufferBindings{};
662 std::vector<Attribute> attributes{};
666 * @brief List of all possible formats
667 * Not all formats may be supported
672 // GLES compatible, luminance doesn't exist in Vulkan
678 R4G4B4A4_UNORM_PACK16,
679 B4G4R4A4_UNORM_PACK16,
682 R5G5B5A1_UNORM_PACK16,
683 B5G5R5A1_UNORM_PACK16,
684 A1R5G5B5_UNORM_PACK16,
727 A8B8G8R8_UNORM_PACK32,
728 A8B8G8R8_SNORM_PACK32,
729 A8B8G8R8_USCALED_PACK32,
730 A8B8G8R8_SSCALED_PACK32,
731 A8B8G8R8_UINT_PACK32,
732 A8B8G8R8_SINT_PACK32,
733 A8B8G8R8_SRGB_PACK32,
734 A2R10G10B10_UNORM_PACK32,
735 A2R10G10B10_SNORM_PACK32,
736 A2R10G10B10_USCALED_PACK32,
737 A2R10G10B10_SSCALED_PACK32,
738 A2R10G10B10_UINT_PACK32,
739 A2R10G10B10_SINT_PACK32,
740 A2B10G10R10_UNORM_PACK32,
741 A2B10G10R10_SNORM_PACK32,
742 A2B10G10R10_USCALED_PACK32,
743 A2B10G10R10_SSCALED_PACK32,
744 A2B10G10R10_UINT_PACK32,
745 A2B10G10R10_SINT_PACK32,
769 R16G16B16A16_USCALED,
770 R16G16B16A16_SSCALED,
798 R11G11B10_UFLOAT_PACK32,
799 B10G11R11_UFLOAT_PACK32,
800 E5B9G9R9_UFLOAT_PACK32,
810 BC1_RGBA_UNORM_BLOCK,
824 ETC2_R8G8B8_UNORM_BLOCK,
825 ETC2_R8G8B8_SRGB_BLOCK,
826 ETC2_R8G8B8A1_UNORM_BLOCK,
827 ETC2_R8G8B8A1_SRGB_BLOCK,
828 ETC2_R8G8B8A8_UNORM_BLOCK,
829 ETC2_R8G8B8A8_SRGB_BLOCK,
832 EAC_R11G11_UNORM_BLOCK,
833 EAC_R11G11_SNORM_BLOCK,
834 ASTC_4x4_UNORM_BLOCK,
836 ASTC_5x4_UNORM_BLOCK,
838 ASTC_5x5_UNORM_BLOCK,
840 ASTC_6x5_UNORM_BLOCK,
842 ASTC_6x6_UNORM_BLOCK,
844 ASTC_8x5_UNORM_BLOCK,
846 ASTC_8x6_UNORM_BLOCK,
848 ASTC_8x8_UNORM_BLOCK,
850 ASTC_10x5_UNORM_BLOCK,
851 ASTC_10x5_SRGB_BLOCK,
852 ASTC_10x6_UNORM_BLOCK,
853 ASTC_10x6_SRGB_BLOCK,
854 ASTC_10x8_UNORM_BLOCK,
855 ASTC_10x8_SRGB_BLOCK,
856 ASTC_10x10_UNORM_BLOCK,
857 ASTC_10x10_SRGB_BLOCK,
858 ASTC_12x10_UNORM_BLOCK,
859 ASTC_12x10_SRGB_BLOCK,
860 ASTC_12x12_UNORM_BLOCK,
861 ASTC_12x12_SRGB_BLOCK,
862 PVRTC1_2BPP_UNORM_BLOCK_IMG,
863 PVRTC1_4BPP_UNORM_BLOCK_IMG,
864 PVRTC2_2BPP_UNORM_BLOCK_IMG,
865 PVRTC2_4BPP_UNORM_BLOCK_IMG,
866 PVRTC1_2BPP_SRGB_BLOCK_IMG,
867 PVRTC1_4BPP_SRGB_BLOCK_IMG,
868 PVRTC2_2BPP_SRGB_BLOCK_IMG,
869 PVRTC2_4BPP_SRGB_BLOCK_IMG,
873 * @brief Flags specifying a buffer usage
875 enum class BufferUsage
877 TRANSFER_SRC = 1 << 0,
878 TRANSFER_DST = 1 << 1,
879 UNIFORM_TEXEL_BUFFER = 1 << 2,
880 STORAGE_TEXEL_BUFFER = 1 << 3,
881 UNIFORM_BUFFER = 1 << 4,
882 STORAGE_BUFFER = 1 << 5,
883 INDEX_BUFFER = 1 << 6,
884 VERTEX_BUFFER = 1 << 7,
885 INDIRECT_BUFFER = 1 << 8,
888 using BufferUsageFlags = uint32_t;
890 inline BufferUsageFlags operator|(BufferUsageFlags flags, BufferUsage usage)
892 flags |= static_cast<uint32_t>(usage);
897 * @brief Buffer property bits
899 * Use these bits to set BufferPropertiesFlags.
901 enum class BufferPropertiesFlagBit : uint32_t
903 CPU_ALLOCATED = 1 << 0, ///< Buffer is allocated on the CPU side
904 TRANSIENT_MEMORY = 1 << 1, ///< Buffer memory will be short-lived
908 * @brief BufferPropetiesFlags alters behaviour of implementation
910 using BufferPropertiesFlags = uint32_t;
912 inline BufferPropertiesFlags operator|(BufferPropertiesFlags flags, BufferPropertiesFlagBit usage)
914 flags |= static_cast<uint32_t>(usage);
919 * @brief The structure describes memory requirements of GPU resource (texture, buffer)
921 struct MemoryRequirements
924 size_t alignment{1u};
927 using TextureUpdateFlags = uint32_t;
928 enum class TextureUpdateFlagBits
930 KEEP_SOURCE = 1 << 0,
934 * @brief Texture update info
936 * Describes the texture update to be executed by
937 * Controller::UpdateTextures()
939 struct TextureUpdateInfo
941 Texture* dstTexture{};
942 Offset2D dstOffset2D;
946 uint32_t srcReference{};
947 Extent2D srcExtent2D{};
948 uint32_t srcOffset{};
950 uint32_t srcStride{};
951 Format srcFormat{}; ///< Should match dstTexture's format, otherwise conversion may occur
955 * @brief Texture update source info
957 * Describes the source of data (memory, buffer or another texture)
958 * to be used when updating textures using Controller::UpdateTextures().
960 struct TextureUpdateSourceInfo
982 struct PixelDataSource
984 Dali::PixelData pixelData;
994 * @brief Properties of texture
996 struct TextureProperties
998 Format format; ///< Texture format
999 Format format1; ///< Texture format (if emulated)
1000 bool emulated; ///< Format is emulated (for example RGB as RGBA)
1001 bool compressed; ///< Texture is compressed
1002 bool packed; ///< Texture is packed
1003 Extent2D extent2D; ///< Size of texture
1004 bool directWriteAccessEnabled; ///< Direct write access (mappable textures)
1005 uint32_t nativeHandle; ///< Native texture handle
1009 * @brief Texture tiling that directly refers to the tiling
1010 * mode supported by the Vulkan. Other implementations
1011 * of the backend may ignore the value.
1013 enum class TextureTiling
1020 * @brief Texture color attachment used by FramebufferCreateInfo
1022 struct ColorAttachment
1024 uint32_t attachmentId;
1031 * @brief Depth stencil attachment used by FramebufferCreateInfo
1033 struct DepthStencilAttachment
1037 WRITE, // If no texture, will create a RenderBuffer instead
1038 NONE // If no attachment/RenderBuffer required
1040 Texture* depthTexture{nullptr};
1041 Texture* stencilTexture{nullptr};
1042 uint32_t depthLevel{0};
1043 uint32_t stencilLevel{0};
1044 Usage depthUsage{Usage::NONE};
1045 Usage stencilUsage{Usage::NONE};
1049 * @brief Submit flags
1051 using SubmitFlags = uint32_t;
1056 enum class SubmitFlagBits : uint32_t
1058 FLUSH = 1 << 0, // Flush immediately
1059 DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
1062 template<typename T>
1063 inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
1065 return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
1069 * @brief Describes command buffers submission
1073 std::vector<CommandBuffer*> cmdBuffer;
1078 * @brief Shader language enum
1080 enum class ShaderLanguage
1090 * @brief Pipeline stages
1092 enum class PipelineStage
1099 TESSELATION_CONTROL,
1100 TESSELATION_EVALUATION,
1105 * @brief Vertex attribute format
1107 * TODO: to be replaced with Format
1109 enum class VertexInputAttributeFormat
1120 * @brief Uniform class
1122 enum class UniformClass
1126 COMBINED_IMAGE_SAMPLER,
1133 * @brief Type of texture
1135 enum class TextureType
1143 * @brief The information of the uniform
1147 std::string name{""};
1148 UniformClass uniformClass{UniformClass::UNDEFINED};
1149 uint32_t binding{0u};
1150 uint32_t bufferIndex{0u};
1151 uint32_t offset{0u};
1152 uint32_t location{0u};
1153 uint32_t elementCount{0u};
1155 bool operator==(const UniformInfo& rhs)
1157 return name == rhs.name &&
1158 uniformClass == rhs.uniformClass &&
1159 binding == rhs.binding &&
1160 bufferIndex == rhs.bufferIndex &&
1161 offset == rhs.offset &&
1162 location == rhs.location &&
1163 elementCount == rhs.elementCount;
1168 * @brief The information of the uniform block
1170 struct UniformBlockInfo
1172 std::string name{""};
1173 uint32_t descriptorSet{0u};
1174 uint32_t binding{0u};
1176 std::vector<UniformInfo> members{};
1180 * @brief Describes pipeline's shading stages
1182 * Shader state binds shader and pipeline stage that the
1183 * shader will be executed. The shader may be created with
1184 * pipeline stage and the pipelineStage member may be ignored
1185 * by setting inheritPipelineStage to true.
1189 const Shader* shader{nullptr}; // shader to attach
1190 PipelineStage pipelineStage{}; // pipeline stage to execute the shader
1191 bool inheritPipelineStage{false}; // stage inheritance
1193 auto& SetShader(const Shader& value)
1199 auto& SetPipelineStage(PipelineStage value)
1201 pipelineStage = value;
1205 auto& SetInheritPipelineStage(bool value)
1207 inheritPipelineStage = value;
1213 * @brief Flag determining usage of texture
1215 using TextureUsageFlags = uint32_t;
1216 enum class TextureUsageFlagBits : uint32_t
1219 COLOR_ATTACHMENT = 1 << 1,
1220 DEPTH_STENCIL_ATTACHMENT = 1 << 2,
1224 template<typename T>
1225 inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
1227 return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
1230 using TextureFormat = Dali::Graphics::Format;
1233 * @brief Texture mipmap disable/enable enum
1235 enum class TextureMipMapFlag
1242 * @brief Depth/stencil attachment flag
1244 enum class TextureDepthStencilFlag
1253 * @brief Layout of texture
1255 * Specifies how the memory will be allocated, organized and accessed.
1257 enum class TextureLayout
1259 LINEAR, ///< Creates linear memory, mapping possible
1260 OPTIMAL ///< Usually, read-only memory, driver-optimal layout
1264 * @brief Level of command buffer
1266 enum class CommandBufferLevel
1268 PRIMARY, ///< Primary buffer can be executed on its own
1269 SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
1273 * @brief Enum indicating whether shader source
1274 * is text-based or binary.
1276 enum class ShaderSourceMode
1283 * @brief Memory usage flags to be set when mapping the buffer
1285 using MemoryUsageFlags = uint32_t;
1286 enum class MemoryUsageFlagBits : uint32_t
1290 PERSISTENT = 1 << 2,
1291 ASYNCHRONOUS = 1 << 3,
1295 template<typename T>
1296 inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
1298 return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
1302 * @brief Describes buffer mapping details
1304 struct MapBufferInfo
1307 MemoryUsageFlags usage;
1313 * @brief Describes buffer mapping details
1314 * TODO: mapping by texture level and layer
1316 struct MapTextureInfo
1319 MemoryUsageFlags usage;
1325 * @brief GraphicsStructureType enum is used by all create info structures
1326 * in order to identify by the implementation which structure it is
1329 enum class GraphicsStructureType : uint32_t
1331 BUFFER_CREATE_INFO_STRUCT,
1332 COMMAND_BUFFER_CREATE_INFO_STRUCT,
1333 FRAMEBUFFER_CREATE_INFO_STRUCT,
1334 PROGRAM_CREATE_INFO_STRUCT,
1335 PIPELINE_CREATE_INFO_STRUCT,
1336 RENDERPASS_CREATE_INFO_STRUCT,
1337 SAMPLER_CREATE_INFO_STRUCT,
1338 SHADER_CREATE_INFO_STRUCT,
1339 TEXTURE_CREATE_INFO_STRUCT,
1340 RENDER_TARGET_CREATE_INFO_STRUCT,
1341 SYNC_OBJECT_CREATE_INFO_STRUCT
1345 * @brief Enum describes load operation associated
1346 * with particular framebuffer attachment
1348 enum class AttachmentLoadOp
1350 LOAD, ///< Load previous content
1351 CLEAR, ///< Clear the attachment
1352 DONT_CARE ///< Let driver decide
1356 * @brief Enum describes store operation associated
1357 * with particular framebuffer attachment
1359 enum class AttachmentStoreOp
1361 STORE, ///< Store content (color attachemnts)
1362 DONT_CARE ///< Let driver decide (depth/stencil attachemnt with no intention of reading)
1366 * @brief The structure describes the read/write
1367 * modes of a single framebuffer attachment
1369 * The attachment description specifies what is going to
1370 * happen to the attachment at the beginning and end of the
1373 * The stencil operation is separated as it may be set
1374 * independent from the depth component (use loadOp, storeOp
1375 * to set up the depth component and stencilLoadOp, stencilStoreOp
1376 * for stencil component).
1378 struct AttachmentDescription
1381 * @brief Sets load operation for the attachment
1383 * @param value Load operation
1384 * @return this structure
1386 auto& SetLoadOp(AttachmentLoadOp value)
1393 * @brief Sets store operation for the attachment
1395 * @param value Store operation
1396 * @return this structure
1398 auto& SetStoreOp(AttachmentStoreOp value)
1405 * @brief Sets load operation for the stencil part of attachment
1407 * @param value load operation
1408 * @return this structure
1410 auto& SetStencilLoadOp(AttachmentLoadOp value)
1412 stencilLoadOp = value;
1417 * @brief Sets store operation for the stencil part of attachment
1419 * @param value store operation
1420 * @return this structure
1422 auto& SetStencilStoreOp(AttachmentStoreOp value)
1424 stencilStoreOp = value;
1428 AttachmentLoadOp loadOp{};
1429 AttachmentStoreOp storeOp{};
1430 AttachmentLoadOp stencilLoadOp{};
1431 AttachmentStoreOp stencilStoreOp{};
1435 * @brief Helper function to be used by the extension developers
1437 * The value of custom type must be unique and recognizable by the
1440 * @param customValue Custom value of GraphicsStructureType
1441 * @return Integer converted to GraphicsStructureType
1443 inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
1445 return static_cast<GraphicsStructureType>(customValue);
1449 * @brief The allocation callbacks may be passed when the object is created.
1451 struct AllocationCallbacks
1453 void* userData = nullptr; ///< User data passed to the allocator
1454 void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
1455 void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
1456 void (*freeCallback)(void* memory, void* userData) = nullptr;
1460 * @brief The ExtensionCreateInfo structure should be a base of any
1461 * extension create info structure. The structure isn't virtual
1462 * so the implementation must prevent slicing it.
1464 struct ExtensionCreateInfo
1466 GraphicsStructureType type{};
1467 ExtensionCreateInfo* nextExtension{};
1471 * @brief Default deleter for graphics unique pointers
1473 * Returned unique_ptr may require custom deleter. To get it working
1474 * with std::unique_ptr the custom type is used with polymorphic deleter
1477 struct DefaultDeleter
1479 DefaultDeleter() = default;
1482 * @brief Conversion constructor
1484 * This constructor will set the lambda for type passed
1487 template<class P, template<typename> typename U>
1488 DefaultDeleter(const U<P>& deleter)
1490 deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
1494 * @brief Conversion constructor from DefaultDelete<P>
1496 * This constructor transfers deleteFunction only
1499 explicit DefaultDeleter(const DefaultDeleter<P>& deleter)
1501 deleteFunction = decltype(deleteFunction)(deleter.deleteFunction);
1505 * @brief Default deleter
1507 * Default deleter will use standard 'delete' call in order
1508 * to discard graphics objects unless a custom deleter was
1511 * @param[in] object Object to delete
1513 void operator()(T* object)
1517 deleteFunction(object);
1525 void (*deleteFunction)(T* object){nullptr}; ///< Custom delete function
1529 * Surface type is just a void* to any native object.
1531 using Surface = void;
1534 * @brief Enum describing preTransform of render target
1536 enum class RenderTargetTransformFlagBits
1538 TRANSFORM_IDENTITY_BIT = 0x00000001,
1539 ROTATE_90_BIT = 0x00000002,
1540 ROTATE_180_BIT = 0x00000004,
1541 ROTATE_270_BIT = 0x00000008,
1542 HORIZONTAL_MIRROR_BIT = 0x00000010,
1543 HORIZONTAL_MIRROR_ROTATE_90_BIT = 0x00000020,
1544 HORIZONTAL_MIRROR_ROTATE_180_BIT = 0x00000040,
1545 HORIZONTAL_MIRROR_ROTATE_270_BIT = 0x00000080,
1548 using RenderTargetTransformFlags = uint32_t;
1550 template<typename T>
1551 inline RenderTargetTransformFlags operator|(T flags, RenderTargetTransformFlagBits bit)
1553 return static_cast<RenderTargetTransformFlags>(flags) | static_cast<RenderTargetTransformFlags>(bit);
1557 * unique_ptr defined in the Graphics scope
1559 template<class T, class D = DefaultDeleter<T>>
1560 using UniquePtr = std::unique_ptr<T, D>;
1563 * @brief MakeUnique<> version that returns Graphics::UniquePtr
1564 * @param[in] args Arguments for construction
1567 template<class T, class Deleter = DefaultDeleter<T>, class... Args>
1568 std::enable_if_t<!std::is_array<T>::value, Graphics::UniquePtr<T>>
1569 MakeUnique(Args&&... args)
1571 return UniquePtr<T>(new T(std::forward<Args>(args)...), Deleter());
1574 } // namespace Graphics
1577 #endif //DALI_GRAPHICS_API_TYPES_H