1 #ifndef DALI_GRAPHICS_API_TYPES
2 #define DALI_GRAPHICS_API_TYPES
5 * Copyright (c) 2022 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/signals/callback.h>
41 * @brief Structure describes 2D offset
50 * @brief Structure describes 2D dimensions
59 * @brief Structure describes 2D rectangle (offset, extent)
70 * @brief Structure represents area of viewport
78 float minDepth = 0.0f;
79 float maxDepth = 0.0f;
83 * @brief Describes vertex attribute input rate
85 enum class VertexInputRate
87 PER_VERTEX, ///< Attribute read per vertex
88 PER_INSTANCE ///< Attribute read per instance
92 * @brief Vertex input format
94 * When UNDEFINED, the reflection is used to determine what
95 * the actual format is.
97 enum class VertexInputFormat
111 * @brief Logic operators used by color blending state
112 * when logicOpEnable is set.
135 * @brief Blend factors
137 enum class BlendFactor
142 ONE_MINUS_SRC_COLOR = 3,
144 ONE_MINUS_DST_COLOR = 5,
146 ONE_MINUS_SRC_ALPHA = 7,
148 ONE_MINUS_DST_ALPHA = 9,
150 ONE_MINUS_CONSTANT_COLOR = 11,
152 ONE_MINUS_CONSTANT_ALPHA = 13,
153 SRC_ALPHA_SATURATE = 14,
155 ONE_MINUS_SRC1_COLOR = 16,
157 ONE_MINUS_SRC1_ALPHA = 18,
161 * @brief Blend operators
167 REVERSE_SUBTRACT = 2,
187 const BlendOp ADVANCED_BLEND_OPTIONS_START(BlendOp::MULTIPLY);
190 * @brief Compare operators
205 * @brief Stencil operators
220 * @brief Backface culling modes
231 * @brief Polygon drawing modes
233 enum class PolygonMode
241 * @brief Front face direction
250 * @brief Primitive geometry topology
252 enum class PrimitiveTopology
264 * @brief Sampler address ( wrapping ) mode
266 enum class SamplerAddressMode
276 * @brief Filtering mode
278 enum class SamplerFilter
287 enum class SamplerMipmapMode
295 * @brief Describes pipeline's color blend state
297 struct ColorBlendState
299 bool logicOpEnable = false;
300 LogicOp logicOp = {};
301 float blendConstants[4] = {0.0f, 0.0f, 0.0f, 0.0f};
302 bool blendEnable = false;
303 BlendFactor srcColorBlendFactor = BlendFactor::ZERO;
304 BlendFactor dstColorBlendFactor = BlendFactor::ZERO;
305 BlendOp colorBlendOp = {};
306 BlendFactor srcAlphaBlendFactor = BlendFactor::ZERO;
307 BlendFactor dstAlphaBlendFactor = BlendFactor::ZERO;
308 BlendOp alphaBlendOp = {};
309 uint32_t colorComponentWriteBits = {0u};
311 auto& SetLogicOpEnable(bool value)
313 logicOpEnable = value;
317 auto& SetLogicOp(LogicOp value)
323 auto& SetBlendConstants(float value[4])
325 std::copy(value, value + 4, blendConstants);
329 auto& SetBlendEnable(bool value)
335 auto& SetSrcColorBlendFactor(BlendFactor value)
337 srcColorBlendFactor = value;
341 auto& SetDstColorBlendFactor(BlendFactor value)
343 dstColorBlendFactor = value;
347 auto& SetColorBlendOp(BlendOp value)
349 colorBlendOp = value;
353 auto& SetSrcAlphaBlendFactor(BlendFactor value)
355 srcAlphaBlendFactor = value;
359 auto& SetDstAlphaBlendFactor(BlendFactor value)
361 dstAlphaBlendFactor = value;
365 auto& SetAlphaBlendOp(BlendOp value)
367 alphaBlendOp = value;
371 auto& SetColorComponentsWriteBits(uint32_t value)
373 colorComponentWriteBits = value;
379 * @brief Program State
383 const Program* program{nullptr};
385 auto& SetProgram(const Program& value)
393 * @brief Framebuffer state.
395 struct FramebufferState
397 const Framebuffer* framebuffer{nullptr};
399 auto& SetFramebuffer(const Framebuffer& value)
401 framebuffer = &value;
407 * @brief Describes pipeline's viewport and scissor state
411 Viewport viewport{0.0, 0.0, 0.0, 0.0};
412 Rect2D scissor{0, 0, 0, 0};
413 bool scissorTestEnable{false};
415 auto& SetViewport(const Viewport& value)
421 auto& SetScissor(const Rect2D& value)
427 auto& SetScissorTestEnable(bool value)
429 scissorTestEnable = value;
435 * @brief Describes stencil operation state
437 struct StencilOpState
441 StencilOp depthFailOp{};
442 CompareOp compareOp{};
443 uint32_t compareMask{0u};
444 uint32_t writeMask{0u};
445 uint32_t reference{0u};
447 auto& SetFailOp(StencilOp value)
453 auto& SetPassOp(StencilOp value)
459 auto& SetDepthFailOp(StencilOp value)
465 auto& SetCompareOp(CompareOp value)
471 auto& SetCompareMask(uint32_t value)
477 auto& SetWriteMask(uint32_t value)
483 auto& SetReference(uint32_t value)
491 * @brief Describes pipeline's viewport and scissor state
493 struct DepthStencilState
495 bool depthTestEnable{false};
496 bool depthWriteEnable{false};
497 CompareOp depthCompareOp{};
499 bool stencilTestEnable{false};
500 StencilOpState front{};
501 StencilOpState back{};
503 auto& SetDepthTestEnable(bool value)
505 depthTestEnable = value;
509 auto& SetDepthWriteEnable(bool value)
511 depthWriteEnable = value;
515 auto& SetDepthCompareOp(CompareOp value)
517 depthCompareOp = value;
521 auto& SetFront(StencilOpState value)
527 auto& SetBack(StencilOpState value)
533 auto& SetStencilTestEnable(bool value)
535 stencilTestEnable = value;
541 * @brief Rasterization state descriptor
543 struct RasterizationState
546 PolygonMode polygonMode{};
547 FrontFace frontFace{};
549 auto& SetCullMode(CullMode value)
555 auto& SetPolygonMode(PolygonMode value)
561 auto& SetFrontFace(FrontFace value)
569 * @brief Input assembly state descriptor.
571 * Structure describes the topology for submitted
574 struct InputAssemblyState
576 PrimitiveTopology topology{};
577 bool primitiveRestartEnable{true};
579 auto& SetTopology(PrimitiveTopology value)
585 auto& SetPrimitiveRestartEnable(bool value)
587 primitiveRestartEnable = true;
593 * @brief Pipeline dynamic state bits
595 namespace PipelineDynamicStateBits
597 const uint32_t VIEWPORT_BIT = 1 << 0;
598 const uint32_t SCISSOR_BIT = 1 << 1;
599 const uint32_t LINE_WIDTH_BIT = 1 << 2;
600 const uint32_t DEPTH_BIAS_BIT = 1 << 3;
601 const uint32_t BLEND_CONSTANTS_BIT = 1 << 4;
602 const uint32_t DEPTH_BOUNDS_BIT = 1 << 5;
603 const uint32_t STENCIL_COMPARE_MASK_BIT = 1 << 6;
604 const uint32_t STENCIL_WRITE_MASK_BIT = 1 << 7;
605 const uint32_t STENCIL_REFERENCE_BIT = 1 << 8;
606 } // namespace PipelineDynamicStateBits
608 const uint32_t PIPELINE_DYNAMIC_STATE_COUNT(9u);
610 using PipelineDynamicStateMask = uint32_t;
613 * @brief Structure describes vertex input state of the pipeline.
614 * It specifies buffer binding and attribute format to be used.
616 struct VertexInputState
618 VertexInputState() = default;
621 * @brief Vertex buffer binding
625 Binding(uint32_t _stride, VertexInputRate _inputRate)
627 inputRate(_inputRate)
631 VertexInputRate inputRate;
635 * @brief Attribute description
639 Attribute(uint32_t _location, uint32_t _binding, uint32_t _offset, VertexInputFormat _format)
640 : location(_location),
650 VertexInputFormat format;
653 VertexInputState(std::vector<Binding> _bufferBindings, std::vector<Attribute> _attributes)
654 : bufferBindings(std::move(_bufferBindings)),
655 attributes(std::move(_attributes))
659 std::vector<Binding> bufferBindings{};
660 std::vector<Attribute> attributes{};
664 * @brief List of all possible formats
665 * Not all formats may be supported
670 // GLES compatible, luminance doesn't exist in Vulkan
676 R4G4B4A4_UNORM_PACK16,
677 B4G4R4A4_UNORM_PACK16,
680 R5G5B5A1_UNORM_PACK16,
681 B5G5R5A1_UNORM_PACK16,
682 A1R5G5B5_UNORM_PACK16,
725 A8B8G8R8_UNORM_PACK32,
726 A8B8G8R8_SNORM_PACK32,
727 A8B8G8R8_USCALED_PACK32,
728 A8B8G8R8_SSCALED_PACK32,
729 A8B8G8R8_UINT_PACK32,
730 A8B8G8R8_SINT_PACK32,
731 A8B8G8R8_SRGB_PACK32,
732 A2R10G10B10_UNORM_PACK32,
733 A2R10G10B10_SNORM_PACK32,
734 A2R10G10B10_USCALED_PACK32,
735 A2R10G10B10_SSCALED_PACK32,
736 A2R10G10B10_UINT_PACK32,
737 A2R10G10B10_SINT_PACK32,
738 A2B10G10R10_UNORM_PACK32,
739 A2B10G10R10_SNORM_PACK32,
740 A2B10G10R10_USCALED_PACK32,
741 A2B10G10R10_SSCALED_PACK32,
742 A2B10G10R10_UINT_PACK32,
743 A2B10G10R10_SINT_PACK32,
767 R16G16B16A16_USCALED,
768 R16G16B16A16_SSCALED,
796 R11G11B10_UFLOAT_PACK32,
797 B10G11R11_UFLOAT_PACK32,
798 E5B9G9R9_UFLOAT_PACK32,
808 BC1_RGBA_UNORM_BLOCK,
822 ETC2_R8G8B8_UNORM_BLOCK,
823 ETC2_R8G8B8_SRGB_BLOCK,
824 ETC2_R8G8B8A1_UNORM_BLOCK,
825 ETC2_R8G8B8A1_SRGB_BLOCK,
826 ETC2_R8G8B8A8_UNORM_BLOCK,
827 ETC2_R8G8B8A8_SRGB_BLOCK,
830 EAC_R11G11_UNORM_BLOCK,
831 EAC_R11G11_SNORM_BLOCK,
832 ASTC_4x4_UNORM_BLOCK,
834 ASTC_5x4_UNORM_BLOCK,
836 ASTC_5x5_UNORM_BLOCK,
838 ASTC_6x5_UNORM_BLOCK,
840 ASTC_6x6_UNORM_BLOCK,
842 ASTC_8x5_UNORM_BLOCK,
844 ASTC_8x6_UNORM_BLOCK,
846 ASTC_8x8_UNORM_BLOCK,
848 ASTC_10x5_UNORM_BLOCK,
849 ASTC_10x5_SRGB_BLOCK,
850 ASTC_10x6_UNORM_BLOCK,
851 ASTC_10x6_SRGB_BLOCK,
852 ASTC_10x8_UNORM_BLOCK,
853 ASTC_10x8_SRGB_BLOCK,
854 ASTC_10x10_UNORM_BLOCK,
855 ASTC_10x10_SRGB_BLOCK,
856 ASTC_12x10_UNORM_BLOCK,
857 ASTC_12x10_SRGB_BLOCK,
858 ASTC_12x12_UNORM_BLOCK,
859 ASTC_12x12_SRGB_BLOCK,
860 PVRTC1_2BPP_UNORM_BLOCK_IMG,
861 PVRTC1_4BPP_UNORM_BLOCK_IMG,
862 PVRTC2_2BPP_UNORM_BLOCK_IMG,
863 PVRTC2_4BPP_UNORM_BLOCK_IMG,
864 PVRTC1_2BPP_SRGB_BLOCK_IMG,
865 PVRTC1_4BPP_SRGB_BLOCK_IMG,
866 PVRTC2_2BPP_SRGB_BLOCK_IMG,
867 PVRTC2_4BPP_SRGB_BLOCK_IMG,
871 * @brief Flags specifying a buffer usage
873 enum class BufferUsage
875 TRANSFER_SRC = 1 << 0,
876 TRANSFER_DST = 1 << 1,
877 UNIFORM_TEXEL_BUFFER = 1 << 2,
878 STORAGE_TEXEL_BUFFER = 1 << 3,
879 UNIFORM_BUFFER = 1 << 4,
880 STORAGE_BUFFER = 1 << 5,
881 INDEX_BUFFER = 1 << 6,
882 VERTEX_BUFFER = 1 << 7,
883 INDIRECT_BUFFER = 1 << 8,
886 using BufferUsageFlags = uint32_t;
888 inline BufferUsageFlags operator|(BufferUsageFlags flags, BufferUsage usage)
890 flags |= static_cast<uint32_t>(usage);
895 * @brief Buffer property bits
897 * Use these bits to set BufferPropertiesFlags.
899 enum class BufferPropertiesFlagBit : uint32_t
901 CPU_ALLOCATED = 1 << 0, ///< Buffer is allocated on the CPU side
902 TRANSIENT_MEMORY = 1 << 1, ///< Buffer memory will be short-lived
906 * @brief BufferPropetiesFlags alters behaviour of implementation
908 using BufferPropertiesFlags = uint32_t;
910 inline BufferPropertiesFlags operator|(BufferPropertiesFlags flags, BufferPropertiesFlagBit usage)
912 flags |= static_cast<uint32_t>(usage);
917 * @brief The structure describes memory requirements of GPU resource (texture, buffer)
919 struct MemoryRequirements
925 using TextureUpdateFlags = uint32_t;
926 enum class TextureUpdateFlagBits
928 KEEP_SOURCE = 1 << 0,
932 * @brief Texture update info
934 * Describes the texture update to be executed by
935 * Controller::UpdateTextures()
937 struct TextureUpdateInfo
939 Texture* dstTexture{};
940 Offset2D dstOffset2D;
944 uint32_t srcReference{};
945 Extent2D srcExtent2D{};
946 uint32_t srcOffset{};
948 uint32_t srcStride{};
949 Format srcFormat{}; ///< Should match dstTexture's format, otherwise conversion may occur
953 * @brief Texture update source info
955 * Describes the source of data (memory, buffer or another texture)
956 * to be used when updating textures using Controller::UpdateTextures().
958 struct TextureUpdateSourceInfo
986 * @brief Properties of texture
988 struct TextureProperties
990 Format format; ///< Texture format
991 Format format1; ///< Texture format (if emulated)
992 bool emulated; ///< Format is emulated (for example RGB as RGBA)
993 bool compressed; ///< Texture is compressed
994 bool packed; ///< Texture is packed
995 Extent2D extent2D; ///< Size of texture
996 bool directWriteAccessEnabled; ///< Direct write access (mappable textures)
1000 * @brief Texture tiling that directly refers to the tiling
1001 * mode supported by the Vulkan. Other implementations
1002 * of the backend may ignore the value.
1004 enum class TextureTiling
1011 * @brief Texture color attachment used by FramebufferCreateInfo
1013 struct ColorAttachment
1015 uint32_t attachmentId;
1022 * @brief Depth stencil attachment used by FramebufferCreateInfo
1024 struct DepthStencilAttachment
1028 WRITE, // If no texture, will create a RenderBuffer instead
1029 NONE // If no attachment/RenderBuffer required
1031 Texture* depthTexture{nullptr};
1032 Texture* stencilTexture{nullptr};
1033 uint32_t depthLevel{0};
1034 uint32_t stencilLevel{0};
1035 Usage depthUsage{Usage::NONE};
1036 Usage stencilUsage{Usage::NONE};
1040 * @brief Submit flags
1042 using SubmitFlags = uint32_t;
1047 enum class SubmitFlagBits : uint32_t
1049 FLUSH = 1 << 0, // Flush immediately
1050 DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
1053 template<typename T>
1054 inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
1056 return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
1060 * @brief Describes command buffers submission
1064 std::vector<CommandBuffer*> cmdBuffer;
1069 * @brief Shader language enum
1071 enum class ShaderLanguage
1081 * @brief Pipeline stages
1083 enum class PipelineStage
1090 TESSELATION_CONTROL,
1091 TESSELATION_EVALUATION,
1096 * @brief Vertex attribute format
1098 * TODO: to be replaced with Format
1100 enum class VertexInputAttributeFormat
1111 * @brief Uniform class
1113 enum class UniformClass
1117 COMBINED_IMAGE_SAMPLER,
1124 * @brief Type of texture
1126 enum class TextureType
1134 * @brief The information of the uniform
1138 std::string name{""};
1139 UniformClass uniformClass{UniformClass::UNDEFINED};
1140 uint32_t binding{0u};
1141 uint32_t bufferIndex{0u};
1142 uint32_t offset{0u};
1143 uint32_t location{0u};
1145 bool operator==(const UniformInfo& rhs)
1147 return name == rhs.name &&
1148 uniformClass == rhs.uniformClass &&
1149 binding == rhs.binding &&
1150 bufferIndex == rhs.bufferIndex &&
1151 offset == rhs.offset &&
1152 location == rhs.location;
1157 * @brief The information of the uniform block
1159 struct UniformBlockInfo
1161 std::string name{""};
1162 uint32_t descriptorSet{0u};
1163 uint32_t binding{0u};
1165 std::vector<UniformInfo> members{};
1169 * @brief Describes pipeline's shading stages
1171 * Shader state binds shader and pipeline stage that the
1172 * shader will be executed. The shader may be created with
1173 * pipeline stage and the pipelineStage member may be ignored
1174 * by setting inheritPipelineStage to true.
1178 const Shader* shader{nullptr}; // shader to attach
1179 PipelineStage pipelineStage{}; // pipeline stage to execute the shader
1180 bool inheritPipelineStage{false}; // stage inheritance
1182 auto& SetShader(const Shader& value)
1188 auto& SetPipelineStage(PipelineStage value)
1190 pipelineStage = value;
1194 auto& SetInheritPipelineStage(bool value)
1196 inheritPipelineStage = value;
1202 * @brief Flag determining usage of texture
1204 using TextureUsageFlags = uint32_t;
1205 enum class TextureUsageFlagBits : uint32_t
1208 COLOR_ATTACHMENT = 1 << 1,
1209 DEPTH_STENCIL_ATTACHMENT = 1 << 2,
1213 template<typename T>
1214 inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
1216 return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
1219 using TextureFormat = Dali::Graphics::Format;
1222 * @brief Texture mipmap disable/enable enum
1224 enum class TextureMipMapFlag
1231 * @brief Depth/stencil attachment flag
1233 enum class TextureDepthStencilFlag
1242 * @brief Layout of texture
1244 * Specifies how the memory will be allocated, organized and accessed.
1246 enum class TextureLayout
1248 LINEAR, ///< Creates linear memory, mapping possible
1249 OPTIMAL ///< Usually, read-only memory, driver-optimal layout
1253 * @brief Level of command buffer
1255 enum class CommandBufferLevel
1257 PRIMARY, ///< Primary buffer can be executed on its own
1258 SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
1262 * @brief Enum indicating whether shader source
1263 * is text-based or binary.
1265 enum class ShaderSourceMode
1272 * @brief Memory usage flags to be set when mapping the buffer
1274 using MemoryUsageFlags = uint32_t;
1275 enum class MemoryUsageFlagBits : uint32_t
1279 PERSISTENT = 1 << 2,
1280 ASYNCHRONOUS = 1 << 3,
1284 template<typename T>
1285 inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
1287 return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
1291 * @brief Describes buffer mapping details
1293 struct MapBufferInfo
1296 MemoryUsageFlags usage;
1302 * @brief Describes buffer mapping details
1303 * TODO: mapping by texture level and layer
1305 struct MapTextureInfo
1308 MemoryUsageFlags usage;
1314 * @brief GraphicsStructureType enum is used by all create info structures
1315 * in order to identify by the implementation which structure it is
1318 enum class GraphicsStructureType : uint32_t
1320 BUFFER_CREATE_INFO_STRUCT,
1321 COMMAND_BUFFER_CREATE_INFO_STRUCT,
1322 FRAMEBUFFER_CREATE_INFO_STRUCT,
1323 PROGRAM_CREATE_INFO_STRUCT,
1324 PIPELINE_CREATE_INFO_STRUCT,
1325 RENDERPASS_CREATE_INFO_STRUCT,
1326 SAMPLER_CREATE_INFO_STRUCT,
1327 SHADER_CREATE_INFO_STRUCT,
1328 TEXTURE_CREATE_INFO_STRUCT,
1329 RENDER_TARGET_CREATE_INFO_STRUCT,
1330 SYNC_OBJECT_CREATE_INFO_STRUCT
1334 * @brief Enum describes load operation associated
1335 * with particular framebuffer attachment
1337 enum class AttachmentLoadOp
1339 LOAD, ///< Load previous content
1340 CLEAR, ///< Clear the attachment
1341 DONT_CARE ///< Let driver decide
1345 * @brief Enum describes store operation associated
1346 * with particular framebuffer attachment
1348 enum class AttachmentStoreOp
1350 STORE, ///< Store content (color attachemnts)
1351 DONT_CARE ///< Let driver decide (depth/stencil attachemnt with no intention of reading)
1355 * @brief The structure describes the read/write
1356 * modes of a single framebuffer attachment
1358 * The attachment description specifies what is going to
1359 * happen to the attachment at the beginning and end of the
1362 * The stencil operation is separated as it may be set
1363 * independent from the depth component (use loadOp, storeOp
1364 * to set up the depth component and stencilLoadOp, stencilStoreOp
1365 * for stencil component).
1367 struct AttachmentDescription
1370 * @brief Sets load operation for the attachment
1372 * @param value Load operation
1373 * @return this structure
1375 auto& SetLoadOp(AttachmentLoadOp value)
1382 * @brief Sets store operation for the attachment
1384 * @param value Store operation
1385 * @return this structure
1387 auto& SetStoreOp(AttachmentStoreOp value)
1394 * @brief Sets load operation for the stencil part of attachment
1396 * @param value load operation
1397 * @return this structure
1399 auto& SetStencilLoadOp(AttachmentLoadOp value)
1401 stencilLoadOp = value;
1406 * @brief Sets store operation for the stencil part of attachment
1408 * @param value store operation
1409 * @return this structure
1411 auto& SetStencilStoreOp(AttachmentStoreOp value)
1413 stencilStoreOp = value;
1417 AttachmentLoadOp loadOp{};
1418 AttachmentStoreOp storeOp{};
1419 AttachmentLoadOp stencilLoadOp{};
1420 AttachmentStoreOp stencilStoreOp{};
1424 * @brief Helper function to be used by the extension developers
1426 * The value of custom type must be unique and recognizable by the
1429 * @param customValue Custom value of GraphicsStructureType
1430 * @return Integer converted to GraphicsStructureType
1432 inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
1434 return static_cast<GraphicsStructureType>(customValue);
1438 * @brief The allocation callbacks may be passed when the object is created.
1440 struct AllocationCallbacks
1442 void* userData = nullptr; ///< User data passed to the allocator
1443 void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
1444 void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
1445 void (*freeCallback)(void* memory, void* userData) = nullptr;
1449 * @brief The ExtensionCreateInfo structure should be a base of any
1450 * extension create info structure. The structure isn't virtual
1451 * so the implementation must prevent slicing it.
1453 struct ExtensionCreateInfo
1455 GraphicsStructureType type{};
1456 ExtensionCreateInfo* nextExtension{};
1460 * @brief Default deleter for graphics unique pointers
1462 * Returned unique_ptr may require custom deleter. To get it working
1463 * with std::unique_ptr the custom type is used with polymorphic deleter
1466 struct DefaultDeleter
1468 DefaultDeleter() = default;
1471 * @brief Conversion constructor
1473 * This constructor will set the lambda for type passed
1476 template<class P, template<typename> typename U>
1477 DefaultDeleter(const U<P>& deleter)
1479 deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
1483 * @brief Conversion constructor from DefaultDelete<P>
1485 * This constructor transfers deleteFunction only
1488 explicit DefaultDeleter(const DefaultDeleter<P>& deleter)
1490 deleteFunction = decltype(deleteFunction)(deleter.deleteFunction);
1494 * @brief Default deleter
1496 * Default deleter will use standard 'delete' call in order
1497 * to discard graphics objects unless a custom deleter was
1500 * @param[in] object Object to delete
1502 void operator()(T* object)
1506 deleteFunction(object);
1514 void (*deleteFunction)(T* object){nullptr}; ///< Custom delete function
1518 * Surface type is just a void* to any native object.
1520 using Surface = void;
1523 * @brief Enum describing preTransform of render target
1525 enum class RenderTargetTransformFlagBits
1527 TRANSFORM_IDENTITY_BIT = 0x00000001,
1528 ROTATE_90_BIT = 0x00000002,
1529 ROTATE_180_BIT = 0x00000004,
1530 ROTATE_270_BIT = 0x00000008,
1531 HORIZONTAL_MIRROR_BIT = 0x00000010,
1532 HORIZONTAL_MIRROR_ROTATE_90_BIT = 0x00000020,
1533 HORIZONTAL_MIRROR_ROTATE_180_BIT = 0x00000040,
1534 HORIZONTAL_MIRROR_ROTATE_270_BIT = 0x00000080,
1537 using RenderTargetTransformFlags = uint32_t;
1539 template<typename T>
1540 inline RenderTargetTransformFlags operator|(T flags, RenderTargetTransformFlagBits bit)
1542 return static_cast<RenderTargetTransformFlags>(flags) | static_cast<RenderTargetTransformFlags>(bit);
1546 * unique_ptr defined in the Graphics scope
1548 template<class T, class D = DefaultDeleter<T>>
1549 using UniquePtr = std::unique_ptr<T, D>;
1552 * @brief MakeUnique<> version that returns Graphics::UniquePtr
1553 * @param[in] args Arguments for construction
1556 template<class T, class Deleter = DefaultDeleter<T>, class... Args>
1557 std::enable_if_t<!std::is_array<T>::value, Graphics::UniquePtr<T>>
1558 MakeUnique(Args&&... args)
1560 return UniquePtr<T>(new T(std::forward<Args>(args)...), Deleter());
1563 } // namespace Graphics
1566 #endif //DALI_GRAPHICS_API_TYPES_H