1 #ifndef DALI_GRAPHICS_TEXTURE_UPLOAD_INTERFACE_H
2 #define DALI_GRAPHICS_TEXTURE_UPLOAD_INTERFACE_H
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.
22 #include <dali/public-api/rendering/texture.h>
25 #include "graphics-types.h"
32 * @brief Structure used to pass parameters to the Upload method
36 uint32_t dataXOffset; ///< Specifies a pixeldata offset in the x direction within the pixeldata buffer.
37 uint32_t dataYOffset; ///< Specifies a pixeldata offset in the y direction within the pixeldata buffer.
38 uint16_t dataWidth; ///< Specifies the width of the pixeldata subimage.
39 uint16_t dataHeight; ///< Specifies the height of the pixeldata subimage.
40 uint16_t layer; ///< Specifies the layer of a cube map or array texture
41 uint16_t mipmap; ///< Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
42 uint16_t xOffset; ///< Specifies a texel offset in the x direction within the texture array.
43 uint16_t yOffset; ///< Specifies a texel offset in the y direction within the texture array.
44 uint16_t width; ///< Specifies the width of the texture subimage
45 uint16_t height; ///< Specifies the height of the texture subimage.
49 * @brief Converts DALi pixel format to Graphics::Format.
50 * @param[in] format Dali::Pixel::Format.
51 * @return Converted Graphics::Format.
53 constexpr Graphics::Format ConvertPixelFormat(Dali::Pixel::Format format)
58 return Graphics::Format::UNDEFINED;
60 return Graphics::Format::R8_UNORM;
63 return Graphics::Format::L8;
65 return Graphics::Format::L8A8;
67 return Graphics::Format::R5G6B5_UNORM_PACK16;
69 return Graphics::Format::B5G6R5_UNORM_PACK16;
71 return Graphics::Format::R4G4B4A4_UNORM_PACK16;
74 return Graphics::Format::B4G4R4A4_UNORM_PACK16;
76 return Graphics::Format::R5G5B5A1_UNORM_PACK16;
78 return Graphics::Format::B5G5R5A1_UNORM_PACK16;
80 return Graphics::Format::R8G8B8_UNORM;
82 return Graphics::Format::R8G8B8A8_UNORM;
84 return Graphics::Format::B8G8R8A8_UNORM;
86 return Graphics::Format::R8G8B8A8_UNORM;
88 return Graphics::Format::B8G8R8A8_UNORM;
90 case Pixel::DEPTH_UNSIGNED_INT:
91 return Graphics::Format::D16_UNORM;
92 case Pixel::DEPTH_FLOAT:
93 return Graphics::Format::D32_SFLOAT;
94 case Pixel::DEPTH_STENCIL:
95 return Graphics::Format::D24_UNORM_S8_UINT;
98 case Pixel::COMPRESSED_R11_EAC:
99 return Graphics::Format::EAC_R11_UNORM_BLOCK;
100 case Pixel::COMPRESSED_SIGNED_R11_EAC:
101 return Graphics::Format::EAC_R11_SNORM_BLOCK;
102 case Pixel::COMPRESSED_RG11_EAC:
103 return Graphics::Format::EAC_R11G11_UNORM_BLOCK;
104 case Pixel::COMPRESSED_SIGNED_RG11_EAC:
105 return Graphics::Format::EAC_R11G11_SNORM_BLOCK;
108 case Pixel::COMPRESSED_RGB8_ETC2:
109 return Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK;
110 case Pixel::COMPRESSED_SRGB8_ETC2:
111 return Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK;
113 case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
114 return Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK; // no 'punchthrough' format
116 case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
117 return Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK; // no 'punchthrough' format
119 case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
120 return Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK;
122 case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
123 return Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK;
125 case Pixel::COMPRESSED_RGB8_ETC1:
126 return Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK; // doesn't seem to be supported at all
128 case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1:
129 return Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG; // or SRGB?
132 case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR:
133 return Graphics::Format::ASTC_4x4_UNORM_BLOCK; // or SRGB?
134 case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR:
135 return Graphics::Format::ASTC_5x4_UNORM_BLOCK;
136 case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR:
137 return Graphics::Format::ASTC_5x5_UNORM_BLOCK;
138 case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR:
139 return Graphics::Format::ASTC_6x5_UNORM_BLOCK;
140 case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR:
141 return Graphics::Format::ASTC_6x6_UNORM_BLOCK;
142 case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR:
143 return Graphics::Format::ASTC_8x5_UNORM_BLOCK;
144 case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR:
145 return Graphics::Format::ASTC_8x6_UNORM_BLOCK;
146 case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR:
147 return Graphics::Format::ASTC_8x8_UNORM_BLOCK;
148 case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR:
149 return Graphics::Format::ASTC_10x5_UNORM_BLOCK;
150 case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR:
151 return Graphics::Format::ASTC_10x6_UNORM_BLOCK;
152 case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR:
153 return Graphics::Format::ASTC_10x8_UNORM_BLOCK;
154 case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR:
155 return Graphics::Format::ASTC_10x10_UNORM_BLOCK;
156 case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR:
157 return Graphics::Format::ASTC_12x10_UNORM_BLOCK;
158 case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR:
159 return Graphics::Format::ASTC_12x12_UNORM_BLOCK;
160 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
161 return Graphics::Format::ASTC_4x4_SRGB_BLOCK; // not type with alpha, but likely to use SRGB
162 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
163 return Graphics::Format::ASTC_5x4_SRGB_BLOCK;
164 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
165 return Graphics::Format::ASTC_5x5_SRGB_BLOCK;
166 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
167 return Graphics::Format::ASTC_6x5_SRGB_BLOCK;
168 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
169 return Graphics::Format::ASTC_6x6_SRGB_BLOCK;
170 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
171 return Graphics::Format::ASTC_8x5_SRGB_BLOCK;
172 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
173 return Graphics::Format::ASTC_8x6_UNORM_BLOCK;
174 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
175 return Graphics::Format::ASTC_8x8_SRGB_BLOCK;
176 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
177 return Graphics::Format::ASTC_10x5_SRGB_BLOCK;
178 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
179 return Graphics::Format::ASTC_10x6_SRGB_BLOCK;
180 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
181 return Graphics::Format::ASTC_10x8_SRGB_BLOCK;
182 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
183 return Graphics::Format::ASTC_10x10_SRGB_BLOCK;
184 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
185 return Graphics::Format::ASTC_12x10_SRGB_BLOCK;
186 case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
187 return Graphics::Format::ASTC_12x12_SRGB_BLOCK;
190 return Graphics::Format::R16G16B16_SFLOAT;
192 return Graphics::Format::R32G32B32_SFLOAT;
193 case Pixel::R11G11B10F:
194 return Graphics::Format::R11G11B10_UFLOAT_PACK32;
196 case Pixel::CHROMINANCE_U:
197 return Graphics::Format::L8;
198 case Pixel::CHROMINANCE_V:
199 return Graphics::Format::L8;
201 return Graphics::Format::UNDEFINED;
205 * @brief Converts DALi texture type to Graphics::TextureType.
207 * @param[in] type Dali::Texture::Type.
208 * @return converted Graphics::TextureType.
210 constexpr Graphics::TextureType ConvertTextureType(Dali::TextureType::Type type)
214 case Dali::TextureType::TEXTURE_2D:
215 return Graphics::TextureType::TEXTURE_2D;
216 case Dali::TextureType::TEXTURE_CUBE:
217 return Graphics::TextureType::TEXTURE_CUBEMAP;
219 return Graphics::TextureType::TEXTURE_2D;
222 } // namespace Graphics
225 #endif // DALI_GRAPHICS_TEXTURE_UPLOAD_INTERFACE_H