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)
997 uint32_t nativeHandle; ///< Native texture handle
1001 * @brief Texture tiling that directly refers to the tiling
1002 * mode supported by the Vulkan. Other implementations
1003 * of the backend may ignore the value.
1005 enum class TextureTiling
1012 * @brief Texture color attachment used by FramebufferCreateInfo
1014 struct ColorAttachment
1016 uint32_t attachmentId;
1023 * @brief Depth stencil attachment used by FramebufferCreateInfo
1025 struct DepthStencilAttachment
1029 WRITE, // If no texture, will create a RenderBuffer instead
1030 NONE // If no attachment/RenderBuffer required
1032 Texture* depthTexture{nullptr};
1033 Texture* stencilTexture{nullptr};
1034 uint32_t depthLevel{0};
1035 uint32_t stencilLevel{0};
1036 Usage depthUsage{Usage::NONE};
1037 Usage stencilUsage{Usage::NONE};
1041 * @brief Submit flags
1043 using SubmitFlags = uint32_t;
1048 enum class SubmitFlagBits : uint32_t
1050 FLUSH = 1 << 0, // Flush immediately
1051 DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
1054 template<typename T>
1055 inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
1057 return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
1061 * @brief Describes command buffers submission
1065 std::vector<CommandBuffer*> cmdBuffer;
1070 * @brief Shader language enum
1072 enum class ShaderLanguage
1082 * @brief Pipeline stages
1084 enum class PipelineStage
1091 TESSELATION_CONTROL,
1092 TESSELATION_EVALUATION,
1097 * @brief Vertex attribute format
1099 * TODO: to be replaced with Format
1101 enum class VertexInputAttributeFormat
1112 * @brief Uniform class
1114 enum class UniformClass
1118 COMBINED_IMAGE_SAMPLER,
1125 * @brief Type of texture
1127 enum class TextureType
1135 * @brief The information of the uniform
1139 std::string name{""};
1140 UniformClass uniformClass{UniformClass::UNDEFINED};
1141 uint32_t binding{0u};
1142 uint32_t bufferIndex{0u};
1143 uint32_t offset{0u};
1144 uint32_t location{0u};
1146 bool operator==(const UniformInfo& rhs)
1148 return name == rhs.name &&
1149 uniformClass == rhs.uniformClass &&
1150 binding == rhs.binding &&
1151 bufferIndex == rhs.bufferIndex &&
1152 offset == rhs.offset &&
1153 location == rhs.location;
1158 * @brief The information of the uniform block
1160 struct UniformBlockInfo
1162 std::string name{""};
1163 uint32_t descriptorSet{0u};
1164 uint32_t binding{0u};
1166 std::vector<UniformInfo> members{};
1170 * @brief Describes pipeline's shading stages
1172 * Shader state binds shader and pipeline stage that the
1173 * shader will be executed. The shader may be created with
1174 * pipeline stage and the pipelineStage member may be ignored
1175 * by setting inheritPipelineStage to true.
1179 const Shader* shader{nullptr}; // shader to attach
1180 PipelineStage pipelineStage{}; // pipeline stage to execute the shader
1181 bool inheritPipelineStage{false}; // stage inheritance
1183 auto& SetShader(const Shader& value)
1189 auto& SetPipelineStage(PipelineStage value)
1191 pipelineStage = value;
1195 auto& SetInheritPipelineStage(bool value)
1197 inheritPipelineStage = value;
1203 * @brief Flag determining usage of texture
1205 using TextureUsageFlags = uint32_t;
1206 enum class TextureUsageFlagBits : uint32_t
1209 COLOR_ATTACHMENT = 1 << 1,
1210 DEPTH_STENCIL_ATTACHMENT = 1 << 2,
1214 template<typename T>
1215 inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
1217 return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
1220 using TextureFormat = Dali::Graphics::Format;
1223 * @brief Texture mipmap disable/enable enum
1225 enum class TextureMipMapFlag
1232 * @brief Depth/stencil attachment flag
1234 enum class TextureDepthStencilFlag
1243 * @brief Layout of texture
1245 * Specifies how the memory will be allocated, organized and accessed.
1247 enum class TextureLayout
1249 LINEAR, ///< Creates linear memory, mapping possible
1250 OPTIMAL ///< Usually, read-only memory, driver-optimal layout
1254 * @brief Level of command buffer
1256 enum class CommandBufferLevel
1258 PRIMARY, ///< Primary buffer can be executed on its own
1259 SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
1263 * @brief Enum indicating whether shader source
1264 * is text-based or binary.
1266 enum class ShaderSourceMode
1273 * @brief Memory usage flags to be set when mapping the buffer
1275 using MemoryUsageFlags = uint32_t;
1276 enum class MemoryUsageFlagBits : uint32_t
1280 PERSISTENT = 1 << 2,
1281 ASYNCHRONOUS = 1 << 3,
1285 template<typename T>
1286 inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
1288 return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
1292 * @brief Describes buffer mapping details
1294 struct MapBufferInfo
1297 MemoryUsageFlags usage;
1303 * @brief Describes buffer mapping details
1304 * TODO: mapping by texture level and layer
1306 struct MapTextureInfo
1309 MemoryUsageFlags usage;
1315 * @brief GraphicsStructureType enum is used by all create info structures
1316 * in order to identify by the implementation which structure it is
1319 enum class GraphicsStructureType : uint32_t
1321 BUFFER_CREATE_INFO_STRUCT,
1322 COMMAND_BUFFER_CREATE_INFO_STRUCT,
1323 FRAMEBUFFER_CREATE_INFO_STRUCT,
1324 PROGRAM_CREATE_INFO_STRUCT,
1325 PIPELINE_CREATE_INFO_STRUCT,
1326 RENDERPASS_CREATE_INFO_STRUCT,
1327 SAMPLER_CREATE_INFO_STRUCT,
1328 SHADER_CREATE_INFO_STRUCT,
1329 TEXTURE_CREATE_INFO_STRUCT,
1330 RENDER_TARGET_CREATE_INFO_STRUCT,
1331 SYNC_OBJECT_CREATE_INFO_STRUCT
1335 * @brief Enum describes load operation associated
1336 * with particular framebuffer attachment
1338 enum class AttachmentLoadOp
1340 LOAD, ///< Load previous content
1341 CLEAR, ///< Clear the attachment
1342 DONT_CARE ///< Let driver decide
1346 * @brief Enum describes store operation associated
1347 * with particular framebuffer attachment
1349 enum class AttachmentStoreOp
1351 STORE, ///< Store content (color attachemnts)
1352 DONT_CARE ///< Let driver decide (depth/stencil attachemnt with no intention of reading)
1356 * @brief The structure describes the read/write
1357 * modes of a single framebuffer attachment
1359 * The attachment description specifies what is going to
1360 * happen to the attachment at the beginning and end of the
1363 * The stencil operation is separated as it may be set
1364 * independent from the depth component (use loadOp, storeOp
1365 * to set up the depth component and stencilLoadOp, stencilStoreOp
1366 * for stencil component).
1368 struct AttachmentDescription
1371 * @brief Sets load operation for the attachment
1373 * @param value Load operation
1374 * @return this structure
1376 auto& SetLoadOp(AttachmentLoadOp value)
1383 * @brief Sets store operation for the attachment
1385 * @param value Store operation
1386 * @return this structure
1388 auto& SetStoreOp(AttachmentStoreOp value)
1395 * @brief Sets load operation for the stencil part of attachment
1397 * @param value load operation
1398 * @return this structure
1400 auto& SetStencilLoadOp(AttachmentLoadOp value)
1402 stencilLoadOp = value;
1407 * @brief Sets store operation for the stencil part of attachment
1409 * @param value store operation
1410 * @return this structure
1412 auto& SetStencilStoreOp(AttachmentStoreOp value)
1414 stencilStoreOp = value;
1418 AttachmentLoadOp loadOp{};
1419 AttachmentStoreOp storeOp{};
1420 AttachmentLoadOp stencilLoadOp{};
1421 AttachmentStoreOp stencilStoreOp{};
1425 * @brief Helper function to be used by the extension developers
1427 * The value of custom type must be unique and recognizable by the
1430 * @param customValue Custom value of GraphicsStructureType
1431 * @return Integer converted to GraphicsStructureType
1433 inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
1435 return static_cast<GraphicsStructureType>(customValue);
1439 * @brief The allocation callbacks may be passed when the object is created.
1441 struct AllocationCallbacks
1443 void* userData = nullptr; ///< User data passed to the allocator
1444 void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
1445 void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
1446 void (*freeCallback)(void* memory, void* userData) = nullptr;
1450 * @brief The ExtensionCreateInfo structure should be a base of any
1451 * extension create info structure. The structure isn't virtual
1452 * so the implementation must prevent slicing it.
1454 struct ExtensionCreateInfo
1456 GraphicsStructureType type{};
1457 ExtensionCreateInfo* nextExtension{};
1461 * @brief Default deleter for graphics unique pointers
1463 * Returned unique_ptr may require custom deleter. To get it working
1464 * with std::unique_ptr the custom type is used with polymorphic deleter
1467 struct DefaultDeleter
1469 DefaultDeleter() = default;
1472 * @brief Conversion constructor
1474 * This constructor will set the lambda for type passed
1477 template<class P, template<typename> typename U>
1478 DefaultDeleter(const U<P>& deleter)
1480 deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
1484 * @brief Conversion constructor from DefaultDelete<P>
1486 * This constructor transfers deleteFunction only
1489 explicit DefaultDeleter(const DefaultDeleter<P>& deleter)
1491 deleteFunction = decltype(deleteFunction)(deleter.deleteFunction);
1495 * @brief Default deleter
1497 * Default deleter will use standard 'delete' call in order
1498 * to discard graphics objects unless a custom deleter was
1501 * @param[in] object Object to delete
1503 void operator()(T* object)
1507 deleteFunction(object);
1515 void (*deleteFunction)(T* object){nullptr}; ///< Custom delete function
1519 * Surface type is just a void* to any native object.
1521 using Surface = void;
1524 * @brief Enum describing preTransform of render target
1526 enum class RenderTargetTransformFlagBits
1528 TRANSFORM_IDENTITY_BIT = 0x00000001,
1529 ROTATE_90_BIT = 0x00000002,
1530 ROTATE_180_BIT = 0x00000004,
1531 ROTATE_270_BIT = 0x00000008,
1532 HORIZONTAL_MIRROR_BIT = 0x00000010,
1533 HORIZONTAL_MIRROR_ROTATE_90_BIT = 0x00000020,
1534 HORIZONTAL_MIRROR_ROTATE_180_BIT = 0x00000040,
1535 HORIZONTAL_MIRROR_ROTATE_270_BIT = 0x00000080,
1538 using RenderTargetTransformFlags = uint32_t;
1540 template<typename T>
1541 inline RenderTargetTransformFlags operator|(T flags, RenderTargetTransformFlagBits bit)
1543 return static_cast<RenderTargetTransformFlags>(flags) | static_cast<RenderTargetTransformFlags>(bit);
1547 * unique_ptr defined in the Graphics scope
1549 template<class T, class D = DefaultDeleter<T>>
1550 using UniquePtr = std::unique_ptr<T, D>;
1553 * @brief MakeUnique<> version that returns Graphics::UniquePtr
1554 * @param[in] args Arguments for construction
1557 template<class T, class Deleter = DefaultDeleter<T>, class... Args>
1558 std::enable_if_t<!std::is_array<T>::value, Graphics::UniquePtr<T>>
1559 MakeUnique(Args&&... args)
1561 return UniquePtr<T>(new T(std::forward<Args>(args)...), Deleter());
1564 } // namespace Graphics
1567 #endif //DALI_GRAPHICS_API_TYPES_H