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 // loadimage.h: Defines image loading functions 8 9 #ifndef IMAGEUTIL_LOADIMAGE_H_ 10 #define IMAGEUTIL_LOADIMAGE_H_ 11 12 #include <stddef.h> 13 #include <stdint.h> 14 15 namespace angle 16 { 17 18 void LoadA8ToRGBA8(size_t width, 19 size_t height, 20 size_t depth, 21 const uint8_t *input, 22 size_t inputRowPitch, 23 size_t inputDepthPitch, 24 uint8_t *output, 25 size_t outputRowPitch, 26 size_t outputDepthPitch); 27 28 void LoadA8ToBGRA8(size_t width, 29 size_t height, 30 size_t depth, 31 const uint8_t *input, 32 size_t inputRowPitch, 33 size_t inputDepthPitch, 34 uint8_t *output, 35 size_t outputRowPitch, 36 size_t outputDepthPitch); 37 38 void LoadA32FToRGBA32F(size_t width, 39 size_t height, 40 size_t depth, 41 const uint8_t *input, 42 size_t inputRowPitch, 43 size_t inputDepthPitch, 44 uint8_t *output, 45 size_t outputRowPitch, 46 size_t outputDepthPitch); 47 48 void LoadA16FToRGBA16F(size_t width, 49 size_t height, 50 size_t depth, 51 const uint8_t *input, 52 size_t inputRowPitch, 53 size_t inputDepthPitch, 54 uint8_t *output, 55 size_t outputRowPitch, 56 size_t outputDepthPitch); 57 58 void LoadL8ToRGBA8(size_t width, 59 size_t height, 60 size_t depth, 61 const uint8_t *input, 62 size_t inputRowPitch, 63 size_t inputDepthPitch, 64 uint8_t *output, 65 size_t outputRowPitch, 66 size_t outputDepthPitch); 67 68 void LoadL8ToBGRA8(size_t width, 69 size_t height, 70 size_t depth, 71 const uint8_t *input, 72 size_t inputRowPitch, 73 size_t inputDepthPitch, 74 uint8_t *output, 75 size_t outputRowPitch, 76 size_t outputDepthPitch); 77 78 void LoadL32FToRGBA32F(size_t width, 79 size_t height, 80 size_t depth, 81 const uint8_t *input, 82 size_t inputRowPitch, 83 size_t inputDepthPitch, 84 uint8_t *output, 85 size_t outputRowPitch, 86 size_t outputDepthPitch); 87 88 void LoadL16FToRGBA16F(size_t width, 89 size_t height, 90 size_t depth, 91 const uint8_t *input, 92 size_t inputRowPitch, 93 size_t inputDepthPitch, 94 uint8_t *output, 95 size_t outputRowPitch, 96 size_t outputDepthPitch); 97 98 void LoadLA8ToRGBA8(size_t width, 99 size_t height, 100 size_t depth, 101 const uint8_t *input, 102 size_t inputRowPitch, 103 size_t inputDepthPitch, 104 uint8_t *output, 105 size_t outputRowPitch, 106 size_t outputDepthPitch); 107 108 void LoadLA8ToBGRA8(size_t width, 109 size_t height, 110 size_t depth, 111 const uint8_t *input, 112 size_t inputRowPitch, 113 size_t inputDepthPitch, 114 uint8_t *output, 115 size_t outputRowPitch, 116 size_t outputDepthPitch); 117 118 void LoadLA32FToRGBA32F(size_t width, 119 size_t height, 120 size_t depth, 121 const uint8_t *input, 122 size_t inputRowPitch, 123 size_t inputDepthPitch, 124 uint8_t *output, 125 size_t outputRowPitch, 126 size_t outputDepthPitch); 127 128 void LoadLA16FToRGBA16F(size_t width, 129 size_t height, 130 size_t depth, 131 const uint8_t *input, 132 size_t inputRowPitch, 133 size_t inputDepthPitch, 134 uint8_t *output, 135 size_t outputRowPitch, 136 size_t outputDepthPitch); 137 138 void LoadRGB8ToBGR565(size_t width, 139 size_t height, 140 size_t depth, 141 const uint8_t *input, 142 size_t inputRowPitch, 143 size_t inputDepthPitch, 144 uint8_t *output, 145 size_t outputRowPitch, 146 size_t outputDepthPitch); 147 148 void LoadRGB565ToBGR565(size_t width, 149 size_t height, 150 size_t depth, 151 const uint8_t *input, 152 size_t inputRowPitch, 153 size_t inputDepthPitch, 154 uint8_t *output, 155 size_t outputRowPitch, 156 size_t outputDepthPitch); 157 158 void LoadRGB8ToBGRX8(size_t width, 159 size_t height, 160 size_t depth, 161 const uint8_t *input, 162 size_t inputRowPitch, 163 size_t inputDepthPitch, 164 uint8_t *output, 165 size_t outputRowPitch, 166 size_t outputDepthPitch); 167 168 void LoadRG8ToBGRX8(size_t width, 169 size_t height, 170 size_t depth, 171 const uint8_t *input, 172 size_t inputRowPitch, 173 size_t inputDepthPitch, 174 uint8_t *output, 175 size_t outputRowPitch, 176 size_t outputDepthPitch); 177 178 void LoadR8ToBGRX8(size_t width, 179 size_t height, 180 size_t depth, 181 const uint8_t *input, 182 size_t inputRowPitch, 183 size_t inputDepthPitch, 184 uint8_t *output, 185 size_t outputRowPitch, 186 size_t outputDepthPitch); 187 188 void LoadR5G6B5ToBGRA8(size_t width, 189 size_t height, 190 size_t depth, 191 const uint8_t *input, 192 size_t inputRowPitch, 193 size_t inputDepthPitch, 194 uint8_t *output, 195 size_t outputRowPitch, 196 size_t outputDepthPitch); 197 198 void LoadR5G6B5ToRGBA8(size_t width, 199 size_t height, 200 size_t depth, 201 const uint8_t *input, 202 size_t inputRowPitch, 203 size_t inputDepthPitch, 204 uint8_t *output, 205 size_t outputRowPitch, 206 size_t outputDepthPitch); 207 208 void LoadRGBA8ToBGRA8(size_t width, 209 size_t height, 210 size_t depth, 211 const uint8_t *input, 212 size_t inputRowPitch, 213 size_t inputDepthPitch, 214 uint8_t *output, 215 size_t outputRowPitch, 216 size_t outputDepthPitch); 217 218 void LoadRGBA8ToBGRA4(size_t width, 219 size_t height, 220 size_t depth, 221 const uint8_t *input, 222 size_t inputRowPitch, 223 size_t inputDepthPitch, 224 uint8_t *output, 225 size_t outputRowPitch, 226 size_t outputDepthPitch); 227 228 void LoadRGBA4ToARGB4(size_t width, 229 size_t height, 230 size_t depth, 231 const uint8_t *input, 232 size_t inputRowPitch, 233 size_t inputDepthPitch, 234 uint8_t *output, 235 size_t outputRowPitch, 236 size_t outputDepthPitch); 237 238 void LoadRGBA4ToBGRA8(size_t width, 239 size_t height, 240 size_t depth, 241 const uint8_t *input, 242 size_t inputRowPitch, 243 size_t inputDepthPitch, 244 uint8_t *output, 245 size_t outputRowPitch, 246 size_t outputDepthPitch); 247 248 void LoadRGBA4ToRGBA8(size_t width, 249 size_t height, 250 size_t depth, 251 const uint8_t *input, 252 size_t inputRowPitch, 253 size_t inputDepthPitch, 254 uint8_t *output, 255 size_t outputRowPitch, 256 size_t outputDepthPitch); 257 258 void LoadBGRA4ToBGRA8(size_t width, 259 size_t height, 260 size_t depth, 261 const uint8_t *input, 262 size_t inputRowPitch, 263 size_t inputDepthPitch, 264 uint8_t *output, 265 size_t outputRowPitch, 266 size_t outputDepthPitch); 267 268 void LoadRGBA8ToBGR5A1(size_t width, 269 size_t height, 270 size_t depth, 271 const uint8_t *input, 272 size_t inputRowPitch, 273 size_t inputDepthPitch, 274 uint8_t *output, 275 size_t outputRowPitch, 276 size_t outputDepthPitch); 277 278 void LoadRGB10A2ToBGR5A1(size_t width, 279 size_t height, 280 size_t depth, 281 const uint8_t *input, 282 size_t inputRowPitch, 283 size_t inputDepthPitch, 284 uint8_t *output, 285 size_t outputRowPitch, 286 size_t outputDepthPitch); 287 288 void LoadRGB5A1ToA1RGB5(size_t width, 289 size_t height, 290 size_t depth, 291 const uint8_t *input, 292 size_t inputRowPitch, 293 size_t inputDepthPitch, 294 uint8_t *output, 295 size_t outputRowPitch, 296 size_t outputDepthPitch); 297 298 void LoadRGB5A1ToBGRA8(size_t width, 299 size_t height, 300 size_t depth, 301 const uint8_t *input, 302 size_t inputRowPitch, 303 size_t inputDepthPitch, 304 uint8_t *output, 305 size_t outputRowPitch, 306 size_t outputDepthPitch); 307 308 void LoadRGB5A1ToRGBA8(size_t width, 309 size_t height, 310 size_t depth, 311 const uint8_t *input, 312 size_t inputRowPitch, 313 size_t inputDepthPitch, 314 uint8_t *output, 315 size_t outputRowPitch, 316 size_t outputDepthPitch); 317 318 void LoadBGR5A1ToBGRA8(size_t width, 319 size_t height, 320 size_t depth, 321 const uint8_t *input, 322 size_t inputRowPitch, 323 size_t inputDepthPitch, 324 uint8_t *output, 325 size_t outputRowPitch, 326 size_t outputDepthPitch); 327 328 void LoadRGB10A2ToRGBA8(size_t width, 329 size_t height, 330 size_t depth, 331 const uint8_t *input, 332 size_t inputRowPitch, 333 size_t inputDepthPitch, 334 uint8_t *output, 335 size_t outputRowPitch, 336 size_t outputDepthPitch); 337 338 void LoadRGB16FToRGB9E5(size_t width, 339 size_t height, 340 size_t depth, 341 const uint8_t *input, 342 size_t inputRowPitch, 343 size_t inputDepthPitch, 344 uint8_t *output, 345 size_t outputRowPitch, 346 size_t outputDepthPitch); 347 348 void LoadRGB32FToRGB9E5(size_t width, 349 size_t height, 350 size_t depth, 351 const uint8_t *input, 352 size_t inputRowPitch, 353 size_t inputDepthPitch, 354 uint8_t *output, 355 size_t outputRowPitch, 356 size_t outputDepthPitch); 357 358 void LoadRGB16FToRG11B10F(size_t width, 359 size_t height, 360 size_t depth, 361 const uint8_t *input, 362 size_t inputRowPitch, 363 size_t inputDepthPitch, 364 uint8_t *output, 365 size_t outputRowPitch, 366 size_t outputDepthPitch); 367 368 void LoadRGB32FToRG11B10F(size_t width, 369 size_t height, 370 size_t depth, 371 const uint8_t *input, 372 size_t inputRowPitch, 373 size_t inputDepthPitch, 374 uint8_t *output, 375 size_t outputRowPitch, 376 size_t outputDepthPitch); 377 378 void LoadG8R24ToR24G8(size_t width, 379 size_t height, 380 size_t depth, 381 const uint8_t *input, 382 size_t inputRowPitch, 383 size_t inputDepthPitch, 384 uint8_t *output, 385 size_t outputRowPitch, 386 size_t outputDepthPitch); 387 388 void LoadD24S8ToD32FS8X24(size_t width, 389 size_t height, 390 size_t depth, 391 const uint8_t *input, 392 size_t inputRowPitch, 393 size_t inputDepthPitch, 394 uint8_t *output, 395 size_t outputRowPitch, 396 size_t outputDepthPitch); 397 398 void LoadD32FToD32F(size_t width, 399 size_t height, 400 size_t depth, 401 const uint8_t *input, 402 size_t inputRowPitch, 403 size_t inputDepthPitch, 404 uint8_t *output, 405 size_t outputRowPitch, 406 size_t outputDepthPitch); 407 408 void LoadD32FS8X24ToD24S8(size_t width, 409 size_t height, 410 size_t depth, 411 const uint8_t *input, 412 size_t inputRowPitch, 413 size_t inputDepthPitch, 414 uint8_t *output, 415 size_t outputRowPitch, 416 size_t outputDepthPitch); 417 418 void LoadX24S8ToS8(size_t width, 419 size_t height, 420 size_t depth, 421 const uint8_t *input, 422 size_t inputRowPitch, 423 size_t inputDepthPitch, 424 uint8_t *output, 425 size_t outputRowPitch, 426 size_t outputDepthPitch); 427 428 void LoadX32S8ToS8(size_t width, 429 size_t height, 430 size_t depth, 431 const uint8_t *input, 432 size_t inputRowPitch, 433 size_t inputDepthPitch, 434 uint8_t *output, 435 size_t outputRowPitch, 436 size_t outputDepthPitch); 437 438 void LoadD32FS8X24ToD32F(size_t width, 439 size_t height, 440 size_t depth, 441 const uint8_t *input, 442 size_t inputRowPitch, 443 size_t inputDepthPitch, 444 uint8_t *output, 445 size_t outputRowPitch, 446 size_t outputDepthPitch); 447 448 void LoadD32FS8X24ToD32FS8X24(size_t width, 449 size_t height, 450 size_t depth, 451 const uint8_t *input, 452 size_t inputRowPitch, 453 size_t inputDepthPitch, 454 uint8_t *output, 455 size_t outputRowPitch, 456 size_t outputDepthPitch); 457 458 template <typename type, size_t componentCount> 459 inline void LoadToNative(size_t width, 460 size_t height, 461 size_t depth, 462 const uint8_t *input, 463 size_t inputRowPitch, 464 size_t inputDepthPitch, 465 uint8_t *output, 466 size_t outputRowPitch, 467 size_t outputDepthPitch); 468 469 template <typename type, uint32_t fourthComponentBits> 470 inline void LoadToNative3To4(size_t width, 471 size_t height, 472 size_t depth, 473 const uint8_t *input, 474 size_t inputRowPitch, 475 size_t inputDepthPitch, 476 uint8_t *output, 477 size_t outputRowPitch, 478 size_t outputDepthPitch); 479 480 template <size_t componentCount> 481 inline void Load32FTo16F(size_t width, 482 size_t height, 483 size_t depth, 484 const uint8_t *input, 485 size_t inputRowPitch, 486 size_t inputDepthPitch, 487 uint8_t *output, 488 size_t outputRowPitch, 489 size_t outputDepthPitch); 490 491 void LoadRGB32FToRGBA16F(size_t width, 492 size_t height, 493 size_t depth, 494 const uint8_t *input, 495 size_t inputRowPitch, 496 size_t inputDepthPitch, 497 uint8_t *output, 498 size_t outputRowPitch, 499 size_t outputDepthPitch); 500 501 void LoadRGB32FToRGB16F(size_t width, 502 size_t height, 503 size_t depth, 504 const uint8_t *input, 505 size_t inputRowPitch, 506 size_t inputDepthPitch, 507 uint8_t *output, 508 size_t outputRowPitch, 509 size_t outputDepthPitch); 510 511 template <size_t blockWidth, size_t blockHeight, size_t blockDepth, size_t blockSize> 512 inline void LoadCompressedToNative(size_t width, 513 size_t height, 514 size_t depth, 515 const uint8_t *input, 516 size_t inputRowPitch, 517 size_t inputDepthPitch, 518 uint8_t *output, 519 size_t outputRowPitch, 520 size_t outputDepthPitch); 521 522 void LoadR32ToR16(size_t width, 523 size_t height, 524 size_t depth, 525 const uint8_t *input, 526 size_t inputRowPitch, 527 size_t inputDepthPitch, 528 uint8_t *output, 529 size_t outputRowPitch, 530 size_t outputDepthPitch); 531 532 template <typename type, 533 uint32_t firstBits, 534 uint32_t secondBits, 535 uint32_t thirdBits, 536 uint32_t fourthBits> 537 inline void Initialize4ComponentData(size_t width, 538 size_t height, 539 size_t depth, 540 uint8_t *output, 541 size_t outputRowPitch, 542 size_t outputDepthPitch); 543 544 void LoadR32ToR24G8(size_t width, 545 size_t height, 546 size_t depth, 547 const uint8_t *input, 548 size_t inputRowPitch, 549 size_t inputDepthPitch, 550 uint8_t *output, 551 size_t outputRowPitch, 552 size_t outputDepthPitch); 553 554 void LoadETC1RGB8ToRGBA8(size_t width, 555 size_t height, 556 size_t depth, 557 const uint8_t *input, 558 size_t inputRowPitch, 559 size_t inputDepthPitch, 560 uint8_t *output, 561 size_t outputRowPitch, 562 size_t outputDepthPitch); 563 564 void LoadETC1RGB8ToBC1(size_t width, 565 size_t height, 566 size_t depth, 567 const uint8_t *input, 568 size_t inputRowPitch, 569 size_t inputDepthPitch, 570 uint8_t *output, 571 size_t outputRowPitch, 572 size_t outputDepthPitch); 573 574 void LoadEACR11ToR8(size_t width, 575 size_t height, 576 size_t depth, 577 const uint8_t *input, 578 size_t inputRowPitch, 579 size_t inputDepthPitch, 580 uint8_t *output, 581 size_t outputRowPitch, 582 size_t outputDepthPitch); 583 584 void LoadEACR11SToR8(size_t width, 585 size_t height, 586 size_t depth, 587 const uint8_t *input, 588 size_t inputRowPitch, 589 size_t inputDepthPitch, 590 uint8_t *output, 591 size_t outputRowPitch, 592 size_t outputDepthPitch); 593 594 void LoadEACRG11ToRG8(size_t width, 595 size_t height, 596 size_t depth, 597 const uint8_t *input, 598 size_t inputRowPitch, 599 size_t inputDepthPitch, 600 uint8_t *output, 601 size_t outputRowPitch, 602 size_t outputDepthPitch); 603 604 void LoadEACRG11SToRG8(size_t width, 605 size_t height, 606 size_t depth, 607 const uint8_t *input, 608 size_t inputRowPitch, 609 size_t inputDepthPitch, 610 uint8_t *output, 611 size_t outputRowPitch, 612 size_t outputDepthPitch); 613 614 void LoadEACR11ToR16(size_t width, 615 size_t height, 616 size_t depth, 617 const uint8_t *input, 618 size_t inputRowPitch, 619 size_t inputDepthPitch, 620 uint8_t *output, 621 size_t outputRowPitch, 622 size_t outputDepthPitch); 623 624 void LoadEACR11SToR16(size_t width, 625 size_t height, 626 size_t depth, 627 const uint8_t *input, 628 size_t inputRowPitch, 629 size_t inputDepthPitch, 630 uint8_t *output, 631 size_t outputRowPitch, 632 size_t outputDepthPitch); 633 634 void LoadEACRG11ToRG16(size_t width, 635 size_t height, 636 size_t depth, 637 const uint8_t *input, 638 size_t inputRowPitch, 639 size_t inputDepthPitch, 640 uint8_t *output, 641 size_t outputRowPitch, 642 size_t outputDepthPitch); 643 644 void LoadEACRG11SToRG16(size_t width, 645 size_t height, 646 size_t depth, 647 const uint8_t *input, 648 size_t inputRowPitch, 649 size_t inputDepthPitch, 650 uint8_t *output, 651 size_t outputRowPitch, 652 size_t outputDepthPitch); 653 654 void LoadEACR11ToR16F(size_t width, 655 size_t height, 656 size_t depth, 657 const uint8_t *input, 658 size_t inputRowPitch, 659 size_t inputDepthPitch, 660 uint8_t *output, 661 size_t outputRowPitch, 662 size_t outputDepthPitch); 663 664 void LoadEACR11SToR16F(size_t width, 665 size_t height, 666 size_t depth, 667 const uint8_t *input, 668 size_t inputRowPitch, 669 size_t inputDepthPitch, 670 uint8_t *output, 671 size_t outputRowPitch, 672 size_t outputDepthPitch); 673 674 void LoadEACRG11ToRG16F(size_t width, 675 size_t height, 676 size_t depth, 677 const uint8_t *input, 678 size_t inputRowPitch, 679 size_t inputDepthPitch, 680 uint8_t *output, 681 size_t outputRowPitch, 682 size_t outputDepthPitch); 683 684 void LoadEACRG11SToRG16F(size_t width, 685 size_t height, 686 size_t depth, 687 const uint8_t *input, 688 size_t inputRowPitch, 689 size_t inputDepthPitch, 690 uint8_t *output, 691 size_t outputRowPitch, 692 size_t outputDepthPitch); 693 694 void LoadETC2RGB8ToRGBA8(size_t width, 695 size_t height, 696 size_t depth, 697 const uint8_t *input, 698 size_t inputRowPitch, 699 size_t inputDepthPitch, 700 uint8_t *output, 701 size_t outputRowPitch, 702 size_t outputDepthPitch); 703 704 void LoadETC2RGB8ToBC1(size_t width, 705 size_t height, 706 size_t depth, 707 const uint8_t *input, 708 size_t inputRowPitch, 709 size_t inputDepthPitch, 710 uint8_t *output, 711 size_t outputRowPitch, 712 size_t outputDepthPitch); 713 714 void LoadETC2SRGB8ToRGBA8(size_t width, 715 size_t height, 716 size_t depth, 717 const uint8_t *input, 718 size_t inputRowPitch, 719 size_t inputDepthPitch, 720 uint8_t *output, 721 size_t outputRowPitch, 722 size_t outputDepthPitch); 723 724 void LoadETC2SRGB8ToBC1(size_t width, 725 size_t height, 726 size_t depth, 727 const uint8_t *input, 728 size_t inputRowPitch, 729 size_t inputDepthPitch, 730 uint8_t *output, 731 size_t outputRowPitch, 732 size_t outputDepthPitch); 733 734 void LoadETC2RGB8A1ToRGBA8(size_t width, 735 size_t height, 736 size_t depth, 737 const uint8_t *input, 738 size_t inputRowPitch, 739 size_t inputDepthPitch, 740 uint8_t *output, 741 size_t outputRowPitch, 742 size_t outputDepthPitch); 743 744 void LoadETC2RGB8A1ToBC1(size_t width, 745 size_t height, 746 size_t depth, 747 const uint8_t *input, 748 size_t inputRowPitch, 749 size_t inputDepthPitch, 750 uint8_t *output, 751 size_t outputRowPitch, 752 size_t outputDepthPitch); 753 754 void LoadETC2SRGB8A1ToRGBA8(size_t width, 755 size_t height, 756 size_t depth, 757 const uint8_t *input, 758 size_t inputRowPitch, 759 size_t inputDepthPitch, 760 uint8_t *output, 761 size_t outputRowPitch, 762 size_t outputDepthPitch); 763 764 void LoadETC2SRGB8A1ToBC1(size_t width, 765 size_t height, 766 size_t depth, 767 const uint8_t *input, 768 size_t inputRowPitch, 769 size_t inputDepthPitch, 770 uint8_t *output, 771 size_t outputRowPitch, 772 size_t outputDepthPitch); 773 774 void LoadETC2RGBA8ToRGBA8(size_t width, 775 size_t height, 776 size_t depth, 777 const uint8_t *input, 778 size_t inputRowPitch, 779 size_t inputDepthPitch, 780 uint8_t *output, 781 size_t outputRowPitch, 782 size_t outputDepthPitch); 783 784 void LoadETC2SRGBA8ToSRGBA8(size_t width, 785 size_t height, 786 size_t depth, 787 const uint8_t *input, 788 size_t inputRowPitch, 789 size_t inputDepthPitch, 790 uint8_t *output, 791 size_t outputRowPitch, 792 size_t outputDepthPitch); 793 794 } // namespace angle 795 796 #include "loadimage.inc" 797 798 #endif // IMAGEUTIL_LOADIMAGE_H_ 799