1 #ifndef DALI_GRAPHICS_API_TYPES
2 #define DALI_GRAPHICS_API_TYPES
5 * Copyright (c) 2021 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.
39 * @brief Structure describes 2D offset
48 * @brief Structure describes 2D dimensions
57 * @brief Structure describes 2D rectangle (offset, extent)
68 * @brief Structure represents area of viewport
76 float minDepth = 0.0f;
77 float maxDepth = 0.0f;
81 * @brief Describes vertex attribute input rate
83 enum class VertexInputRate
85 PER_VERTEX, ///< Attribute read per vertex
86 PER_INSTANCE ///< Attribute read per instance
90 * @brief Vertex input format
92 * When UNDEFINED, the reflection is used to determine what
93 * the actual format is.
95 enum class VertexInputFormat
109 * @brief Logic operators used by color blending state
110 * when logicOpEnable is set.
133 * @brief Blend factors
135 enum class BlendFactor
140 ONE_MINUS_SRC_COLOR = 3,
142 ONE_MINUS_DST_COLOR = 5,
144 ONE_MINUS_SRC_ALPHA = 7,
146 ONE_MINUS_DST_ALPHA = 9,
148 ONE_MINUS_CONSTANT_COLOR = 11,
150 ONE_MINUS_CONSTANT_ALPHA = 13,
151 SRC_ALPHA_SATURATE = 14,
153 ONE_MINUS_SRC1_COLOR = 16,
155 ONE_MINUS_SRC1_ALPHA = 18,
159 * @brief Blend operators
165 REVERSE_SUBTRACT = 2,
185 const BlendOp ADVANCED_BLEND_OPTIONS_START(BlendOp::MULTIPLY);
188 * @brief Compare operators
203 * @brief Stencil operators
218 * @brief Backface culling modes
229 * @brief Polygon drawing modes
231 enum class PolygonMode
239 * @brief Front face direction
248 * @brief Primitive geometry topology
250 enum class PrimitiveTopology
262 * @brief Sampler address ( wrapping ) mode
264 enum class SamplerAddressMode
274 * @brief Filtering mode
276 enum class SamplerFilter
285 enum class SamplerMipmapMode
293 * @brief Describes pipeline's color blend state
295 struct ColorBlendState
297 bool logicOpEnable = false;
298 LogicOp logicOp = {};
299 float blendConstants[4] = {0.0f, 0.0f, 0.0f, 0.0f};
300 bool blendEnable = false;
301 BlendFactor srcColorBlendFactor = BlendFactor::ZERO;
302 BlendFactor dstColorBlendFactor = BlendFactor::ZERO;
303 BlendOp colorBlendOp = {};
304 BlendFactor srcAlphaBlendFactor = BlendFactor::ZERO;
305 BlendFactor dstAlphaBlendFactor = BlendFactor::ZERO;
306 BlendOp alphaBlendOp = {};
307 uint32_t colorComponentWriteBits = {0u};
309 auto& SetLogicOpEnable(bool value)
311 logicOpEnable = value;
315 auto& SetLogicOp(LogicOp value)
321 auto& SetBlendConstants(float value[4])
323 std::copy(value, value + 4, blendConstants);
327 auto& SetBlendEnable(bool value)
333 auto& SetSrcColorBlendFactor(BlendFactor value)
335 srcColorBlendFactor = value;
339 auto& SetDstColorBlendFactor(BlendFactor value)
341 dstColorBlendFactor = value;
345 auto& SetColorBlendOp(BlendOp value)
347 colorBlendOp = value;
351 auto& SetSrcAlphaBlendFactor(BlendFactor value)
353 srcAlphaBlendFactor = value;
357 auto& SetDstAlphaBlendFactor(BlendFactor value)
359 dstAlphaBlendFactor = value;
363 auto& SetAlphaBlendOp(BlendOp value)
365 alphaBlendOp = value;
369 auto& SetColorComponentsWriteBits(uint32_t value)
371 colorComponentWriteBits = value;
377 * @brief Program State
381 const Program* program{nullptr};
383 auto& SetProgram(const Program& value)
391 * @brief Framebuffer state.
393 struct FramebufferState
395 const Framebuffer* framebuffer{nullptr};
397 auto& SetFramebuffer(const Framebuffer& value)
399 framebuffer = &value;
405 * @brief Describes pipeline's viewport and scissor state
409 Viewport viewport{0.0, 0.0, 0.0, 0.0};
410 Rect2D scissor{0, 0, 0, 0};
411 bool scissorTestEnable{false};
413 auto& SetViewport(const Viewport& value)
419 auto& SetScissor(const Rect2D& value)
425 auto& SetScissorTestEnable(bool value)
427 scissorTestEnable = value;
433 * @brief Describes stencil operation state
435 struct StencilOpState
439 StencilOp depthFailOp{};
440 CompareOp compareOp{};
441 uint32_t compareMask{0u};
442 uint32_t writeMask{0u};
443 uint32_t reference{0u};
445 auto& SetFailOp(StencilOp value)
451 auto& SetPassOp(StencilOp value)
457 auto& SetDepthFailOp(StencilOp value)
463 auto& SetCompareOp(CompareOp value)
469 auto& SetCompareMask(uint32_t value)
475 auto& SetWriteMask(uint32_t value)
481 auto& SetReference(uint32_t value)
489 * @brief Describes pipeline's viewport and scissor state
491 struct DepthStencilState
493 bool depthTestEnable{false};
494 bool depthWriteEnable{false};
495 CompareOp depthCompareOp{};
497 bool stencilTestEnable{false};
498 StencilOpState front{};
499 StencilOpState back{};
501 auto& SetDepthTestEnable(bool value)
503 depthTestEnable = value;
507 auto& SetDepthWriteEnable(bool value)
509 depthWriteEnable = value;
513 auto& SetDepthCompareOp(CompareOp value)
515 depthCompareOp = value;
519 auto& SetFront(StencilOpState value)
525 auto& SetBack(StencilOpState value)
531 auto& SetStencilTestEnable(bool value)
533 stencilTestEnable = value;
539 * @brief Rasterization state descriptor
541 struct RasterizationState
544 PolygonMode polygonMode{};
545 FrontFace frontFace{};
547 auto& SetCullMode(CullMode value)
553 auto& SetPolygonMode(PolygonMode value)
559 auto& SetFrontFace(FrontFace value)
567 * @brief Input assembly state descriptor.
569 * Structure describes the topology for submitted
572 struct InputAssemblyState
574 PrimitiveTopology topology{};
575 bool primitiveRestartEnable{true};
577 auto& SetTopology(PrimitiveTopology value)
583 auto& SetPrimitiveRestartEnable(bool value)
585 primitiveRestartEnable = true;
591 * @brief Pipeline dynamic state bits
593 namespace PipelineDynamicStateBits
595 const uint32_t VIEWPORT_BIT = 1 << 0;
596 const uint32_t SCISSOR_BIT = 1 << 1;
597 const uint32_t LINE_WIDTH_BIT = 1 << 2;
598 const uint32_t DEPTH_BIAS_BIT = 1 << 3;
599 const uint32_t BLEND_CONSTANTS_BIT = 1 << 4;
600 const uint32_t DEPTH_BOUNDS_BIT = 1 << 5;
601 const uint32_t STENCIL_COMPARE_MASK_BIT = 1 << 6;
602 const uint32_t STENCIL_WRITE_MASK_BIT = 1 << 7;
603 const uint32_t STENCIL_REFERENCE_BIT = 1 << 8;
604 } // namespace PipelineDynamicStateBits
606 const uint32_t PIPELINE_DYNAMIC_STATE_COUNT(9u);
608 using PipelineDynamicStateMask = uint32_t;
611 * @brief Structure describes vertex input state of the pipeline.
612 * It specifies buffer binding and attribute format to be used.
614 struct VertexInputState
616 VertexInputState() = default;
619 * @brief Vertex buffer binding
623 Binding(uint32_t _stride, VertexInputRate _inputRate)
625 inputRate(_inputRate)
629 VertexInputRate inputRate;
633 * @brief Attribute description
637 Attribute(uint32_t _location, uint32_t _binding, uint32_t _offset, VertexInputFormat _format)
638 : location(_location),
648 VertexInputFormat format;
651 VertexInputState(std::vector<Binding> _bufferBindings, std::vector<Attribute> _attributes)
652 : bufferBindings(std::move(_bufferBindings)),
653 attributes(std::move(_attributes))
657 std::vector<Binding> bufferBindings{};
658 std::vector<Attribute> attributes{};
662 * @brief List of all possible formats
663 * Not all formats may be supported
668 // GLES compatible, luminance doesn't exist in Vulkan
674 R4G4B4A4_UNORM_PACK16,
675 B4G4R4A4_UNORM_PACK16,
678 R5G5B5A1_UNORM_PACK16,
679 B5G5R5A1_UNORM_PACK16,
680 A1R5G5B5_UNORM_PACK16,
723 A8B8G8R8_UNORM_PACK32,
724 A8B8G8R8_SNORM_PACK32,
725 A8B8G8R8_USCALED_PACK32,
726 A8B8G8R8_SSCALED_PACK32,
727 A8B8G8R8_UINT_PACK32,
728 A8B8G8R8_SINT_PACK32,
729 A8B8G8R8_SRGB_PACK32,
730 A2R10G10B10_UNORM_PACK32,
731 A2R10G10B10_SNORM_PACK32,
732 A2R10G10B10_USCALED_PACK32,
733 A2R10G10B10_SSCALED_PACK32,
734 A2R10G10B10_UINT_PACK32,
735 A2R10G10B10_SINT_PACK32,
736 A2B10G10R10_UNORM_PACK32,
737 A2B10G10R10_SNORM_PACK32,
738 A2B10G10R10_USCALED_PACK32,
739 A2B10G10R10_SSCALED_PACK32,
740 A2B10G10R10_UINT_PACK32,
741 A2B10G10R10_SINT_PACK32,
765 R16G16B16A16_USCALED,
766 R16G16B16A16_SSCALED,
794 R11G11B10_UFLOAT_PACK32,
795 B10G11R11_UFLOAT_PACK32,
796 E5B9G9R9_UFLOAT_PACK32,
806 BC1_RGBA_UNORM_BLOCK,
820 ETC2_R8G8B8_UNORM_BLOCK,
821 ETC2_R8G8B8_SRGB_BLOCK,
822 ETC2_R8G8B8A1_UNORM_BLOCK,
823 ETC2_R8G8B8A1_SRGB_BLOCK,
824 ETC2_R8G8B8A8_UNORM_BLOCK,
825 ETC2_R8G8B8A8_SRGB_BLOCK,
828 EAC_R11G11_UNORM_BLOCK,
829 EAC_R11G11_SNORM_BLOCK,
830 ASTC_4x4_UNORM_BLOCK,
832 ASTC_5x4_UNORM_BLOCK,
834 ASTC_5x5_UNORM_BLOCK,
836 ASTC_6x5_UNORM_BLOCK,
838 ASTC_6x6_UNORM_BLOCK,
840 ASTC_8x5_UNORM_BLOCK,
842 ASTC_8x6_UNORM_BLOCK,
844 ASTC_8x8_UNORM_BLOCK,
846 ASTC_10x5_UNORM_BLOCK,
847 ASTC_10x5_SRGB_BLOCK,
848 ASTC_10x6_UNORM_BLOCK,
849 ASTC_10x6_SRGB_BLOCK,
850 ASTC_10x8_UNORM_BLOCK,
851 ASTC_10x8_SRGB_BLOCK,
852 ASTC_10x10_UNORM_BLOCK,
853 ASTC_10x10_SRGB_BLOCK,
854 ASTC_12x10_UNORM_BLOCK,
855 ASTC_12x10_SRGB_BLOCK,
856 ASTC_12x12_UNORM_BLOCK,
857 ASTC_12x12_SRGB_BLOCK,
858 PVRTC1_2BPP_UNORM_BLOCK_IMG,
859 PVRTC1_4BPP_UNORM_BLOCK_IMG,
860 PVRTC2_2BPP_UNORM_BLOCK_IMG,
861 PVRTC2_4BPP_UNORM_BLOCK_IMG,
862 PVRTC1_2BPP_SRGB_BLOCK_IMG,
863 PVRTC1_4BPP_SRGB_BLOCK_IMG,
864 PVRTC2_2BPP_SRGB_BLOCK_IMG,
865 PVRTC2_4BPP_SRGB_BLOCK_IMG,
869 * @brief Flags specifying a buffer usage
871 enum class BufferUsage
873 TRANSFER_SRC = 1 << 0,
874 TRANSFER_DST = 1 << 1,
875 UNIFORM_TEXEL_BUFFER = 1 << 2,
876 STORAGE_TEXEL_BUFFER = 1 << 3,
877 UNIFORM_BUFFER = 1 << 4,
878 STORAGE_BUFFER = 1 << 5,
879 INDEX_BUFFER = 1 << 6,
880 VERTEX_BUFFER = 1 << 7,
881 INDIRECT_BUFFER = 1 << 8,
884 using BufferUsageFlags = uint32_t;
886 inline BufferUsageFlags operator|(BufferUsageFlags flags, BufferUsage usage)
888 flags |= static_cast<uint32_t>(usage);
893 * @brief Buffer property bits
895 * Use these bits to set BufferPropertiesFlags.
897 enum class BufferPropertiesFlagBit : uint32_t
899 CPU_ALLOCATED = 1 << 0, ///< Buffer is allocated on the CPU side
900 TRANSIENT_MEMORY = 1 << 1, ///< Buffer memory will be short-lived
904 * @brief BufferPropetiesFlags alters behaviour of implementation
906 using BufferPropertiesFlags = uint32_t;
908 inline BufferPropertiesFlags operator|(BufferPropertiesFlags flags, BufferPropertiesFlagBit usage)
910 flags |= static_cast<uint32_t>(usage);
915 * @brief The structure describes memory requirements of GPU resource (texture, buffer)
917 struct MemoryRequirements
923 using TextureUpdateFlags = uint32_t;
924 enum class TextureUpdateFlagBits
926 KEEP_SOURCE = 1 << 0,
930 * @brief Texture update info
932 * Describes the texture update to be executed by
933 * Controller::UpdateTextures()
935 struct TextureUpdateInfo
937 Texture* dstTexture{};
938 Offset2D dstOffset2D;
942 uint32_t srcReference{};
943 Extent2D srcExtent2D{};
944 uint32_t srcOffset{};
946 Format srcFormat{}; ///< Should match dstTexture's format, otherwise conversion may occur
950 * @brief Texture update source info
952 * Describes the source of data (memory, buffer or another texture)
953 * to be used when updating textures using Controller::UpdateTextures().
955 struct TextureUpdateSourceInfo
983 * @brief Properties of texture
985 struct TextureProperties
987 Format format; ///< Texture format
988 Format format1; ///< Texture format (if emulated)
989 bool emulated; ///< Format is emulated (for example RGB as RGBA)
990 bool compressed; ///< Texture is compressed
991 bool packed; ///< Texture is packed
992 Extent2D extent2D; ///< Size of texture
993 bool directWriteAccessEnabled; ///< Direct write access (mappable textures)
997 * @brief Texture tiling that directly refers to the tiling
998 * mode supported by the Vulkan. Other implementations
999 * of the backend may ignore the value.
1001 enum class TextureTiling
1008 * @brief Texture color attachment used by FramebufferCreateInfo
1010 struct ColorAttachment
1012 uint32_t attachmentId;
1019 * @brief Depth stencil attachment used by FramebufferCreateInfo
1021 struct DepthStencilAttachment
1025 WRITE, // If no texture, will create a RenderBuffer instead
1026 NONE // If no attachment/RenderBuffer required
1028 Texture* depthTexture{nullptr};
1029 Texture* stencilTexture{nullptr};
1030 uint32_t depthLevel{0};
1031 uint32_t stencilLevel{0};
1032 Usage depthUsage{Usage::NONE};
1033 Usage stencilUsage{Usage::NONE};
1037 * @brief Submit flags
1039 using SubmitFlags = uint32_t;
1044 enum class SubmitFlagBits : uint32_t
1046 FLUSH = 1 << 0, // Flush immediately
1047 DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
1050 template<typename T>
1051 inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
1053 return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
1057 * @brief Describes command buffers submission
1061 std::vector<CommandBuffer*> cmdBuffer;
1066 * @brief Shader language enum
1068 enum class ShaderLanguage
1078 * @brief Pipeline stages
1080 enum class PipelineStage
1087 TESSELATION_CONTROL,
1088 TESSELATION_EVALUATION,
1093 * @brief Vertex attribute format
1095 * TODO: to be replaced with Format
1097 enum class VertexInputAttributeFormat
1108 * @brief Uniform class
1110 enum class UniformClass
1114 COMBINED_IMAGE_SAMPLER,
1121 * @brief Type of texture
1123 enum class TextureType
1131 * @brief The information of the uniform
1135 std::string name{""};
1136 UniformClass uniformClass{UniformClass::UNDEFINED};
1137 uint32_t binding{0u};
1138 uint32_t bufferIndex{0u};
1139 uint32_t offset{0u};
1140 uint32_t location{0u};
1142 bool operator==(const UniformInfo& rhs)
1144 return name == rhs.name &&
1145 uniformClass == rhs.uniformClass &&
1146 binding == rhs.binding &&
1147 bufferIndex == rhs.bufferIndex &&
1148 offset == rhs.offset &&
1149 location == rhs.location;
1154 * @brief The information of the uniform block
1156 struct UniformBlockInfo
1158 std::string name{""};
1159 uint32_t descriptorSet{0u};
1160 uint32_t binding{0u};
1162 std::vector<UniformInfo> members{};
1166 * @brief Describes pipeline's shading stages
1168 * Shader state binds shader and pipeline stage that the
1169 * shader will be executed. The shader may be created with
1170 * pipeline stage and the pipelineStage member may be ignored
1171 * by setting inheritPipelineStage to true.
1175 const Shader* shader{nullptr}; // shader to attach
1176 PipelineStage pipelineStage{}; // pipeline stage to execute the shader
1177 bool inheritPipelineStage{false}; // stage inheritance
1179 auto& SetShader(const Shader& value)
1185 auto& SetPipelineStage(PipelineStage value)
1187 pipelineStage = value;
1191 auto& SetInheritPipelineStage(bool value)
1193 inheritPipelineStage = value;
1199 * @brief Flag determining usage of texture
1201 using TextureUsageFlags = uint32_t;
1202 enum class TextureUsageFlagBits : uint32_t
1205 COLOR_ATTACHMENT = 1 << 1,
1206 DEPTH_STENCIL_ATTACHMENT = 1 << 2,
1210 template<typename T>
1211 inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
1213 return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
1216 using TextureFormat = Dali::Graphics::Format;
1219 * @brief Texture mipmap disable/enable enum
1221 enum class TextureMipMapFlag
1228 * @brief Depth/stencil attachment flag
1230 enum class TextureDepthStencilFlag
1239 * @brief Layout of texture
1241 * Specifies how the memory will be allocated, organized and accessed.
1243 enum class TextureLayout
1245 LINEAR, ///< Creates linear memory, mapping possible
1246 OPTIMAL ///< Usually, read-only memory, driver-optimal layout
1250 * @brief Level of command buffer
1252 enum class CommandBufferLevel
1254 PRIMARY, ///< Primary buffer can be executed on its own
1255 SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
1259 * @brief Enum indicating whether shader source
1260 * is text-based or binary.
1262 enum class ShaderSourceMode
1269 * @brief Memory usage flags to be set when mapping the buffer
1271 using MemoryUsageFlags = uint32_t;
1272 enum class MemoryUsageFlagBits : uint32_t
1276 PERSISTENT = 1 << 2,
1277 ASYNCHRONOUS = 1 << 3,
1281 template<typename T>
1282 inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
1284 return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
1288 * @brief Describes buffer mapping details
1290 struct MapBufferInfo
1293 MemoryUsageFlags usage;
1299 * @brief Describes buffer mapping details
1300 * TODO: mapping by texture level and layer
1302 struct MapTextureInfo
1305 MemoryUsageFlags usage;
1311 * @brief GraphicsStructureType enum is used by all create info structures
1312 * in order to identify by the implementation which structure it is
1315 enum class GraphicsStructureType : uint32_t
1317 BUFFER_CREATE_INFO_STRUCT,
1318 COMMAND_BUFFER_CREATE_INFO_STRUCT,
1319 FRAMEBUFFER_CREATE_INFO_STRUCT,
1320 PROGRAM_CREATE_INFO_STRUCT,
1321 PIPELINE_CREATE_INFO_STRUCT,
1322 RENDERPASS_CREATE_INFO_STRUCT,
1323 SAMPLER_CREATE_INFO_STRUCT,
1324 SHADER_CREATE_INFO_STRUCT,
1325 TEXTURE_CREATE_INFO_STRUCT,
1326 RENDER_TARGET_CREATE_INFO_STRUCT,
1327 SYNC_OBJECT_CREATE_INFO_STRUCT
1331 * @brief Enum describes load operation associated
1332 * with particular framebuffer attachment
1334 enum class AttachmentLoadOp
1336 LOAD, ///< Load previous content
1337 CLEAR, ///< Clear the attachment
1338 DONT_CARE ///< Let driver decide
1342 * @brief Enum describes store operation associated
1343 * with particular framebuffer attachment
1345 enum class AttachmentStoreOp
1347 STORE, ///< Store content (color attachemnts)
1348 DONT_CARE ///< Let driver decide (depth/stencil attachemnt with no intention of reading)
1352 * @brief The structure describes the read/write
1353 * modes of a single framebuffer attachment
1355 * The attachment description specifies what is going to
1356 * happen to the attachment at the beginning and end of the
1359 * The stencil operation is separated as it may be set
1360 * independent from the depth component (use loadOp, storeOp
1361 * to set up the depth component and stencilLoadOp, stencilStoreOp
1362 * for stencil component).
1364 struct AttachmentDescription
1367 * @brief Sets load operation for the attachment
1369 * @param value Load operation
1370 * @return this structure
1372 auto& SetLoadOp(AttachmentLoadOp value)
1379 * @brief Sets store operation for the attachment
1381 * @param value Store operation
1382 * @return this structure
1384 auto& SetStoreOp(AttachmentStoreOp value)
1391 * @brief Sets load operation for the stencil part of attachment
1393 * @param value load operation
1394 * @return this structure
1396 auto& SetStencilLoadOp(AttachmentLoadOp value)
1398 stencilLoadOp = value;
1403 * @brief Sets store operation for the stencil part of attachment
1405 * @param value store operation
1406 * @return this structure
1408 auto& SetStencilStoreOp(AttachmentStoreOp value)
1410 stencilStoreOp = value;
1414 AttachmentLoadOp loadOp{};
1415 AttachmentStoreOp storeOp{};
1416 AttachmentLoadOp stencilLoadOp{};
1417 AttachmentStoreOp stencilStoreOp{};
1421 * @brief Helper function to be used by the extension developers
1423 * The value of custom type must be unique and recognizable by the
1426 * @param customValue Custom value of GraphicsStructureType
1427 * @return Integer converted to GraphicsStructureType
1429 inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
1431 return static_cast<GraphicsStructureType>(customValue);
1435 * @brief The allocation callbacks may be passed when the object is created.
1437 struct AllocationCallbacks
1439 void* userData = nullptr; ///< User data passed to the allocator
1440 void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
1441 void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
1442 void (*freeCallback)(void* memory, void* userData) = nullptr;
1446 * @brief The ExtensionCreateInfo structure should be a base of any
1447 * extension create info structure. The structure isn't virtual
1448 * so the implementation must prevent slicing it.
1450 struct ExtensionCreateInfo
1452 GraphicsStructureType type{};
1453 ExtensionCreateInfo* nextExtension{};
1457 * @brief Default deleter for graphics unique pointers
1459 * Returned unique_ptr may require custom deleter. To get it working
1460 * with std::unique_ptr the custom type is used with polymorphic deleter
1463 struct DefaultDeleter
1465 DefaultDeleter() = default;
1468 * @brief Conversion constructor
1470 * This constructor will set the lambda for type passed
1473 template<class P, template<typename> typename U>
1474 DefaultDeleter(const U<P>& deleter)
1476 deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
1480 * @brief Conversion constructor from DefaultDelete<P>
1482 * This constructor transfers deleteFunction only
1485 explicit DefaultDeleter(const DefaultDeleter<P>& deleter)
1487 deleteFunction = decltype(deleteFunction)(deleter.deleteFunction);
1491 * @brief Default deleter
1493 * Default deleter will use standard 'delete' call in order
1494 * to discard graphics objects unless a custom deleter was
1497 * @param[in] object Object to delete
1499 void operator()(T* object)
1503 deleteFunction(object);
1511 void (*deleteFunction)(T* object){nullptr}; ///< Custom delete function
1515 * Surface type is just a void* to any native object.
1517 using Surface = void;
1520 * @brief Enum describing preTransform of render target
1522 enum class RenderTargetTransformFlagBits
1524 TRANSFORM_IDENTITY_BIT = 0x00000001,
1525 ROTATE_90_BIT = 0x00000002,
1526 ROTATE_180_BIT = 0x00000004,
1527 ROTATE_270_BIT = 0x00000008,
1528 HORIZONTAL_MIRROR_BIT = 0x00000010,
1529 HORIZONTAL_MIRROR_ROTATE_90_BIT = 0x00000020,
1530 HORIZONTAL_MIRROR_ROTATE_180_BIT = 0x00000040,
1531 HORIZONTAL_MIRROR_ROTATE_270_BIT = 0x00000080,
1534 using RenderTargetTransformFlags = uint32_t;
1536 template<typename T>
1537 inline RenderTargetTransformFlags operator|(T flags, RenderTargetTransformFlagBits bit)
1539 return static_cast<RenderTargetTransformFlags>(flags) | static_cast<RenderTargetTransformFlags>(bit);
1543 * unique_ptr defined in the Graphics scope
1545 template<class T, class D = DefaultDeleter<T>>
1546 using UniquePtr = std::unique_ptr<T, D>;
1549 * @brief MakeUnique<> version that returns Graphics::UniquePtr
1550 * @param[in] args Arguments for construction
1553 template<class T, class Deleter = DefaultDeleter<T>, class... Args>
1554 std::enable_if_t<!std::is_array<T>::value, Graphics::UniquePtr<T>>
1555 MakeUnique(Args&&... args)
1557 return UniquePtr<T>(new T(std::forward<Args>(args)...), Deleter());
1560 } // namespace Graphics
1563 #endif //DALI_GRAPHICS_API_TYPES_H