Changeset 84441 in webkit
- Timestamp:
- Apr 20, 2011 5:28:17 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84440 r84441 1 2011-04-20 Kenneth Russell <kbr@google.com> 2 3 Reviewed by James Robinson. 4 5 Reduce size of GraphicsContext3D's compiled code 6 https://bugs.webkit.org/show_bug.cgi?id=59029 7 8 Changed format conversion operations to work line-by-line instead 9 of pixel-by-pixel, and passed them as function pointers rather 10 than template parameters. Simplified computation of source 11 increment, since elements per row is now all that is needed. 12 13 These changes reduce the size of GraphicsContext3D.o in release 14 mode on Linux from 299 KB to 53 KB. 15 16 No new tests. Existing layout tests cover these format conversions 17 well, and caught one typo in the restructuring. Also ran WebGL 18 conformance suite and other demos. 19 20 * platform/graphics/GraphicsContext3D.cpp: 21 (WebCore::doUnpackingAndPacking): 22 (WebCore::computeSourceElementsPerRow): 23 (WebCore::doPacking): 24 (WebCore::doFloatingPointPacking): 25 (WebCore::GraphicsContext3D::packPixels): 26 1 27 2011-04-20 Dimitri Glazkov <dglazkov@chromium.org> 2 28 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
r76600 r84441 343 343 } 344 344 345 // These functions can not be static, or gcc will not allow them to be 346 // used as template parameters. Use an anonymous namespace to prevent 347 // the need to declare prototypes for them. 345 // The following packing and unpacking routines are expressed in terms 346 // of line-by-line operations, and passed by function pointer rather 347 // than template parameter, to achieve the majority of the speedups of 348 // having them inlined while reducing code size. 349 348 350 namespace { 349 351 … … 351 353 // Pixel unpacking routines. 352 354 353 void unpackRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination) 354 { 355 destination[0] = source[0]; 356 destination[1] = source[1]; 357 destination[2] = source[2]; 358 destination[3] = source[3]; 359 } 360 361 void unpackRGBA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 362 { 363 destination[0] = convertColor16LittleTo8(source[0]); 364 destination[1] = convertColor16LittleTo8(source[1]); 365 destination[2] = convertColor16LittleTo8(source[2]); 366 destination[3] = convertColor16LittleTo8(source[3]); 367 } 368 369 void unpackRGBA16BigToRGBA8(const uint16_t* source, uint8_t* destination) 370 { 371 destination[0] = convertColor16BigTo8(source[0]); 372 destination[1] = convertColor16BigTo8(source[1]); 373 destination[2] = convertColor16BigTo8(source[2]); 374 destination[3] = convertColor16BigTo8(source[3]); 375 } 376 377 void unpackRGB8ToRGBA8(const uint8_t* source, uint8_t* destination) 378 { 379 destination[0] = source[0]; 380 destination[1] = source[1]; 381 destination[2] = source[2]; 382 destination[3] = 0xFF; 383 } 384 385 void unpackRGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 386 { 387 destination[0] = convertColor16LittleTo8(source[0]); 388 destination[1] = convertColor16LittleTo8(source[1]); 389 destination[2] = convertColor16LittleTo8(source[2]); 390 destination[3] = 0xFF; 391 } 392 393 void unpackRGB16BigToRGBA8(const uint16_t* source, uint8_t* destination) 394 { 395 destination[0] = convertColor16BigTo8(source[0]); 396 destination[1] = convertColor16BigTo8(source[1]); 397 destination[2] = convertColor16BigTo8(source[2]); 398 destination[3] = 0xFF; 399 } 400 401 void unpackBGR8ToRGBA8(const uint8_t* source, uint8_t* destination) 402 { 403 destination[0] = source[2]; 404 destination[1] = source[1]; 405 destination[2] = source[0]; 406 destination[3] = 0xFF; 407 } 408 409 void unpackARGB8ToRGBA8(const uint8_t* source, uint8_t* destination) 410 { 411 destination[0] = source[1]; 412 destination[1] = source[2]; 413 destination[2] = source[3]; 414 destination[3] = source[0]; 415 } 416 417 void unpackARGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 418 { 419 destination[0] = convertColor16LittleTo8(source[1]); 420 destination[1] = convertColor16LittleTo8(source[2]); 421 destination[2] = convertColor16LittleTo8(source[3]); 422 destination[3] = convertColor16LittleTo8(source[0]); 423 } 424 425 void unpackARGB16BigToRGBA8(const uint16_t* source, uint8_t* destination) 426 { 427 destination[0] = convertColor16BigTo8(source[1]); 428 destination[1] = convertColor16BigTo8(source[2]); 429 destination[2] = convertColor16BigTo8(source[3]); 430 destination[3] = convertColor16BigTo8(source[0]); 431 } 432 433 void unpackABGR8ToRGBA8(const uint8_t* source, uint8_t* destination) 434 { 435 destination[0] = source[3]; 436 destination[1] = source[2]; 437 destination[2] = source[1]; 438 destination[3] = source[0]; 439 } 440 441 void unpackBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination) 442 { 443 destination[0] = source[2]; 444 destination[1] = source[1]; 445 destination[2] = source[0]; 446 destination[3] = source[3]; 447 } 448 449 void unpackBGRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 450 { 451 destination[0] = convertColor16LittleTo8(source[2]); 452 destination[1] = convertColor16LittleTo8(source[1]); 453 destination[2] = convertColor16LittleTo8(source[0]); 454 destination[3] = convertColor16LittleTo8(source[3]); 455 } 456 457 void unpackBGRA16BigToRGBA8(const uint16_t* source, uint8_t* destination) 458 { 459 destination[0] = convertColor16BigTo8(source[2]); 460 destination[1] = convertColor16BigTo8(source[1]); 461 destination[2] = convertColor16BigTo8(source[0]); 462 destination[3] = convertColor16BigTo8(source[3]); 463 } 464 465 void unpackRGBA5551ToRGBA8(const uint16_t* source, uint8_t* destination) 466 { 467 uint16_t packedValue = source[0]; 468 uint8_t r = packedValue >> 11; 469 uint8_t g = (packedValue >> 6) & 0x1F; 470 uint8_t b = (packedValue >> 1) & 0x1F; 471 destination[0] = (r << 3) | (r & 0x7); 472 destination[1] = (g << 3) | (g & 0x7); 473 destination[2] = (b << 3) | (b & 0x7); 474 destination[3] = (packedValue & 0x1) ? 0xFF : 0x0; 475 } 476 477 void unpackRGBA4444ToRGBA8(const uint16_t* source, uint8_t* destination) 478 { 479 uint16_t packedValue = source[0]; 480 uint8_t r = packedValue >> 12; 481 uint8_t g = (packedValue >> 8) & 0x0F; 482 uint8_t b = (packedValue >> 4) & 0x0F; 483 uint8_t a = packedValue & 0x0F; 484 destination[0] = r << 4 | r; 485 destination[1] = g << 4 | g; 486 destination[2] = b << 4 | b; 487 destination[3] = a << 4 | a; 488 } 489 490 void unpackRGB565ToRGBA8(const uint16_t* source, uint8_t* destination) 491 { 492 uint16_t packedValue = source[0]; 493 uint8_t r = packedValue >> 11; 494 uint8_t g = (packedValue >> 5) & 0x3F; 495 uint8_t b = packedValue & 0x1F; 496 destination[0] = (r << 3) | (r & 0x7); 497 destination[1] = (g << 2) | (g & 0x3); 498 destination[2] = (b << 3) | (b & 0x7); 499 destination[3] = 0xFF; 500 } 501 502 void unpackR8ToRGBA8(const uint8_t* source, uint8_t* destination) 503 { 504 destination[0] = source[0]; 505 destination[1] = source[0]; 506 destination[2] = source[0]; 507 destination[3] = 0xFF; 508 } 509 510 void unpackR16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 511 { 512 destination[0] = convertColor16LittleTo8(source[0]); 513 destination[1] = convertColor16LittleTo8(source[0]); 514 destination[2] = convertColor16LittleTo8(source[0]); 515 destination[3] = 0xFF; 516 } 517 518 void unpackR16BigToRGBA8(const uint16_t* source, uint8_t* destination) 519 { 520 destination[0] = convertColor16BigTo8(source[0]); 521 destination[1] = convertColor16BigTo8(source[0]); 522 destination[2] = convertColor16BigTo8(source[0]); 523 destination[3] = 0xFF; 524 } 525 526 void unpackRA8ToRGBA8(const uint8_t* source, uint8_t* destination) 527 { 528 destination[0] = source[0]; 529 destination[1] = source[0]; 530 destination[2] = source[0]; 531 destination[3] = source[1]; 532 } 533 534 void unpackRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 535 { 536 destination[0] = convertColor16LittleTo8(source[0]); 537 destination[1] = convertColor16LittleTo8(source[0]); 538 destination[2] = convertColor16LittleTo8(source[0]); 539 destination[3] = convertColor16LittleTo8(source[1]); 540 } 541 542 void unpackRA16BigToRGBA8(const uint16_t* source, uint8_t* destination) 543 { 544 destination[0] = convertColor16BigTo8(source[0]); 545 destination[1] = convertColor16BigTo8(source[0]); 546 destination[2] = convertColor16BigTo8(source[0]); 547 destination[3] = convertColor16BigTo8(source[1]); 548 } 549 550 void unpackAR8ToRGBA8(const uint8_t* source, uint8_t* destination) 551 { 552 destination[0] = source[1]; 553 destination[1] = source[1]; 554 destination[2] = source[1]; 555 destination[3] = source[0]; 556 } 557 558 void unpackAR16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 559 { 560 destination[0] = convertColor16LittleTo8(source[1]); 561 destination[1] = convertColor16LittleTo8(source[1]); 562 destination[2] = convertColor16LittleTo8(source[1]); 563 destination[3] = convertColor16LittleTo8(source[0]); 564 } 565 566 void unpackAR16BigToRGBA8(const uint16_t* source, uint8_t* destination) 567 { 568 destination[0] = convertColor16BigTo8(source[1]); 569 destination[1] = convertColor16BigTo8(source[1]); 570 destination[2] = convertColor16BigTo8(source[1]); 571 destination[3] = convertColor16BigTo8(source[0]); 572 } 573 574 void unpackA8ToRGBA8(const uint8_t* source, uint8_t* destination) 575 { 576 destination[0] = 0x0; 577 destination[1] = 0x0; 578 destination[2] = 0x0; 579 destination[3] = source[0]; 580 } 581 582 void unpackA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) 583 { 584 destination[0] = 0x0; 585 destination[1] = 0x0; 586 destination[2] = 0x0; 587 destination[3] = convertColor16LittleTo8(source[0]); 588 } 589 590 void unpackA16BigToRGBA8(const uint16_t* source, uint8_t* destination) 591 { 592 destination[0] = 0x0; 593 destination[1] = 0x0; 594 destination[2] = 0x0; 595 destination[3] = convertColor16BigTo8(source[0]); 596 } 597 598 void unpackRGB32FToRGBA32F(const float* source, float* destination) 599 { 600 destination[0] = source[0]; 601 destination[1] = source[1]; 602 destination[2] = source[2]; 603 destination[3] = 1; 604 } 605 606 void unpackR32FToRGBA32F(const float* source, float* destination) 607 { 608 destination[0] = source[0]; 609 destination[1] = source[0]; 610 destination[2] = source[0]; 611 destination[3] = 1; 612 } 613 614 void unpackRA32FToRGBA32F(const float* source, float* destination) 615 { 616 destination[0] = source[0]; 617 destination[1] = source[0]; 618 destination[2] = source[0]; 619 destination[3] = source[1]; 620 } 621 622 void unpackA32FToRGBA32F(const float* source, float* destination) 623 { 624 destination[0] = 0; 625 destination[1] = 0; 626 destination[2] = 0; 627 destination[3] = source[0]; 355 void unpackOneRowOfRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 356 { 357 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 358 destination[0] = source[0]; 359 destination[1] = source[1]; 360 destination[2] = source[2]; 361 destination[3] = source[3]; 362 source += 4; 363 destination += 4; 364 } 365 } 366 367 void unpackOneRowOfRGBA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 368 { 369 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 370 destination[0] = convertColor16LittleTo8(source[0]); 371 destination[1] = convertColor16LittleTo8(source[1]); 372 destination[2] = convertColor16LittleTo8(source[2]); 373 destination[3] = convertColor16LittleTo8(source[3]); 374 source += 4; 375 destination += 4; 376 } 377 } 378 379 void unpackOneRowOfRGBA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 380 { 381 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 382 destination[0] = convertColor16BigTo8(source[0]); 383 destination[1] = convertColor16BigTo8(source[1]); 384 destination[2] = convertColor16BigTo8(source[2]); 385 destination[3] = convertColor16BigTo8(source[3]); 386 source += 4; 387 destination += 4; 388 } 389 } 390 391 void unpackOneRowOfRGB8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 392 { 393 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 394 destination[0] = source[0]; 395 destination[1] = source[1]; 396 destination[2] = source[2]; 397 destination[3] = 0xFF; 398 source += 3; 399 destination += 4; 400 } 401 } 402 403 void unpackOneRowOfRGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 404 { 405 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 406 destination[0] = convertColor16LittleTo8(source[0]); 407 destination[1] = convertColor16LittleTo8(source[1]); 408 destination[2] = convertColor16LittleTo8(source[2]); 409 destination[3] = 0xFF; 410 source += 3; 411 destination += 4; 412 } 413 } 414 415 void unpackOneRowOfRGB16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 416 { 417 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 418 destination[0] = convertColor16BigTo8(source[0]); 419 destination[1] = convertColor16BigTo8(source[1]); 420 destination[2] = convertColor16BigTo8(source[2]); 421 destination[3] = 0xFF; 422 source += 3; 423 destination += 4; 424 } 425 } 426 427 void unpackOneRowOfBGR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 428 { 429 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 430 destination[0] = source[2]; 431 destination[1] = source[1]; 432 destination[2] = source[0]; 433 destination[3] = 0xFF; 434 source += 3; 435 destination += 4; 436 } 437 } 438 439 void unpackOneRowOfARGB8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 440 { 441 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 442 destination[0] = source[1]; 443 destination[1] = source[2]; 444 destination[2] = source[3]; 445 destination[3] = source[0]; 446 source += 4; 447 destination += 4; 448 } 449 } 450 451 void unpackOneRowOfARGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 452 { 453 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 454 destination[0] = convertColor16LittleTo8(source[1]); 455 destination[1] = convertColor16LittleTo8(source[2]); 456 destination[2] = convertColor16LittleTo8(source[3]); 457 destination[3] = convertColor16LittleTo8(source[0]); 458 source += 4; 459 destination += 4; 460 } 461 } 462 463 void unpackOneRowOfARGB16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 464 { 465 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 466 destination[0] = convertColor16BigTo8(source[1]); 467 destination[1] = convertColor16BigTo8(source[2]); 468 destination[2] = convertColor16BigTo8(source[3]); 469 destination[3] = convertColor16BigTo8(source[0]); 470 source += 4; 471 destination += 4; 472 } 473 } 474 475 void unpackOneRowOfABGR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 476 { 477 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 478 destination[0] = source[3]; 479 destination[1] = source[2]; 480 destination[2] = source[1]; 481 destination[3] = source[0]; 482 source += 4; 483 destination += 4; 484 } 485 } 486 487 void unpackOneRowOfBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 488 { 489 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 490 destination[0] = source[2]; 491 destination[1] = source[1]; 492 destination[2] = source[0]; 493 destination[3] = source[3]; 494 source += 4; 495 destination += 4; 496 } 497 } 498 499 void unpackOneRowOfBGRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 500 { 501 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 502 destination[0] = convertColor16LittleTo8(source[2]); 503 destination[1] = convertColor16LittleTo8(source[1]); 504 destination[2] = convertColor16LittleTo8(source[0]); 505 destination[3] = convertColor16LittleTo8(source[3]); 506 source += 4; 507 destination += 4; 508 } 509 } 510 511 void unpackOneRowOfBGRA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 512 { 513 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 514 destination[0] = convertColor16BigTo8(source[2]); 515 destination[1] = convertColor16BigTo8(source[1]); 516 destination[2] = convertColor16BigTo8(source[0]); 517 destination[3] = convertColor16BigTo8(source[3]); 518 source += 4; 519 destination += 4; 520 } 521 } 522 523 void unpackOneRowOfRGBA5551ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 524 { 525 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 526 uint16_t packedValue = source[0]; 527 uint8_t r = packedValue >> 11; 528 uint8_t g = (packedValue >> 6) & 0x1F; 529 uint8_t b = (packedValue >> 1) & 0x1F; 530 destination[0] = (r << 3) | (r & 0x7); 531 destination[1] = (g << 3) | (g & 0x7); 532 destination[2] = (b << 3) | (b & 0x7); 533 destination[3] = (packedValue & 0x1) ? 0xFF : 0x0; 534 source += 1; 535 destination += 4; 536 } 537 } 538 539 void unpackOneRowOfRGBA4444ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 540 { 541 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 542 uint16_t packedValue = source[0]; 543 uint8_t r = packedValue >> 12; 544 uint8_t g = (packedValue >> 8) & 0x0F; 545 uint8_t b = (packedValue >> 4) & 0x0F; 546 uint8_t a = packedValue & 0x0F; 547 destination[0] = r << 4 | r; 548 destination[1] = g << 4 | g; 549 destination[2] = b << 4 | b; 550 destination[3] = a << 4 | a; 551 source += 1; 552 destination += 4; 553 } 554 } 555 556 void unpackOneRowOfRGB565ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 557 { 558 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 559 uint16_t packedValue = source[0]; 560 uint8_t r = packedValue >> 11; 561 uint8_t g = (packedValue >> 5) & 0x3F; 562 uint8_t b = packedValue & 0x1F; 563 destination[0] = (r << 3) | (r & 0x7); 564 destination[1] = (g << 2) | (g & 0x3); 565 destination[2] = (b << 3) | (b & 0x7); 566 destination[3] = 0xFF; 567 source += 1; 568 destination += 4; 569 } 570 } 571 572 void unpackOneRowOfR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 573 { 574 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 575 destination[0] = source[0]; 576 destination[1] = source[0]; 577 destination[2] = source[0]; 578 destination[3] = 0xFF; 579 source += 1; 580 destination += 4; 581 } 582 } 583 584 void unpackOneRowOfR16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 585 { 586 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 587 destination[0] = convertColor16LittleTo8(source[0]); 588 destination[1] = convertColor16LittleTo8(source[0]); 589 destination[2] = convertColor16LittleTo8(source[0]); 590 destination[3] = 0xFF; 591 source += 1; 592 destination += 4; 593 } 594 } 595 596 void unpackOneRowOfR16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 597 { 598 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 599 destination[0] = convertColor16BigTo8(source[0]); 600 destination[1] = convertColor16BigTo8(source[0]); 601 destination[2] = convertColor16BigTo8(source[0]); 602 destination[3] = 0xFF; 603 source += 1; 604 destination += 4; 605 } 606 } 607 608 void unpackOneRowOfRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 609 { 610 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 611 destination[0] = source[0]; 612 destination[1] = source[0]; 613 destination[2] = source[0]; 614 destination[3] = source[1]; 615 source += 2; 616 destination += 4; 617 } 618 } 619 620 void unpackOneRowOfRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 621 { 622 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 623 destination[0] = convertColor16LittleTo8(source[0]); 624 destination[1] = convertColor16LittleTo8(source[0]); 625 destination[2] = convertColor16LittleTo8(source[0]); 626 destination[3] = convertColor16LittleTo8(source[1]); 627 source += 2; 628 destination += 4; 629 } 630 } 631 632 void unpackOneRowOfRA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 633 { 634 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 635 destination[0] = convertColor16BigTo8(source[0]); 636 destination[1] = convertColor16BigTo8(source[0]); 637 destination[2] = convertColor16BigTo8(source[0]); 638 destination[3] = convertColor16BigTo8(source[1]); 639 source += 2; 640 destination += 4; 641 } 642 } 643 644 void unpackOneRowOfAR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 645 { 646 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 647 destination[0] = source[1]; 648 destination[1] = source[1]; 649 destination[2] = source[1]; 650 destination[3] = source[0]; 651 source += 2; 652 destination += 4; 653 } 654 } 655 656 void unpackOneRowOfAR16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 657 { 658 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 659 destination[0] = convertColor16LittleTo8(source[1]); 660 destination[1] = convertColor16LittleTo8(source[1]); 661 destination[2] = convertColor16LittleTo8(source[1]); 662 destination[3] = convertColor16LittleTo8(source[0]); 663 source += 2; 664 destination += 4; 665 } 666 } 667 668 void unpackOneRowOfAR16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 669 { 670 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 671 destination[0] = convertColor16BigTo8(source[1]); 672 destination[1] = convertColor16BigTo8(source[1]); 673 destination[2] = convertColor16BigTo8(source[1]); 674 destination[3] = convertColor16BigTo8(source[0]); 675 source += 2; 676 destination += 4; 677 } 678 } 679 680 void unpackOneRowOfA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 681 { 682 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 683 destination[0] = 0x0; 684 destination[1] = 0x0; 685 destination[2] = 0x0; 686 destination[3] = source[0]; 687 source += 1; 688 destination += 4; 689 } 690 } 691 692 void unpackOneRowOfA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 693 { 694 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 695 destination[0] = 0x0; 696 destination[1] = 0x0; 697 destination[2] = 0x0; 698 destination[3] = convertColor16LittleTo8(source[0]); 699 source += 1; 700 destination += 4; 701 } 702 } 703 704 void unpackOneRowOfA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow) 705 { 706 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 707 destination[0] = 0x0; 708 destination[1] = 0x0; 709 destination[2] = 0x0; 710 destination[3] = convertColor16BigTo8(source[0]); 711 source += 1; 712 destination += 4; 713 } 714 } 715 716 void unpackOneRowOfRGB32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow) 717 { 718 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 719 destination[0] = source[0]; 720 destination[1] = source[1]; 721 destination[2] = source[2]; 722 destination[3] = 1; 723 source += 3; 724 destination += 4; 725 } 726 } 727 728 void unpackOneRowOfR32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow) 729 { 730 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 731 destination[0] = source[0]; 732 destination[1] = source[0]; 733 destination[2] = source[0]; 734 destination[3] = 1; 735 source += 1; 736 destination += 4; 737 } 738 } 739 740 void unpackOneRowOfRA32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow) 741 { 742 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 743 destination[0] = source[0]; 744 destination[1] = source[0]; 745 destination[2] = source[0]; 746 destination[3] = source[1]; 747 source += 2; 748 destination += 4; 749 } 750 } 751 752 void unpackOneRowOfA32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow) 753 { 754 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 755 destination[0] = 0; 756 destination[1] = 0; 757 destination[2] = 0; 758 destination[3] = source[0]; 759 source += 1; 760 destination += 4; 761 } 628 762 } 629 763 … … 632 766 // 633 767 634 void packRGBA8ToA8(const uint8_t* source, uint8_t* destination) 635 { 636 destination[0] = source[3]; 637 } 638 639 void packRGBA8ToR8(const uint8_t* source, uint8_t* destination) 640 { 641 destination[0] = source[0]; 642 } 643 644 void packRGBA8ToR8Premultiply(const uint8_t* source, uint8_t* destination) 645 { 646 float scaleFactor = source[3] / 255.0f; 647 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 648 destination[0] = sourceR; 768 void packOneRowOfRGBA8ToA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 769 { 770 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 771 destination[0] = source[3]; 772 source += 4; 773 destination += 1; 774 } 775 } 776 777 void packOneRowOfRGBA8ToR8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 778 { 779 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 780 destination[0] = source[0]; 781 source += 4; 782 destination += 1; 783 } 784 } 785 786 void packOneRowOfRGBA8ToR8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 787 { 788 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 789 float scaleFactor = source[3] / 255.0f; 790 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 791 destination[0] = sourceR; 792 source += 4; 793 destination += 1; 794 } 649 795 } 650 796 651 797 // FIXME: this routine is lossy and must be removed. 652 void packRGBA8ToR8Unmultiply(const uint8_t* source, uint8_t* destination) 653 { 654 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 655 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 656 destination[0] = sourceR; 657 } 658 659 void packRGBA8ToRA8(const uint8_t* source, uint8_t* destination) 660 { 661 destination[0] = source[0]; 662 destination[1] = source[3]; 663 } 664 665 void packRGBA8ToRA8Premultiply(const uint8_t* source, uint8_t* destination) 666 { 667 float scaleFactor = source[3] / 255.0f; 668 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 669 destination[0] = sourceR; 670 destination[1] = source[3]; 798 void packOneRowOfRGBA8ToR8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 799 { 800 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 801 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 802 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 803 destination[0] = sourceR; 804 source += 4; 805 destination += 1; 806 } 807 } 808 809 void packOneRowOfRGBA8ToRA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 810 { 811 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 812 destination[0] = source[0]; 813 destination[1] = source[3]; 814 source += 4; 815 destination += 2; 816 } 817 } 818 819 void packOneRowOfRGBA8ToRA8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 820 { 821 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 822 float scaleFactor = source[3] / 255.0f; 823 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 824 destination[0] = sourceR; 825 destination[1] = source[3]; 826 source += 4; 827 destination += 2; 828 } 671 829 } 672 830 673 831 // FIXME: this routine is lossy and must be removed. 674 void packRGBA8ToRA8Unmultiply(const uint8_t* source, uint8_t* destination) 675 { 676 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 677 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 678 destination[0] = sourceR; 679 destination[1] = source[3]; 680 } 681 682 void packRGBA8ToRGB8(const uint8_t* source, uint8_t* destination) 683 { 684 destination[0] = source[0]; 685 destination[1] = source[1]; 686 destination[2] = source[2]; 687 } 688 689 void packRGBA8ToRGB8Premultiply(const uint8_t* source, uint8_t* destination) 690 { 691 float scaleFactor = source[3] / 255.0f; 692 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 693 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 694 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 695 destination[0] = sourceR; 696 destination[1] = sourceG; 697 destination[2] = sourceB; 832 void packOneRowOfRGBA8ToRA8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 833 { 834 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 835 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 836 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 837 destination[0] = sourceR; 838 destination[1] = source[3]; 839 source += 4; 840 destination += 2; 841 } 842 } 843 844 void packOneRowOfRGBA8ToRGB8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 845 { 846 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 847 destination[0] = source[0]; 848 destination[1] = source[1]; 849 destination[2] = source[2]; 850 source += 4; 851 destination += 3; 852 } 853 } 854 855 void packOneRowOfRGBA8ToRGB8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 856 { 857 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 858 float scaleFactor = source[3] / 255.0f; 859 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 860 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 861 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 862 destination[0] = sourceR; 863 destination[1] = sourceG; 864 destination[2] = sourceB; 865 source += 4; 866 destination += 3; 867 } 698 868 } 699 869 700 870 // FIXME: this routine is lossy and must be removed. 701 void packRGBA8ToRGB8Unmultiply(const uint8_t* source, uint8_t* destination) 702 { 703 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 704 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 705 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 706 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 707 destination[0] = sourceR; 708 destination[1] = sourceG; 709 destination[2] = sourceB; 871 void packOneRowOfRGBA8ToRGB8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 872 { 873 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 874 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 875 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 876 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 877 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 878 destination[0] = sourceR; 879 destination[1] = sourceG; 880 destination[2] = sourceB; 881 source += 4; 882 destination += 3; 883 } 710 884 } 711 885 712 886 // This is only used when the source format is different than SourceFormatRGBA8. 713 void packRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination) 714 { 715 destination[0] = source[0]; 716 destination[1] = source[1]; 717 destination[2] = source[2]; 718 destination[3] = source[3]; 719 } 720 721 void packRGBA8ToRGBA8Premultiply(const uint8_t* source, uint8_t* destination) 722 { 723 float scaleFactor = source[3] / 255.0f; 724 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 725 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 726 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 727 destination[0] = sourceR; 728 destination[1] = sourceG; 729 destination[2] = sourceB; 730 destination[3] = source[3]; 887 void packOneRowOfRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 888 { 889 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 890 destination[0] = source[0]; 891 destination[1] = source[1]; 892 destination[2] = source[2]; 893 destination[3] = source[3]; 894 source += 4; 895 destination += 4; 896 } 897 } 898 899 void packOneRowOfRGBA8ToRGBA8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 900 { 901 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 902 float scaleFactor = source[3] / 255.0f; 903 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 904 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 905 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 906 destination[0] = sourceR; 907 destination[1] = sourceG; 908 destination[2] = sourceB; 909 destination[3] = source[3]; 910 source += 4; 911 destination += 4; 912 } 731 913 } 732 914 733 915 // FIXME: this routine is lossy and must be removed. 734 void packRGBA8ToRGBA8Unmultiply(const uint8_t* source, uint8_t* destination) 735 { 736 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 737 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 738 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 739 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 740 destination[0] = sourceR; 741 destination[1] = sourceG; 742 destination[2] = sourceB; 743 destination[3] = source[3]; 744 } 745 746 void packRGBA8ToUnsignedShort4444(const uint8_t* source, uint16_t* destination) 747 { 748 *destination = (((source[0] & 0xF0) << 8) 749 | ((source[1] & 0xF0) << 4) 750 | (source[2] & 0xF0) 751 | (source[3] >> 4)); 752 } 753 754 void packRGBA8ToUnsignedShort4444Premultiply(const uint8_t* source, uint16_t* destination) 755 { 756 float scaleFactor = source[3] / 255.0f; 757 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 758 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 759 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 760 *destination = (((sourceR & 0xF0) << 8) 761 | ((sourceG & 0xF0) << 4) 762 | (sourceB & 0xF0) 763 | (source[3] >> 4)); 916 void packOneRowOfRGBA8ToRGBA8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 917 { 918 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 919 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 920 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 921 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 922 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 923 destination[0] = sourceR; 924 destination[1] = sourceG; 925 destination[2] = sourceB; 926 destination[3] = source[3]; 927 source += 4; 928 destination += 4; 929 } 930 } 931 932 void packOneRowOfRGBA8ToUnsignedShort4444(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 933 { 934 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 935 *destination = (((source[0] & 0xF0) << 8) 936 | ((source[1] & 0xF0) << 4) 937 | (source[2] & 0xF0) 938 | (source[3] >> 4)); 939 source += 4; 940 destination += 1; 941 } 942 } 943 944 void packOneRowOfRGBA8ToUnsignedShort4444Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 945 { 946 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 947 float scaleFactor = source[3] / 255.0f; 948 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 949 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 950 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 951 *destination = (((sourceR & 0xF0) << 8) 952 | ((sourceG & 0xF0) << 4) 953 | (sourceB & 0xF0) 954 | (source[3] >> 4)); 955 source += 4; 956 destination += 1; 957 } 764 958 } 765 959 766 960 // FIXME: this routine is lossy and must be removed. 767 void packRGBA8ToUnsignedShort4444Unmultiply(const uint8_t* source, uint16_t* destination) 768 { 769 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 770 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 771 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 772 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 773 *destination = (((sourceR & 0xF0) << 8) 774 | ((sourceG & 0xF0) << 4) 775 | (sourceB & 0xF0) 776 | (source[3] >> 4)); 777 } 778 779 void packRGBA8ToUnsignedShort5551(const uint8_t* source, uint16_t* destination) 780 { 781 *destination = (((source[0] & 0xF8) << 8) 782 | ((source[1] & 0xF8) << 3) 783 | ((source[2] & 0xF8) >> 2) 784 | (source[3] >> 7)); 785 } 786 787 void packRGBA8ToUnsignedShort5551Premultiply(const uint8_t* source, uint16_t* destination) 788 { 789 float scaleFactor = source[3] / 255.0f; 790 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 791 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 792 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 793 *destination = (((sourceR & 0xF8) << 8) 794 | ((sourceG & 0xF8) << 3) 795 | ((sourceB & 0xF8) >> 2) 796 | (source[3] >> 7)); 961 void packOneRowOfRGBA8ToUnsignedShort4444Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 962 { 963 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 964 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 965 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 966 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 967 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 968 *destination = (((sourceR & 0xF0) << 8) 969 | ((sourceG & 0xF0) << 4) 970 | (sourceB & 0xF0) 971 | (source[3] >> 4)); 972 source += 4; 973 destination += 1; 974 } 975 } 976 977 void packOneRowOfRGBA8ToUnsignedShort5551(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 978 { 979 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 980 *destination = (((source[0] & 0xF8) << 8) 981 | ((source[1] & 0xF8) << 3) 982 | ((source[2] & 0xF8) >> 2) 983 | (source[3] >> 7)); 984 source += 4; 985 destination += 1; 986 } 987 } 988 989 void packOneRowOfRGBA8ToUnsignedShort5551Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 990 { 991 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 992 float scaleFactor = source[3] / 255.0f; 993 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 994 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 995 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 996 *destination = (((sourceR & 0xF8) << 8) 997 | ((sourceG & 0xF8) << 3) 998 | ((sourceB & 0xF8) >> 2) 999 | (source[3] >> 7)); 1000 source += 4; 1001 destination += 1; 1002 } 797 1003 } 798 1004 799 1005 // FIXME: this routine is lossy and must be removed. 800 void packRGBA8ToUnsignedShort5551Unmultiply(const uint8_t* source, uint16_t* destination) 801 { 802 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 803 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 804 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 805 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 806 *destination = (((sourceR & 0xF8) << 8) 807 | ((sourceG & 0xF8) << 3) 808 | ((sourceB & 0xF8) >> 2) 809 | (source[3] >> 7)); 810 } 811 812 void packRGBA8ToUnsignedShort565(const uint8_t* source, uint16_t* destination) 813 { 814 *destination = (((source[0] & 0xF8) << 8) 815 | ((source[1] & 0xFC) << 3) 816 | ((source[2] & 0xF8) >> 3)); 817 } 818 819 void packRGBA8ToUnsignedShort565Premultiply(const uint8_t* source, uint16_t* destination) 820 { 821 float scaleFactor = source[3] / 255.0f; 822 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 823 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 824 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 825 *destination = (((sourceR & 0xF8) << 8) 826 | ((sourceG & 0xFC) << 3) 827 | ((sourceB & 0xF8) >> 3)); 1006 void packOneRowOfRGBA8ToUnsignedShort5551Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 1007 { 1008 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1009 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 1010 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 1011 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 1012 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 1013 *destination = (((sourceR & 0xF8) << 8) 1014 | ((sourceG & 0xF8) << 3) 1015 | ((sourceB & 0xF8) >> 2) 1016 | (source[3] >> 7)); 1017 source += 4; 1018 destination += 1; 1019 } 1020 } 1021 1022 void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 1023 { 1024 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1025 *destination = (((source[0] & 0xF8) << 8) 1026 | ((source[1] & 0xFC) << 3) 1027 | ((source[2] & 0xF8) >> 3)); 1028 source += 4; 1029 destination += 1; 1030 } 1031 } 1032 1033 void packOneRowOfRGBA8ToUnsignedShort565Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 1034 { 1035 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1036 float scaleFactor = source[3] / 255.0f; 1037 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 1038 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 1039 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 1040 *destination = (((sourceR & 0xF8) << 8) 1041 | ((sourceG & 0xFC) << 3) 1042 | ((sourceB & 0xF8) >> 3)); 1043 source += 4; 1044 destination += 1; 1045 } 828 1046 } 829 1047 830 1048 // FIXME: this routine is lossy and must be removed. 831 void packRGBA8ToUnsignedShort565Unmultiply(const uint8_t* source, uint16_t* destination) 832 { 833 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 834 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 835 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 836 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 837 *destination = (((sourceR & 0xF8) << 8) 838 | ((sourceG & 0xFC) << 3) 839 | ((sourceB & 0xF8) >> 3)); 840 } 841 842 void packRGBA32FToRGB32F(const float* source, float* destination) 843 { 844 destination[0] = source[0]; 845 destination[1] = source[1]; 846 destination[2] = source[2]; 847 } 848 849 void packRGBA32FToRGB32FPremultiply(const float* source, float* destination) 850 { 851 float scaleFactor = source[3]; 852 destination[0] = source[0] * scaleFactor; 853 destination[1] = source[1] * scaleFactor; 854 destination[2] = source[2] * scaleFactor; 855 } 856 857 void packRGBA32FToRGBA32FPremultiply(const float* source, float* destination) 858 { 859 float scaleFactor = source[3]; 860 destination[0] = source[0] * scaleFactor; 861 destination[1] = source[1] * scaleFactor; 862 destination[2] = source[2] * scaleFactor; 863 destination[3] = source[3]; 864 } 865 866 void packRGBA32FToA32F(const float* source, float* destination) 867 { 868 destination[0] = source[3]; 869 } 870 871 void packRGBA32FToR32F(const float* source, float* destination) 872 { 873 destination[0] = source[0]; 874 } 875 876 void packRGBA32FToR32FPremultiply(const float* source, float* destination) 877 { 878 float scaleFactor = source[3]; 879 destination[0] = source[0] * scaleFactor; 880 } 881 882 883 void packRGBA32FToRA32F(const float* source, float* destination) 884 { 885 destination[0] = source[0]; 886 destination[1] = source[3]; 887 } 888 889 void packRGBA32FToRA32FPremultiply(const float* source, float* destination) 890 { 891 float scaleFactor = source[3]; 892 destination[0] = source[0] * scaleFactor; 893 destination[1] = scaleFactor; 1049 void packOneRowOfRGBA8ToUnsignedShort565Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow) 1050 { 1051 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1052 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f); 1053 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 1054 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); 1055 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor); 1056 *destination = (((sourceR & 0xF8) << 8) 1057 | ((sourceG & 0xFC) << 3) 1058 | ((sourceB & 0xF8) >> 3)); 1059 source += 4; 1060 destination += 1; 1061 } 1062 } 1063 1064 void packOneRowOfRGBA32FToRGB32F(const float* source, float* destination, unsigned int pixelsPerRow) 1065 { 1066 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1067 destination[0] = source[0]; 1068 destination[1] = source[1]; 1069 destination[2] = source[2]; 1070 source += 4; 1071 destination += 3; 1072 } 1073 } 1074 1075 void packOneRowOfRGBA32FToRGB32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow) 1076 { 1077 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1078 float scaleFactor = source[3]; 1079 destination[0] = source[0] * scaleFactor; 1080 destination[1] = source[1] * scaleFactor; 1081 destination[2] = source[2] * scaleFactor; 1082 source += 4; 1083 destination += 3; 1084 } 1085 } 1086 1087 void packOneRowOfRGBA32FToRGBA32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow) 1088 { 1089 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1090 float scaleFactor = source[3]; 1091 destination[0] = source[0] * scaleFactor; 1092 destination[1] = source[1] * scaleFactor; 1093 destination[2] = source[2] * scaleFactor; 1094 destination[3] = source[3]; 1095 source += 4; 1096 destination += 4; 1097 } 1098 } 1099 1100 void packOneRowOfRGBA32FToA32F(const float* source, float* destination, unsigned int pixelsPerRow) 1101 { 1102 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1103 destination[0] = source[3]; 1104 source += 4; 1105 destination += 1; 1106 } 1107 } 1108 1109 void packOneRowOfRGBA32FToR32F(const float* source, float* destination, unsigned int pixelsPerRow) 1110 { 1111 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1112 destination[0] = source[0]; 1113 source += 4; 1114 destination += 1; 1115 } 1116 } 1117 1118 void packOneRowOfRGBA32FToR32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow) 1119 { 1120 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1121 float scaleFactor = source[3]; 1122 destination[0] = source[0] * scaleFactor; 1123 source += 4; 1124 destination += 1; 1125 } 1126 } 1127 1128 1129 void packOneRowOfRGBA32FToRA32F(const float* source, float* destination, unsigned int pixelsPerRow) 1130 { 1131 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1132 destination[0] = source[0]; 1133 destination[1] = source[3]; 1134 source += 4; 1135 destination += 2; 1136 } 1137 } 1138 1139 void packOneRowOfRGBA32FToRA32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow) 1140 { 1141 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1142 float scaleFactor = source[3]; 1143 destination[0] = source[0] * scaleFactor; 1144 destination[1] = scaleFactor; 1145 source += 4; 1146 destination += 2; 1147 } 894 1148 } 895 1149 … … 899 1153 // is not in RGBA8/RGBA32F format, or the unpack alignment specifies 900 1154 // that rows are not tightly packed. 901 template<typename SourceType, typename IntermediateType, typename DestType, 902 void unpackingFunc(const SourceType*, IntermediateType*), 903 void packingFunc(const IntermediateType*, DestType*)> 1155 template<typename SourceType, typename IntermediateType, typename DestType> 904 1156 static void doUnpackingAndPacking(const SourceType* sourceData, 1157 void (*rowUnpackingFunc)(const SourceType*, IntermediateType*, unsigned int), 905 1158 unsigned int width, 906 1159 unsigned int height, 907 unsigned int sourceElementsPerPixel,908 1160 unsigned int sourceElementsPerRow, 909 1161 DestType* destinationData, 1162 void (*rowPackingFunc)(const IntermediateType*, DestType*, unsigned int), 910 1163 unsigned int destinationElementsPerPixel) 911 1164 { 912 if (!sourceElementsPerRow) { 913 unsigned int numElements = width * height * sourceElementsPerPixel; 914 const SourceType* endPointer = sourceData + numElements; 915 IntermediateType temporaryRGBAData[4]; 916 while (sourceData < endPointer) { 917 unpackingFunc(sourceData, temporaryRGBAData); 918 packingFunc(temporaryRGBAData, destinationData); 919 sourceData += sourceElementsPerPixel; 920 destinationData += destinationElementsPerPixel; 921 } 922 } else { 923 IntermediateType temporaryRGBAData[4]; 924 for (unsigned int y = 0; y < height; ++y) { 925 const SourceType* currentSource = sourceData; 926 for (unsigned int x = 0; x < width; ++x) { 927 unpackingFunc(currentSource, temporaryRGBAData); 928 packingFunc(temporaryRGBAData, destinationData); 929 currentSource += sourceElementsPerPixel; 930 destinationData += destinationElementsPerPixel; 931 } 932 sourceData += sourceElementsPerRow; 933 } 1165 OwnArrayPtr<IntermediateType> temporaryRGBAData = adoptArrayPtr(new IntermediateType[width * 4]); 1166 const SourceType* endPointer = sourceData + height * sourceElementsPerRow; 1167 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1168 while (sourceData < endPointer) { 1169 rowUnpackingFunc(sourceData, temporaryRGBAData.get(), width); 1170 rowPackingFunc(temporaryRGBAData.get(), destinationData, width); 1171 sourceData += sourceElementsPerRow; 1172 destinationData += destinationElementsPerRow; 934 1173 } 935 1174 } 936 1175 937 1176 template<typename SourceType> 938 static void computeIncrementParameters(unsigned int width, 939 unsigned int bytesPerPixel, 940 unsigned int unpackAlignment, 941 unsigned int* sourceElementsPerPixel, 942 unsigned int* sourceElementsPerRow) 1177 static unsigned int computeSourceElementsPerRow(unsigned int width, 1178 unsigned int bytesPerPixel, 1179 unsigned int unpackAlignment) 943 1180 { 944 1181 unsigned int elementSizeInBytes = sizeof(SourceType); … … 952 1189 totalRowBytes += (unpackAlignment - remainder); 953 1190 } 954 *sourceElementsPerPixel = bytesPerPixel / elementSizeInBytes; 955 if (validRowBytes == totalRowBytes) 956 *sourceElementsPerRow = 0; 957 else 958 *sourceElementsPerRow = totalRowBytes / elementSizeInBytes; 1191 return totalRowBytes / elementSizeInBytes; 959 1192 } 960 1193 961 1194 // This handles all conversions with a faster path for tightly packed RGBA8 source data. 962 template<typename DestType , void packingFunc(const uint8_t*, DestType*)>1195 template<typename DestType> 963 1196 static void doPacking(const void* sourceData, 964 1197 GraphicsContext3D::SourceDataFormat sourceDataFormat, … … 967 1200 unsigned int sourceUnpackAlignment, 968 1201 DestType* destinationData, 1202 void (*rowPackingFunc)(const uint8_t*, DestType*, unsigned int), 969 1203 unsigned int destinationElementsPerPixel) 970 1204 { 971 1205 switch (sourceDataFormat) { 972 1206 case GraphicsContext3D::SourceFormatRGBA8: { 973 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 974 computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 975 if (!sourceElementsPerRow) { 976 const uint8_t* source = static_cast<const uint8_t*>(sourceData); 977 unsigned int numElements = width * height * 4; 978 const uint8_t* endPointer = source + numElements; 979 while (source < endPointer) { 980 packingFunc(source, destinationData); 981 source += sourceElementsPerPixel; 982 destinationData += destinationElementsPerPixel; 983 } 984 } else { 985 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRGBA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1207 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment); 1208 const uint8_t* source = static_cast<const uint8_t*>(sourceData); 1209 const uint8_t* endPointer = source + height * sourceElementsPerRow; 1210 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1211 while (source < endPointer) { 1212 rowPackingFunc(source, destinationData, width); 1213 source += sourceElementsPerRow; 1214 destinationData += destinationElementsPerRow; 986 1215 } 987 1216 break; 988 1217 } 989 1218 case GraphicsContext3D::SourceFormatRGBA16Little: { 990 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 991 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 992 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1219 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1220 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 993 1221 break; 994 1222 } 995 1223 case GraphicsContext3D::SourceFormatRGBA16Big: { 996 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 997 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 998 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1224 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1225 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 999 1226 break; 1000 1227 } 1001 1228 case GraphicsContext3D::SourceFormatRGB8: { 1002 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1003 computeIncrementParameters<uint8_t>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1004 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1229 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 3, sourceUnpackAlignment); 1230 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfRGB8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1005 1231 break; 1006 1232 } 1007 1233 case GraphicsContext3D::SourceFormatRGB16Little: { 1008 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1009 computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1010 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1234 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 6, sourceUnpackAlignment); 1235 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1011 1236 break; 1012 1237 } 1013 1238 case GraphicsContext3D::SourceFormatRGB16Big: { 1014 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1015 computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1016 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1239 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 6, sourceUnpackAlignment); 1240 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1017 1241 break; 1018 1242 } 1019 1243 case GraphicsContext3D::SourceFormatBGR8: { 1020 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1021 computeIncrementParameters<uint8_t>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1022 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackBGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1244 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 3, sourceUnpackAlignment); 1245 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfBGR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1023 1246 break; 1024 1247 } 1025 1248 case GraphicsContext3D::SourceFormatARGB8: { 1026 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1027 computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1028 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackARGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1249 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment); 1250 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfARGB8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1029 1251 break; 1030 1252 } 1031 1253 case GraphicsContext3D::SourceFormatARGB16Little: { 1032 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1033 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1034 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackARGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1254 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1255 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfARGB16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1035 1256 break; 1036 1257 } 1037 1258 case GraphicsContext3D::SourceFormatARGB16Big: { 1038 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1039 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1040 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackARGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1259 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1260 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfARGB16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1041 1261 break; 1042 1262 } 1043 1263 case GraphicsContext3D::SourceFormatABGR8: { 1044 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1045 computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1046 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackABGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1264 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment); 1265 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfABGR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1047 1266 break; 1048 1267 } 1049 1268 case GraphicsContext3D::SourceFormatBGRA8: { 1050 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1051 computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1052 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackBGRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1269 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment); 1270 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfBGRA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1053 1271 break; 1054 1272 } 1055 1273 case GraphicsContext3D::SourceFormatBGRA16Little: { 1056 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1057 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1058 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackBGRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1274 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1275 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfBGRA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1059 1276 break; 1060 1277 } 1061 1278 case GraphicsContext3D::SourceFormatBGRA16Big: { 1062 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1063 computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1064 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackBGRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1279 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment); 1280 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfBGRA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1065 1281 break; 1066 1282 } 1067 1283 case GraphicsContext3D::SourceFormatRGBA5551: { 1068 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1069 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1070 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA5551ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1284 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1285 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA5551ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1071 1286 break; 1072 1287 } 1073 1288 case GraphicsContext3D::SourceFormatRGBA4444: { 1074 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1075 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1076 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA4444ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1289 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1290 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA4444ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1077 1291 break; 1078 1292 } 1079 1293 case GraphicsContext3D::SourceFormatRGB565: { 1080 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1081 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1082 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB565ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1294 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1295 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB565ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1083 1296 break; 1084 1297 } 1085 1298 case GraphicsContext3D::SourceFormatR8: { 1086 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1087 computeIncrementParameters<uint8_t>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1088 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1299 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 1, sourceUnpackAlignment); 1300 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1089 1301 break; 1090 1302 } 1091 1303 case GraphicsContext3D::SourceFormatR16Little: { 1092 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1093 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1094 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1304 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1305 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfR16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1095 1306 break; 1096 1307 } 1097 1308 case GraphicsContext3D::SourceFormatR16Big: { 1098 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1099 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1100 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1309 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1310 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfR16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1101 1311 break; 1102 1312 } 1103 1313 case GraphicsContext3D::SourceFormatRA8: { 1104 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1105 computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1106 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1314 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 2, sourceUnpackAlignment); 1315 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfRA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1107 1316 break; 1108 1317 } 1109 1318 case GraphicsContext3D::SourceFormatRA16Little: { 1110 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1111 computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1112 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1319 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment); 1320 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1113 1321 break; 1114 1322 } 1115 1323 case GraphicsContext3D::SourceFormatRA16Big: { 1116 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1117 computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1118 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1324 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment); 1325 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1119 1326 break; 1120 1327 } 1121 1328 case GraphicsContext3D::SourceFormatAR8: { 1122 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1123 computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1124 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackAR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1329 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 2, sourceUnpackAlignment); 1330 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfAR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1125 1331 break; 1126 1332 } 1127 1333 case GraphicsContext3D::SourceFormatAR16Little: { 1128 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1129 computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1130 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackAR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1334 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment); 1335 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfAR16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1131 1336 break; 1132 1337 } 1133 1338 case GraphicsContext3D::SourceFormatAR16Big: { 1134 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1135 computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1136 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackAR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1339 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment); 1340 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfAR16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1137 1341 break; 1138 1342 } 1139 1343 case GraphicsContext3D::SourceFormatA8: { 1140 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1141 computeIncrementParameters<uint8_t>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1142 doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1344 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 1, sourceUnpackAlignment); 1345 doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1143 1346 break; 1144 1347 } 1145 1348 case GraphicsContext3D::SourceFormatA16Little: { 1146 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1147 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1148 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1349 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1350 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1149 1351 break; 1150 1352 } 1151 1353 case GraphicsContext3D::SourceFormatA16Big: { 1152 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1153 computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1154 doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1354 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment); 1355 doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1155 1356 break; 1156 1357 } … … 1164 1365 // currently no native floating-point image formats in WebKit, there are only a 1165 1366 // few upload paths. 1166 template<void packingFunc(const float*, float*)>1167 1367 static void doFloatingPointPacking(const void* sourceData, 1168 1368 GraphicsContext3D::SourceDataFormat sourceDataFormat, … … 1171 1371 unsigned int sourceUnpackAlignment, 1172 1372 float* destinationData, 1373 void rowPackingFunc(const float*, float*, unsigned int), 1173 1374 unsigned int destinationElementsPerPixel) 1174 1375 { 1175 1376 switch (sourceDataFormat) { 1176 1377 case GraphicsContext3D::SourceFormatRGBA8: { 1177 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1178 computeIncrementParameters<float>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1179 ASSERT(!sourceElementsPerRow); // Guaranteed because each color channel is sizeof(float) bytes. 1378 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 4, sourceUnpackAlignment); 1180 1379 const float* source = static_cast<const float*>(sourceData); 1181 unsigned int numElements = width * height * 4;1182 const float* endPointer = source + numElements;1380 const float* endPointer = source + height * sourceElementsPerRow; 1381 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1183 1382 while (source < endPointer) { 1184 packingFunc(source, destinationData);1185 source += sourceElementsPer Pixel;1186 destinationData += destinationElementsPer Pixel;1383 rowPackingFunc(source, destinationData, width); 1384 source += sourceElementsPerRow; 1385 destinationData += destinationElementsPerRow; 1187 1386 } 1188 1387 break; 1189 1388 } 1190 1389 case GraphicsContext3D::SourceFormatRGB32F: { 1191 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1192 computeIncrementParameters<float>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1193 doUnpackingAndPacking<float, float, float, unpackRGB32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1390 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 3, sourceUnpackAlignment); 1391 doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfRGB32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1194 1392 break; 1195 1393 } 1196 1394 case GraphicsContext3D::SourceFormatR32F: { 1197 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1198 computeIncrementParameters<float>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1199 doUnpackingAndPacking<float, float, float, unpackR32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1395 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 1, sourceUnpackAlignment); 1396 doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfR32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1200 1397 break; 1201 1398 } 1202 1399 case GraphicsContext3D::SourceFormatRA32F: { 1203 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1204 computeIncrementParameters<float>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1205 doUnpackingAndPacking<float, float, float, unpackRA32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1400 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 2, sourceUnpackAlignment); 1401 doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfRA32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1206 1402 break; 1207 1403 } 1208 1404 case GraphicsContext3D::SourceFormatA32F: { 1209 unsigned int sourceElementsPerPixel, sourceElementsPerRow; 1210 computeIncrementParameters<float>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); 1211 doUnpackingAndPacking<float, float, float, unpackA32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); 1405 unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 1, sourceUnpackAlignment); 1406 doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfA32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel); 1212 1407 break; 1213 1408 } … … 1239 1434 switch (alphaOp) { 1240 1435 case AlphaDoNothing: 1241 doPacking<uint8_t , packRGBA8ToRGB8>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);1436 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8, 3); 1242 1437 break; 1243 1438 case AlphaDoPremultiply: 1244 doPacking<uint8_t , packRGBA8ToRGB8Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);1439 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8Premultiply, 3); 1245 1440 break; 1246 1441 case AlphaDoUnmultiply: 1247 doPacking<uint8_t , packRGBA8ToRGB8Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);1442 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8Unmultiply, 3); 1248 1443 break; 1249 1444 } … … 1253 1448 case AlphaDoNothing: 1254 1449 ASSERT(sourceDataFormat != SourceFormatRGBA8 || sourceUnpackAlignment > 4); // Handled above with fast case. 1255 doPacking<uint8_t , packRGBA8ToRGBA8>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 4);1450 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8, 4); 1256 1451 break; 1257 1452 case AlphaDoPremultiply: 1258 doPacking<uint8_t , packRGBA8ToRGBA8Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 4);1453 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8Premultiply, 4); 1259 1454 break; 1260 1455 case AlphaDoUnmultiply: 1261 doPacking<uint8_t , packRGBA8ToRGBA8Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 4);1456 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8Unmultiply, 4); 1262 1457 break; 1263 1458 default: … … 1269 1464 // specification, Table 3.15), the alpha channel is chosen 1270 1465 // from the RGBA data. 1271 doPacking<uint8_t , packRGBA8ToA8>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1466 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToA8, 1); 1272 1467 break; 1273 1468 case LUMINANCE: … … 1277 1472 switch (alphaOp) { 1278 1473 case AlphaDoNothing: 1279 doPacking<uint8_t , packRGBA8ToR8>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1474 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8, 1); 1280 1475 break; 1281 1476 case AlphaDoPremultiply: 1282 doPacking<uint8_t , packRGBA8ToR8Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1477 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8Premultiply, 1); 1283 1478 break; 1284 1479 case AlphaDoUnmultiply: 1285 doPacking<uint8_t , packRGBA8ToR8Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1480 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8Unmultiply, 1); 1286 1481 break; 1287 1482 } … … 1293 1488 switch (alphaOp) { 1294 1489 case AlphaDoNothing: 1295 doPacking<uint8_t , packRGBA8ToRA8>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);1490 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8, 2); 1296 1491 break; 1297 1492 case AlphaDoPremultiply: 1298 doPacking<uint8_t , packRGBA8ToRA8Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);1493 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8Premultiply, 2); 1299 1494 break; 1300 1495 case AlphaDoUnmultiply: 1301 doPacking<uint8_t , packRGBA8ToRA8Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);1496 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8Unmultiply, 2); 1302 1497 break; 1303 1498 } … … 1310 1505 switch (alphaOp) { 1311 1506 case AlphaDoNothing: 1312 doPacking<uint16_t , packRGBA8ToUnsignedShort4444>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1507 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444, 1); 1313 1508 break; 1314 1509 case AlphaDoPremultiply: 1315 doPacking<uint16_t , packRGBA8ToUnsignedShort4444Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1510 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444Premultiply, 1); 1316 1511 break; 1317 1512 case AlphaDoUnmultiply: 1318 doPacking<uint16_t , packRGBA8ToUnsignedShort4444Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1513 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444Unmultiply, 1); 1319 1514 break; 1320 1515 } … … 1325 1520 switch (alphaOp) { 1326 1521 case AlphaDoNothing: 1327 doPacking<uint16_t , packRGBA8ToUnsignedShort5551>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1522 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551, 1); 1328 1523 break; 1329 1524 case AlphaDoPremultiply: 1330 doPacking<uint16_t , packRGBA8ToUnsignedShort5551Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1525 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551Premultiply, 1); 1331 1526 break; 1332 1527 case AlphaDoUnmultiply: 1333 doPacking<uint16_t , packRGBA8ToUnsignedShort5551Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1528 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551Unmultiply, 1); 1334 1529 break; 1335 1530 } … … 1340 1535 switch (alphaOp) { 1341 1536 case AlphaDoNothing: 1342 doPacking<uint16_t , packRGBA8ToUnsignedShort565>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1537 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565, 1); 1343 1538 break; 1344 1539 case AlphaDoPremultiply: 1345 doPacking<uint16_t , packRGBA8ToUnsignedShort565Premultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1540 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565Premultiply, 1); 1346 1541 break; 1347 1542 case AlphaDoUnmultiply: 1348 doPacking<uint16_t , packRGBA8ToUnsignedShort565Unmultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1543 doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565Unmultiply, 1); 1349 1544 break; 1350 1545 } … … 1379 1574 switch (alphaOp) { 1380 1575 case AlphaDoNothing: 1381 doFloatingPointPacking <packRGBA32FToRGB32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);1576 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGB32F, 3); 1382 1577 break; 1383 1578 case AlphaDoPremultiply: 1384 doFloatingPointPacking <packRGBA32FToRGB32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);1579 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGB32FPremultiply, 3); 1385 1580 break; 1386 1581 default: … … 1391 1586 // AlphaDoNothing is handled above with fast path. 1392 1587 ASSERT(alphaOp == AlphaDoPremultiply); 1393 doFloatingPointPacking <packRGBA32FToRGBA32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 4);1588 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGBA32FPremultiply, 4); 1394 1589 break; 1395 1590 case ALPHA: … … 1397 1592 // specification, Table 3.15), the alpha channel is chosen 1398 1593 // from the RGBA data. 1399 doFloatingPointPacking <packRGBA32FToA32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1594 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToA32F, 1); 1400 1595 break; 1401 1596 case LUMINANCE: … … 1405 1600 switch (alphaOp) { 1406 1601 case AlphaDoNothing: 1407 doFloatingPointPacking <packRGBA32FToR32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1602 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToR32F, 1); 1408 1603 break; 1409 1604 case AlphaDoPremultiply: 1410 doFloatingPointPacking <packRGBA32FToR32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);1605 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToR32FPremultiply, 1); 1411 1606 break; 1412 1607 default: … … 1420 1615 switch (alphaOp) { 1421 1616 case AlphaDoNothing: 1422 doFloatingPointPacking <packRGBA32FToRA32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);1617 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRA32F, 2); 1423 1618 break; 1424 1619 case AlphaDoPremultiply: 1425 doFloatingPointPacking <packRGBA32FToRA32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);1620 doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRA32FPremultiply, 2); 1426 1621 break; 1427 1622 default:
Note: See TracChangeset
for help on using the changeset viewer.