1 // 2 // Copyright 2013 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // imageformats.h: Defines image format types with functions for mip generation 8 // and copying. 9 10 #ifndef IMAGEUTIL_IMAGEFORMATS_H_ 11 #define IMAGEUTIL_IMAGEFORMATS_H_ 12 13 #include "common/Color.h" 14 15 #include <cstdint> 16 17 namespace angle 18 { 19 20 // Several structures share functionality for reading, writing or mipmapping but the layout 21 // must match the texture format which the structure represents. If collapsing or typedefing 22 // structs in this header, make sure the functionality and memory layout is exactly the same. 23 24 struct L8 25 { 26 uint8_t L; 27 28 static void readColor(gl::ColorF *dst, const L8 *src); 29 static void writeColor(L8 *dst, const gl::ColorF *src); 30 static void average(L8 *dst, const L8 *src1, const L8 *src2); 31 }; 32 33 struct R8 34 { 35 uint8_t R; 36 37 static void readColor(gl::ColorF *dst, const R8 *src); 38 static void readColor(gl::ColorUI *dst, const R8 *src); 39 static void writeColor(R8 *dst, const gl::ColorF *src); 40 static void writeColor(R8 *dst, const gl::ColorUI *src); 41 static void average(R8 *dst, const R8 *src1, const R8 *src2); 42 }; 43 44 struct A8 45 { 46 uint8_t A; 47 48 static void readColor(gl::ColorF *dst, const A8 *src); 49 static void writeColor(A8 *dst, const gl::ColorF *src); 50 static void average(A8 *dst, const A8 *src1, const A8 *src2); 51 }; 52 53 struct L8A8 54 { 55 uint8_t L; 56 uint8_t A; 57 58 static void readColor(gl::ColorF *dst, const L8A8 *src); 59 static void writeColor(L8A8 *dst, const gl::ColorF *src); 60 static void average(L8A8 *dst, const L8A8 *src1, const L8A8 *src2); 61 }; 62 63 struct A8L8 64 { 65 uint8_t A; 66 uint8_t L; 67 68 static void readColor(gl::ColorF *dst, const A8L8 *src); 69 static void writeColor(A8L8 *dst, const gl::ColorF *src); 70 static void average(A8L8 *dst, const A8L8 *src1, const A8L8 *src2); 71 }; 72 73 struct R8G8 74 { 75 uint8_t R; 76 uint8_t G; 77 78 static void readColor(gl::ColorF *dst, const R8G8 *src); 79 static void readColor(gl::ColorUI *dst, const R8G8 *src); 80 static void writeColor(R8G8 *dst, const gl::ColorF *src); 81 static void writeColor(R8G8 *dst, const gl::ColorUI *src); 82 static void average(R8G8 *dst, const R8G8 *src1, const R8G8 *src2); 83 }; 84 85 struct R8G8B8 86 { 87 uint8_t R; 88 uint8_t G; 89 uint8_t B; 90 91 static void readColor(gl::ColorF *dst, const R8G8B8 *src); 92 static void readColor(gl::ColorUI *dst, const R8G8B8 *src); 93 static void writeColor(R8G8B8 *dst, const gl::ColorF *src); 94 static void writeColor(R8G8B8 *dst, const gl::ColorUI *src); 95 static void average(R8G8B8 *dst, const R8G8B8 *src1, const R8G8B8 *src2); 96 }; 97 98 struct B8G8R8 99 { 100 uint8_t B; 101 uint8_t G; 102 uint8_t R; 103 104 static void readColor(gl::ColorF *dst, const B8G8R8 *src); 105 static void readColor(gl::ColorUI *dst, const B8G8R8 *src); 106 static void writeColor(B8G8R8 *dst, const gl::ColorF *src); 107 static void writeColor(B8G8R8 *dst, const gl::ColorUI *src); 108 static void average(B8G8R8 *dst, const B8G8R8 *src1, const B8G8R8 *src2); 109 }; 110 111 struct R5G6B5 112 { 113 // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the 114 // most significant bits of the bitfield, and successive component occupying progressively less 115 // significant locations" 116 uint16_t RGB; 117 118 static void readColor(gl::ColorF *dst, const R5G6B5 *src); 119 static void writeColor(R5G6B5 *dst, const gl::ColorF *src); 120 static void average(R5G6B5 *dst, const R5G6B5 *src1, const R5G6B5 *src2); 121 }; 122 123 struct B5G6R5 124 { 125 uint16_t BGR; 126 127 static void readColor(gl::ColorF *dst, const B5G6R5 *src); 128 static void writeColor(B5G6R5 *dst, const gl::ColorF *src); 129 static void average(B5G6R5 *dst, const B5G6R5 *src1, const B5G6R5 *src2); 130 }; 131 132 struct A8R8G8B8 133 { 134 uint8_t A; 135 uint8_t R; 136 uint8_t G; 137 uint8_t B; 138 139 static void readColor(gl::ColorF *dst, const A8R8G8B8 *src); 140 static void readColor(gl::ColorUI *dst, const A8R8G8B8 *src); 141 static void writeColor(A8R8G8B8 *dst, const gl::ColorF *src); 142 static void writeColor(A8R8G8B8 *dst, const gl::ColorUI *src); 143 static void average(A8R8G8B8 *dst, const A8R8G8B8 *src1, const A8R8G8B8 *src2); 144 }; 145 146 struct R8G8B8A8 147 { 148 uint8_t R; 149 uint8_t G; 150 uint8_t B; 151 uint8_t A; 152 153 static void readColor(gl::ColorF *dst, const R8G8B8A8 *src); 154 static void readColor(gl::ColorUI *dst, const R8G8B8A8 *src); 155 static void writeColor(R8G8B8A8 *dst, const gl::ColorF *src); 156 static void writeColor(R8G8B8A8 *dst, const gl::ColorUI *src); 157 static void average(R8G8B8A8 *dst, const R8G8B8A8 *src1, const R8G8B8A8 *src2); 158 }; 159 160 struct R8G8B8A8SRGB 161 { 162 uint8_t R; 163 uint8_t G; 164 uint8_t B; 165 uint8_t A; 166 167 static void readColor(gl::ColorF *dst, const R8G8B8A8SRGB *src); 168 static void writeColor(R8G8B8A8SRGB *dst, const gl::ColorF *src); 169 static void average(R8G8B8A8SRGB *dst, const R8G8B8A8SRGB *src1, const R8G8B8A8SRGB *src2); 170 }; 171 172 struct B8G8R8A8 173 { 174 uint8_t B; 175 uint8_t G; 176 uint8_t R; 177 uint8_t A; 178 179 static void readColor(gl::ColorF *dst, const B8G8R8A8 *src); 180 static void readColor(gl::ColorUI *dst, const B8G8R8A8 *src); 181 static void writeColor(B8G8R8A8 *dst, const gl::ColorF *src); 182 static void writeColor(B8G8R8A8 *dst, const gl::ColorUI *src); 183 static void average(B8G8R8A8 *dst, const B8G8R8A8 *src1, const B8G8R8A8 *src2); 184 }; 185 186 struct B8G8R8X8 187 { 188 uint8_t B; 189 uint8_t G; 190 uint8_t R; 191 uint8_t X; 192 193 static void readColor(gl::ColorF *dst, const B8G8R8X8 *src); 194 static void readColor(gl::ColorUI *dst, const B8G8R8X8 *src); 195 static void writeColor(B8G8R8X8 *dst, const gl::ColorF *src); 196 static void writeColor(B8G8R8X8 *dst, const gl::ColorUI *src); 197 static void average(B8G8R8X8 *dst, const B8G8R8X8 *src1, const B8G8R8X8 *src2); 198 }; 199 200 struct A1R5G5B5 201 { 202 uint16_t ARGB; 203 204 static void readColor(gl::ColorF *dst, const A1R5G5B5 *src); 205 static void writeColor(A1R5G5B5 *dst, const gl::ColorF *src); 206 static void average(A1R5G5B5 *dst, const A1R5G5B5 *src1, const A1R5G5B5 *src2); 207 }; 208 209 struct R5G5B5A1 210 { 211 // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the 212 // most significant 213 // bits of the bitfield, and successive component occupying progressively less significant 214 // locations" 215 uint16_t RGBA; 216 217 static void readColor(gl::ColorF *dst, const R5G5B5A1 *src); 218 static void writeColor(R5G5B5A1 *dst, const gl::ColorF *src); 219 static void average(R5G5B5A1 *dst, const R5G5B5A1 *src1, const R5G5B5A1 *src2); 220 }; 221 222 struct R4G4B4A4 223 { 224 // OpenGL ES 2.0.25 spec Section 3.6.2: "Components are packed with the first component in the 225 // most significant 226 // bits of the bitfield, and successive component occupying progressively less significant 227 // locations" 228 uint16_t RGBA; 229 230 static void readColor(gl::ColorF *dst, const R4G4B4A4 *src); 231 static void writeColor(R4G4B4A4 *dst, const gl::ColorF *src); 232 static void average(R4G4B4A4 *dst, const R4G4B4A4 *src1, const R4G4B4A4 *src2); 233 }; 234 235 struct A4R4G4B4 236 { 237 uint16_t ARGB; 238 239 static void readColor(gl::ColorF *dst, const A4R4G4B4 *src); 240 static void writeColor(A4R4G4B4 *dst, const gl::ColorF *src); 241 static void average(A4R4G4B4 *dst, const A4R4G4B4 *src1, const A4R4G4B4 *src2); 242 }; 243 244 struct R16 245 { 246 uint16_t R; 247 248 static void readColor(gl::ColorF *dst, const R16 *src); 249 static void readColor(gl::ColorUI *dst, const R16 *src); 250 static void writeColor(R16 *dst, const gl::ColorF *src); 251 static void writeColor(R16 *dst, const gl::ColorUI *src); 252 static void average(R16 *dst, const R16 *src1, const R16 *src2); 253 }; 254 255 struct R16G16 256 { 257 uint16_t R; 258 uint16_t G; 259 260 static void readColor(gl::ColorF *dst, const R16G16 *src); 261 static void readColor(gl::ColorUI *dst, const R16G16 *src); 262 static void writeColor(R16G16 *dst, const gl::ColorF *src); 263 static void writeColor(R16G16 *dst, const gl::ColorUI *src); 264 static void average(R16G16 *dst, const R16G16 *src1, const R16G16 *src2); 265 }; 266 267 struct R16G16B16 268 { 269 uint16_t R; 270 uint16_t G; 271 uint16_t B; 272 273 static void readColor(gl::ColorF *dst, const R16G16B16 *src); 274 static void readColor(gl::ColorUI *dst, const R16G16B16 *src); 275 static void writeColor(R16G16B16 *dst, const gl::ColorF *src); 276 static void writeColor(R16G16B16 *dst, const gl::ColorUI *src); 277 static void average(R16G16B16 *dst, const R16G16B16 *src1, const R16G16B16 *src2); 278 }; 279 280 struct R16G16B16A16 281 { 282 uint16_t R; 283 uint16_t G; 284 uint16_t B; 285 uint16_t A; 286 287 static void readColor(gl::ColorF *dst, const R16G16B16A16 *src); 288 static void readColor(gl::ColorUI *dst, const R16G16B16A16 *src); 289 static void writeColor(R16G16B16A16 *dst, const gl::ColorF *src); 290 static void writeColor(R16G16B16A16 *dst, const gl::ColorUI *src); 291 static void average(R16G16B16A16 *dst, const R16G16B16A16 *src1, const R16G16B16A16 *src2); 292 }; 293 294 struct R32 295 { 296 uint32_t R; 297 298 static void readColor(gl::ColorF *dst, const R32 *src); 299 static void readColor(gl::ColorUI *dst, const R32 *src); 300 static void writeColor(R32 *dst, const gl::ColorF *src); 301 static void writeColor(R32 *dst, const gl::ColorUI *src); 302 static void average(R32 *dst, const R32 *src1, const R32 *src2); 303 }; 304 305 struct R32G32 306 { 307 uint32_t R; 308 uint32_t G; 309 310 static void readColor(gl::ColorF *dst, const R32G32 *src); 311 static void readColor(gl::ColorUI *dst, const R32G32 *src); 312 static void writeColor(R32G32 *dst, const gl::ColorF *src); 313 static void writeColor(R32G32 *dst, const gl::ColorUI *src); 314 static void average(R32G32 *dst, const R32G32 *src1, const R32G32 *src2); 315 }; 316 317 struct R32G32B32 318 { 319 uint32_t R; 320 uint32_t G; 321 uint32_t B; 322 323 static void readColor(gl::ColorF *dst, const R32G32B32 *src); 324 static void readColor(gl::ColorUI *dst, const R32G32B32 *src); 325 static void writeColor(R32G32B32 *dst, const gl::ColorF *src); 326 static void writeColor(R32G32B32 *dst, const gl::ColorUI *src); 327 static void average(R32G32B32 *dst, const R32G32B32 *src1, const R32G32B32 *src2); 328 }; 329 330 struct R32G32B32A32 331 { 332 uint32_t R; 333 uint32_t G; 334 uint32_t B; 335 uint32_t A; 336 337 static void readColor(gl::ColorF *dst, const R32G32B32A32 *src); 338 static void readColor(gl::ColorUI *dst, const R32G32B32A32 *src); 339 static void writeColor(R32G32B32A32 *dst, const gl::ColorF *src); 340 static void writeColor(R32G32B32A32 *dst, const gl::ColorUI *src); 341 static void average(R32G32B32A32 *dst, const R32G32B32A32 *src1, const R32G32B32A32 *src2); 342 }; 343 344 struct R8S 345 { 346 int8_t R; 347 348 static void readColor(gl::ColorF *dst, const R8S *src); 349 static void readColor(gl::ColorI *dst, const R8S *src); 350 static void writeColor(R8S *dst, const gl::ColorF *src); 351 static void writeColor(R8S *dst, const gl::ColorI *src); 352 static void average(R8S *dst, const R8S *src1, const R8S *src2); 353 }; 354 355 struct R8G8S 356 { 357 int8_t R; 358 int8_t G; 359 360 static void readColor(gl::ColorF *dst, const R8G8S *src); 361 static void readColor(gl::ColorI *dst, const R8G8S *src); 362 static void writeColor(R8G8S *dst, const gl::ColorF *src); 363 static void writeColor(R8G8S *dst, const gl::ColorI *src); 364 static void average(R8G8S *dst, const R8G8S *src1, const R8G8S *src2); 365 }; 366 367 struct R8G8B8S 368 { 369 int8_t R; 370 int8_t G; 371 int8_t B; 372 373 static void readColor(gl::ColorF *dst, const R8G8B8S *src); 374 static void readColor(gl::ColorI *dst, const R8G8B8S *src); 375 static void writeColor(R8G8B8S *dst, const gl::ColorF *src); 376 static void writeColor(R8G8B8S *dst, const gl::ColorI *src); 377 static void average(R8G8B8S *dst, const R8G8B8S *src1, const R8G8B8S *src2); 378 }; 379 380 struct R8G8B8A8S 381 { 382 int8_t R; 383 int8_t G; 384 int8_t B; 385 int8_t A; 386 387 static void readColor(gl::ColorF *dst, const R8G8B8A8S *src); 388 static void readColor(gl::ColorI *dst, const R8G8B8A8S *src); 389 static void writeColor(R8G8B8A8S *dst, const gl::ColorF *src); 390 static void writeColor(R8G8B8A8S *dst, const gl::ColorI *src); 391 static void average(R8G8B8A8S *dst, const R8G8B8A8S *src1, const R8G8B8A8S *src2); 392 }; 393 394 struct R16S 395 { 396 int16_t R; 397 398 static void readColor(gl::ColorF *dst, const R16S *src); 399 static void readColor(gl::ColorI *dst, const R16S *src); 400 static void writeColor(R16S *dst, const gl::ColorF *src); 401 static void writeColor(R16S *dst, const gl::ColorI *src); 402 static void average(R16S *dst, const R16S *src1, const R16S *src2); 403 }; 404 405 struct R16G16S 406 { 407 int16_t R; 408 int16_t G; 409 410 static void readColor(gl::ColorF *dst, const R16G16S *src); 411 static void readColor(gl::ColorI *dst, const R16G16S *src); 412 static void writeColor(R16G16S *dst, const gl::ColorF *src); 413 static void writeColor(R16G16S *dst, const gl::ColorI *src); 414 static void average(R16G16S *dst, const R16G16S *src1, const R16G16S *src2); 415 }; 416 417 struct R16G16B16S 418 { 419 int16_t R; 420 int16_t G; 421 int16_t B; 422 423 static void readColor(gl::ColorF *dst, const R16G16B16S *src); 424 static void readColor(gl::ColorI *dst, const R16G16B16S *src); 425 static void writeColor(R16G16B16S *dst, const gl::ColorF *src); 426 static void writeColor(R16G16B16S *dst, const gl::ColorI *src); 427 static void average(R16G16B16S *dst, const R16G16B16S *src1, const R16G16B16S *src2); 428 }; 429 430 struct R16G16B16A16S 431 { 432 int16_t R; 433 int16_t G; 434 int16_t B; 435 int16_t A; 436 437 static void readColor(gl::ColorF *dst, const R16G16B16A16S *src); 438 static void readColor(gl::ColorI *dst, const R16G16B16A16S *src); 439 static void writeColor(R16G16B16A16S *dst, const gl::ColorF *src); 440 static void writeColor(R16G16B16A16S *dst, const gl::ColorI *src); 441 static void average(R16G16B16A16S *dst, const R16G16B16A16S *src1, const R16G16B16A16S *src2); 442 }; 443 444 struct R32S 445 { 446 int32_t R; 447 448 static void readColor(gl::ColorF *dst, const R32S *src); 449 static void readColor(gl::ColorI *dst, const R32S *src); 450 static void writeColor(R32S *dst, const gl::ColorF *src); 451 static void writeColor(R32S *dst, const gl::ColorI *src); 452 static void average(R32S *dst, const R32S *src1, const R32S *src2); 453 }; 454 455 struct R32G32S 456 { 457 int32_t R; 458 int32_t G; 459 460 static void readColor(gl::ColorF *dst, const R32G32S *src); 461 static void readColor(gl::ColorI *dst, const R32G32S *src); 462 static void writeColor(R32G32S *dst, const gl::ColorF *src); 463 static void writeColor(R32G32S *dst, const gl::ColorI *src); 464 static void average(R32G32S *dst, const R32G32S *src1, const R32G32S *src2); 465 }; 466 467 struct R32G32B32S 468 { 469 int32_t R; 470 int32_t G; 471 int32_t B; 472 473 static void readColor(gl::ColorF *dst, const R32G32B32S *src); 474 static void readColor(gl::ColorI *dst, const R32G32B32S *src); 475 static void writeColor(R32G32B32S *dst, const gl::ColorF *src); 476 static void writeColor(R32G32B32S *dst, const gl::ColorI *src); 477 static void average(R32G32B32S *dst, const R32G32B32S *src1, const R32G32B32S *src2); 478 }; 479 480 struct R32G32B32A32S 481 { 482 int32_t R; 483 int32_t G; 484 int32_t B; 485 int32_t A; 486 487 static void readColor(gl::ColorF *dst, const R32G32B32A32S *src); 488 static void readColor(gl::ColorI *dst, const R32G32B32A32S *src); 489 static void writeColor(R32G32B32A32S *dst, const gl::ColorF *src); 490 static void writeColor(R32G32B32A32S *dst, const gl::ColorI *src); 491 static void average(R32G32B32A32S *dst, const R32G32B32A32S *src1, const R32G32B32A32S *src2); 492 }; 493 494 struct A16B16G16R16F 495 { 496 uint16_t A; 497 uint16_t R; 498 uint16_t G; 499 uint16_t B; 500 501 static void readColor(gl::ColorF *dst, const A16B16G16R16F *src); 502 static void writeColor(A16B16G16R16F *dst, const gl::ColorF *src); 503 static void average(A16B16G16R16F *dst, const A16B16G16R16F *src1, const A16B16G16R16F *src2); 504 }; 505 506 struct R16G16B16A16F 507 { 508 uint16_t R; 509 uint16_t G; 510 uint16_t B; 511 uint16_t A; 512 513 static void readColor(gl::ColorF *dst, const R16G16B16A16F *src); 514 static void writeColor(R16G16B16A16F *dst, const gl::ColorF *src); 515 static void average(R16G16B16A16F *dst, const R16G16B16A16F *src1, const R16G16B16A16F *src2); 516 }; 517 518 struct R16F 519 { 520 uint16_t R; 521 522 static void readColor(gl::ColorF *dst, const R16F *src); 523 static void writeColor(R16F *dst, const gl::ColorF *src); 524 static void average(R16F *dst, const R16F *src1, const R16F *src2); 525 }; 526 527 struct A16F 528 { 529 uint16_t A; 530 531 static void readColor(gl::ColorF *dst, const A16F *src); 532 static void writeColor(A16F *dst, const gl::ColorF *src); 533 static void average(A16F *dst, const A16F *src1, const A16F *src2); 534 }; 535 536 struct L16F 537 { 538 uint16_t L; 539 540 static void readColor(gl::ColorF *dst, const L16F *src); 541 static void writeColor(L16F *dst, const gl::ColorF *src); 542 static void average(L16F *dst, const L16F *src1, const L16F *src2); 543 }; 544 545 struct L16A16F 546 { 547 uint16_t L; 548 uint16_t A; 549 550 static void readColor(gl::ColorF *dst, const L16A16F *src); 551 static void writeColor(L16A16F *dst, const gl::ColorF *src); 552 static void average(L16A16F *dst, const L16A16F *src1, const L16A16F *src2); 553 }; 554 555 struct R16G16F 556 { 557 uint16_t R; 558 uint16_t G; 559 560 static void readColor(gl::ColorF *dst, const R16G16F *src); 561 static void writeColor(R16G16F *dst, const gl::ColorF *src); 562 static void average(R16G16F *dst, const R16G16F *src1, const R16G16F *src2); 563 }; 564 565 struct R16G16B16F 566 { 567 uint16_t R; 568 uint16_t G; 569 uint16_t B; 570 571 static void readColor(gl::ColorF *dst, const R16G16B16F *src); 572 static void writeColor(R16G16B16F *dst, const gl::ColorF *src); 573 static void average(R16G16B16F *dst, const R16G16B16F *src1, const R16G16B16F *src2); 574 }; 575 576 struct A32B32G32R32F 577 { 578 float A; 579 float R; 580 float G; 581 float B; 582 583 static void readColor(gl::ColorF *dst, const A32B32G32R32F *src); 584 static void writeColor(A32B32G32R32F *dst, const gl::ColorF *src); 585 static void average(A32B32G32R32F *dst, const A32B32G32R32F *src1, const A32B32G32R32F *src2); 586 }; 587 588 struct R32G32B32A32F 589 { 590 float R; 591 float G; 592 float B; 593 float A; 594 595 static void readColor(gl::ColorF *dst, const R32G32B32A32F *src); 596 static void writeColor(R32G32B32A32F *dst, const gl::ColorF *src); 597 static void average(R32G32B32A32F *dst, const R32G32B32A32F *src1, const R32G32B32A32F *src2); 598 }; 599 600 struct R32F 601 { 602 float R; 603 604 static void readColor(gl::ColorF *dst, const R32F *src); 605 static void writeColor(R32F *dst, const gl::ColorF *src); 606 static void average(R32F *dst, const R32F *src1, const R32F *src2); 607 }; 608 609 struct A32F 610 { 611 float A; 612 613 static void readColor(gl::ColorF *dst, const A32F *src); 614 static void writeColor(A32F *dst, const gl::ColorF *src); 615 static void average(A32F *dst, const A32F *src1, const A32F *src2); 616 }; 617 618 struct L32F 619 { 620 float L; 621 622 static void readColor(gl::ColorF *dst, const L32F *src); 623 static void writeColor(L32F *dst, const gl::ColorF *src); 624 static void average(L32F *dst, const L32F *src1, const L32F *src2); 625 }; 626 627 struct L32A32F 628 { 629 float L; 630 float A; 631 632 static void readColor(gl::ColorF *dst, const L32A32F *src); 633 static void writeColor(L32A32F *dst, const gl::ColorF *src); 634 static void average(L32A32F *dst, const L32A32F *src1, const L32A32F *src2); 635 }; 636 637 struct R32G32F 638 { 639 float R; 640 float G; 641 642 static void readColor(gl::ColorF *dst, const R32G32F *src); 643 static void writeColor(R32G32F *dst, const gl::ColorF *src); 644 static void average(R32G32F *dst, const R32G32F *src1, const R32G32F *src2); 645 }; 646 647 struct R32G32B32F 648 { 649 float R; 650 float G; 651 float B; 652 653 static void readColor(gl::ColorF *dst, const R32G32B32F *src); 654 static void writeColor(R32G32B32F *dst, const gl::ColorF *src); 655 static void average(R32G32B32F *dst, const R32G32B32F *src1, const R32G32B32F *src2); 656 }; 657 658 struct R10G10B10A2 659 { 660 uint32_t R : 10; 661 uint32_t G : 10; 662 uint32_t B : 10; 663 uint32_t A : 2; 664 665 static void readColor(gl::ColorF *dst, const R10G10B10A2 *src); 666 static void readColor(gl::ColorUI *dst, const R10G10B10A2 *src); 667 static void writeColor(R10G10B10A2 *dst, const gl::ColorF *src); 668 static void writeColor(R10G10B10A2 *dst, const gl::ColorUI *src); 669 static void average(R10G10B10A2 *dst, const R10G10B10A2 *src1, const R10G10B10A2 *src2); 670 }; 671 static_assert(sizeof(R10G10B10A2) == 4, "R10G10B10A2 struct not 32-bits."); 672 673 struct R10G10B10A2S 674 { 675 int32_t R : 10; 676 int32_t G : 10; 677 int32_t B : 10; 678 int32_t A : 2; 679 680 static void readColor(gl::ColorF *dst, const R10G10B10A2S *src); 681 static void readColor(gl::ColorI *dst, const R10G10B10A2S *src); 682 static void writeColor(R10G10B10A2S *dst, const gl::ColorF *src); 683 static void writeColor(R10G10B10A2S *dst, const gl::ColorI *src); 684 static void average(R10G10B10A2S *dst, const R10G10B10A2S *src1, const R10G10B10A2S *src2); 685 }; 686 static_assert(sizeof(R10G10B10A2S) == 4, "R10G10B10A2S struct not 32-bits."); 687 688 struct R10G10B10X2 689 { 690 uint32_t R : 10; 691 uint32_t G : 10; 692 uint32_t B : 10; 693 694 static void readColor(gl::ColorF *dst, const R10G10B10X2 *src); 695 static void readColor(gl::ColorUI *dst, const R10G10B10X2 *src); 696 static void writeColor(R10G10B10X2 *dst, const gl::ColorF *src); 697 static void writeColor(R10G10B10X2 *dst, const gl::ColorUI *src); 698 static void average(R10G10B10X2 *dst, const R10G10B10X2 *src1, const R10G10B10X2 *src2); 699 }; 700 static_assert(sizeof(R10G10B10X2) == 4, "R10G10B10X2 struct not 32-bits."); 701 702 struct B10G10R10A2 703 { 704 uint32_t B : 10; 705 uint32_t G : 10; 706 uint32_t R : 10; 707 uint32_t A : 2; 708 709 static void readColor(gl::ColorF *dst, const B10G10R10A2 *src); 710 static void readColor(gl::ColorUI *dst, const B10G10R10A2 *src); 711 static void writeColor(B10G10R10A2 *dst, const gl::ColorF *src); 712 static void writeColor(B10G10R10A2 *dst, const gl::ColorUI *src); 713 static void average(B10G10R10A2 *dst, const B10G10R10A2 *src1, const B10G10R10A2 *src2); 714 }; 715 static_assert(sizeof(B10G10R10A2) == 4, "B10G10R10A2 struct not 32-bits."); 716 717 struct R9G9B9E5 718 { 719 uint32_t R : 9; 720 uint32_t G : 9; 721 uint32_t B : 9; 722 uint32_t E : 5; 723 724 static void readColor(gl::ColorF *dst, const R9G9B9E5 *src); 725 static void writeColor(R9G9B9E5 *dst, const gl::ColorF *src); 726 static void average(R9G9B9E5 *dst, const R9G9B9E5 *src1, const R9G9B9E5 *src2); 727 }; 728 static_assert(sizeof(R9G9B9E5) == 4, "R9G9B9E5 struct not 32-bits."); 729 730 struct R11G11B10F 731 { 732 uint32_t R : 11; 733 uint32_t G : 11; 734 uint32_t B : 10; 735 736 static void readColor(gl::ColorF *dst, const R11G11B10F *src); 737 static void writeColor(R11G11B10F *dst, const gl::ColorF *src); 738 static void average(R11G11B10F *dst, const R11G11B10F *src1, const R11G11B10F *src2); 739 }; 740 static_assert(sizeof(R11G11B10F) == 4, "R11G11B10F struct not 32-bits."); 741 742 struct D24S8 743 { 744 uint32_t S : 8; 745 uint32_t D : 24; 746 747 static void ReadDepthStencil(DepthStencil *dst, const D24S8 *src); 748 static void WriteDepthStencil(D24S8 *dst, const DepthStencil *src); 749 }; 750 751 struct S8 752 { 753 uint8_t S; 754 755 static void ReadDepthStencil(DepthStencil *dst, const S8 *src); 756 static void WriteDepthStencil(S8 *dst, const DepthStencil *src); 757 }; 758 759 struct D16 760 { 761 uint16_t D; 762 763 static void ReadDepthStencil(DepthStencil *dst, const D16 *src); 764 static void WriteDepthStencil(D16 *dst, const DepthStencil *src); 765 }; 766 767 struct D24X8 768 { 769 uint32_t D : 24; 770 uint32_t X : 8; 771 772 static void ReadDepthStencil(DepthStencil *dst, const D24X8 *src); 773 static void WriteDepthStencil(D24X8 *dst, const DepthStencil *src); 774 }; 775 776 struct D32F 777 { 778 float D; 779 780 static void ReadDepthStencil(DepthStencil *dst, const D32F *src); 781 static void WriteDepthStencil(D32F *dst, const DepthStencil *src); 782 }; 783 784 struct D32 785 { 786 uint32_t D; 787 788 static void ReadDepthStencil(DepthStencil *dst, const D32 *src); 789 static void WriteDepthStencil(D32 *dst, const DepthStencil *src); 790 }; 791 792 struct D32FS8X24 793 { 794 float D; 795 uint32_t S; 796 797 static void ReadDepthStencil(DepthStencil *dst, const D32FS8X24 *src); 798 static void WriteDepthStencil(D32FS8X24 *dst, const DepthStencil *src); 799 }; 800 } // namespace angle 801 802 #endif // IMAGEUTIL_IMAGEFORMATS_H_ 803