| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxge/dib/dib_int.h" | 7 #include "core/fxge/dib/dib_int.h" |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 #include "core/include/fxge/fx_ge.h" | 9 #include "core/include/fxge/fx_ge.h" |
| 10 | 10 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 *mid = (*mid - *min) * s / (*max - *min); | 193 *mid = (*mid - *min) * s / (*max - *min); |
| 194 *max = s; | 194 *max = s; |
| 195 *min = 0; | 195 *min = 0; |
| 196 } | 196 } |
| 197 return color; | 197 return color; |
| 198 } | 198 } |
| 199 void _RGB_Blend(int blend_mode, | 199 void _RGB_Blend(int blend_mode, |
| 200 const uint8_t* src_scan, | 200 const uint8_t* src_scan, |
| 201 uint8_t* dest_scan, | 201 uint8_t* dest_scan, |
| 202 int results[3]) { | 202 int results[3]) { |
| 203 _RGB src, back, result; | 203 _RGB src; |
| 204 _RGB back; |
| 205 _RGB result = {0, 0, 0}; |
| 204 src.red = src_scan[2]; | 206 src.red = src_scan[2]; |
| 205 src.green = src_scan[1]; | 207 src.green = src_scan[1]; |
| 206 src.blue = src_scan[0]; | 208 src.blue = src_scan[0]; |
| 207 back.red = dest_scan[2]; | 209 back.red = dest_scan[2]; |
| 208 back.green = dest_scan[1]; | 210 back.green = dest_scan[1]; |
| 209 back.blue = dest_scan[0]; | 211 back.blue = dest_scan[0]; |
| 210 switch (blend_mode) { | 212 switch (blend_mode) { |
| 211 case FXDIB_BLEND_HUE: | 213 case FXDIB_BLEND_HUE: |
| 212 result = _SetLum(_SetSat(src, _Sat(back)), _Lum(back)); | 214 result = _SetLum(_SetSat(src, _Sat(back)), _Lum(back)); |
| 213 break; | 215 break; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 const uint8_t* clip_scan, | 286 const uint8_t* clip_scan, |
| 285 const uint8_t* src_alpha_scan, | 287 const uint8_t* src_alpha_scan, |
| 286 uint8_t* dst_alpha_scan, | 288 uint8_t* dst_alpha_scan, |
| 287 void* pIccTransform) { | 289 void* pIccTransform) { |
| 288 ICodec_IccModule* pIccModule = nullptr; | 290 ICodec_IccModule* pIccModule = nullptr; |
| 289 if (pIccTransform) | 291 if (pIccTransform) |
| 290 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 292 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 291 | 293 |
| 292 if (blend_type) { | 294 if (blend_type) { |
| 293 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 295 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 294 int blended_color; | |
| 295 if (src_alpha_scan) { | 296 if (src_alpha_scan) { |
| 296 for (int col = 0; col < pixel_count; col++) { | 297 for (int col = 0; col < pixel_count; col++) { |
| 297 uint8_t back_alpha = *dst_alpha_scan; | 298 uint8_t back_alpha = *dst_alpha_scan; |
| 298 if (back_alpha == 0) { | 299 if (back_alpha == 0) { |
| 299 int src_alpha = *src_alpha_scan++; | 300 int src_alpha = *src_alpha_scan++; |
| 300 if (clip_scan) | 301 if (clip_scan) |
| 301 src_alpha = clip_scan[col] * src_alpha / 255; | 302 src_alpha = clip_scan[col] * src_alpha / 255; |
| 302 | 303 |
| 303 if (src_alpha) { | 304 if (src_alpha) { |
| 304 if (pIccTransform) { | 305 if (pIccTransform) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 325 continue; | 326 continue; |
| 326 } | 327 } |
| 327 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); | 328 *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); |
| 328 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); | 329 int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); |
| 329 uint8_t gray; | 330 uint8_t gray; |
| 330 if (pIccTransform) { | 331 if (pIccTransform) { |
| 331 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | 332 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 332 } else { | 333 } else { |
| 333 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 334 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 334 } | 335 } |
| 335 if (bNonseparableBlend) { | 336 if (bNonseparableBlend) |
| 336 blended_color = | 337 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 337 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 338 else |
| 338 } | 339 gray = _BLEND(blend_type, *dest_scan, gray); |
| 339 gray = bNonseparableBlend ? blended_color | |
| 340 : _BLEND(blend_type, *dest_scan, gray); | |
| 341 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 340 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 342 dest_scan++; | 341 dest_scan++; |
| 343 dst_alpha_scan++; | 342 dst_alpha_scan++; |
| 344 src_scan += 3; | 343 src_scan += 3; |
| 345 } | 344 } |
| 346 } else { | 345 } else { |
| 347 for (int col = 0; col < pixel_count; col++) { | 346 for (int col = 0; col < pixel_count; col++) { |
| 348 uint8_t back_alpha = *dst_alpha_scan; | 347 uint8_t back_alpha = *dst_alpha_scan; |
| 349 if (back_alpha == 0) { | 348 if (back_alpha == 0) { |
| 350 int src_alpha = src_scan[3]; | 349 int src_alpha = src_scan[3]; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 const uint8_t* clip_scan, | 490 const uint8_t* clip_scan, |
| 492 const uint8_t* src_alpha_scan, | 491 const uint8_t* src_alpha_scan, |
| 493 void* pIccTransform) { | 492 void* pIccTransform) { |
| 494 ICodec_IccModule* pIccModule = NULL; | 493 ICodec_IccModule* pIccModule = NULL; |
| 495 uint8_t gray; | 494 uint8_t gray; |
| 496 if (pIccTransform) | 495 if (pIccTransform) |
| 497 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 496 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 498 | 497 |
| 499 if (blend_type) { | 498 if (blend_type) { |
| 500 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 499 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 501 int blended_color; | |
| 502 if (src_alpha_scan) { | 500 if (src_alpha_scan) { |
| 503 for (int col = 0; col < pixel_count; col++) { | 501 for (int col = 0; col < pixel_count; col++) { |
| 504 int src_alpha = *src_alpha_scan++; | 502 int src_alpha = *src_alpha_scan++; |
| 505 if (clip_scan) | 503 if (clip_scan) |
| 506 src_alpha = clip_scan[col] * src_alpha / 255; | 504 src_alpha = clip_scan[col] * src_alpha / 255; |
| 507 | 505 |
| 508 if (src_alpha) { | 506 if (src_alpha) { |
| 509 if (pIccTransform) | 507 if (pIccTransform) |
| 510 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | 508 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 511 else | 509 else |
| 512 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 510 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 513 | 511 |
| 514 if (bNonseparableBlend) { | 512 if (bNonseparableBlend) |
| 515 blended_color = | 513 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 516 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 514 else |
| 517 } | 515 gray = _BLEND(blend_type, *dest_scan, gray); |
| 518 gray = bNonseparableBlend ? blended_color | |
| 519 : _BLEND(blend_type, *dest_scan, gray); | |
| 520 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 516 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 521 } | 517 } |
| 522 dest_scan++; | 518 dest_scan++; |
| 523 src_scan += 3; | 519 src_scan += 3; |
| 524 } | 520 } |
| 525 } else { | 521 } else { |
| 526 for (int col = 0; col < pixel_count; col++) { | 522 for (int col = 0; col < pixel_count; col++) { |
| 527 int src_alpha = src_scan[3]; | 523 int src_alpha = src_scan[3]; |
| 528 if (clip_scan) | 524 if (clip_scan) |
| 529 src_alpha = clip_scan[col] * src_alpha / 255; | 525 src_alpha = clip_scan[col] * src_alpha / 255; |
| 530 | 526 |
| 531 if (src_alpha) { | 527 if (src_alpha) { |
| 532 if (pIccTransform) | 528 if (pIccTransform) |
| 533 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | 529 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 534 else | 530 else |
| 535 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 531 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 536 | 532 |
| 537 if (bNonseparableBlend) { | 533 if (bNonseparableBlend) |
| 538 blended_color = | 534 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 539 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 535 else |
| 540 } | 536 gray = _BLEND(blend_type, *dest_scan, gray); |
| 541 gray = bNonseparableBlend ? blended_color | |
| 542 : _BLEND(blend_type, *dest_scan, gray); | |
| 543 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 537 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 544 } | 538 } |
| 545 dest_scan++; | 539 dest_scan++; |
| 546 src_scan += 4; | 540 src_scan += 4; |
| 547 } | 541 } |
| 548 } | 542 } |
| 549 return; | 543 return; |
| 550 } | 544 } |
| 551 if (src_alpha_scan) { | 545 if (src_alpha_scan) { |
| 552 for (int col = 0; col < pixel_count; col++) { | 546 for (int col = 0; col < pixel_count; col++) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 int blend_type, | 586 int blend_type, |
| 593 const uint8_t* clip_scan, | 587 const uint8_t* clip_scan, |
| 594 void* pIccTransform) { | 588 void* pIccTransform) { |
| 595 ICodec_IccModule* pIccModule = NULL; | 589 ICodec_IccModule* pIccModule = NULL; |
| 596 uint8_t gray; | 590 uint8_t gray; |
| 597 if (pIccTransform) { | 591 if (pIccTransform) { |
| 598 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 592 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 599 } | 593 } |
| 600 if (blend_type) { | 594 if (blend_type) { |
| 601 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 595 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 602 int blended_color; | |
| 603 for (int col = 0; col < pixel_count; col++) { | 596 for (int col = 0; col < pixel_count; col++) { |
| 604 if (pIccTransform) { | 597 if (pIccTransform) { |
| 605 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | 598 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 606 } else { | 599 } else { |
| 607 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 600 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 608 } | 601 } |
| 609 if (bNonseparableBlend) { | 602 if (bNonseparableBlend) |
| 610 blended_color = | 603 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 611 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 604 else |
| 612 } | 605 gray = _BLEND(blend_type, *dest_scan, gray); |
| 613 gray = bNonseparableBlend ? blended_color | |
| 614 : _BLEND(blend_type, *dest_scan, gray); | |
| 615 if (clip_scan && clip_scan[col] < 255) { | 606 if (clip_scan && clip_scan[col] < 255) { |
| 616 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); | 607 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 617 } else { | 608 } else { |
| 618 *dest_scan = gray; | 609 *dest_scan = gray; |
| 619 } | 610 } |
| 620 dest_scan++; | 611 dest_scan++; |
| 621 src_scan += src_Bpp; | 612 src_scan += src_Bpp; |
| 622 } | 613 } |
| 623 return; | 614 return; |
| 624 } | 615 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 643 int pixel_count, | 634 int pixel_count, |
| 644 int blend_type, | 635 int blend_type, |
| 645 const uint8_t* clip_scan, | 636 const uint8_t* clip_scan, |
| 646 uint8_t* dest_alpha_scan, | 637 uint8_t* dest_alpha_scan, |
| 647 void* pIccTransform) { | 638 void* pIccTransform) { |
| 648 ICodec_IccModule* pIccModule = NULL; | 639 ICodec_IccModule* pIccModule = NULL; |
| 649 if (pIccTransform) { | 640 if (pIccTransform) { |
| 650 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 641 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 651 } | 642 } |
| 652 if (blend_type) { | 643 if (blend_type) { |
| 653 int blended_color; | |
| 654 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 644 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 655 for (int col = 0; col < pixel_count; col++) { | 645 for (int col = 0; col < pixel_count; col++) { |
| 656 int back_alpha = *dest_alpha_scan; | 646 int back_alpha = *dest_alpha_scan; |
| 657 if (back_alpha == 0) { | 647 if (back_alpha == 0) { |
| 658 if (pIccTransform) { | 648 if (pIccTransform) { |
| 659 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1); | 649 pIccModule->TranslateScanline(pIccTransform, dest_scan, src_scan, 1); |
| 660 } else { | 650 } else { |
| 661 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 651 *dest_scan = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 662 } | 652 } |
| 663 dest_scan++; | 653 dest_scan++; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 678 uint8_t dest_alpha = | 668 uint8_t dest_alpha = |
| 679 back_alpha + src_alpha - back_alpha * src_alpha / 255; | 669 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 680 *dest_alpha_scan++ = dest_alpha; | 670 *dest_alpha_scan++ = dest_alpha; |
| 681 int alpha_ratio = src_alpha * 255 / dest_alpha; | 671 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 682 uint8_t gray; | 672 uint8_t gray; |
| 683 if (pIccTransform) { | 673 if (pIccTransform) { |
| 684 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); | 674 pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); |
| 685 } else { | 675 } else { |
| 686 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); | 676 gray = FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); |
| 687 } | 677 } |
| 688 if (bNonseparableBlend) { | 678 if (bNonseparableBlend) |
| 689 blended_color = | 679 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 690 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 680 else |
| 691 } | 681 gray = _BLEND(blend_type, *dest_scan, gray); |
| 692 gray = bNonseparableBlend ? blended_color | |
| 693 : _BLEND(blend_type, *dest_scan, gray); | |
| 694 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 682 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 695 dest_scan++; | 683 dest_scan++; |
| 696 src_scan += src_Bpp; | 684 src_scan += src_Bpp; |
| 697 } | 685 } |
| 698 return; | 686 return; |
| 699 } | 687 } |
| 700 for (int col = 0; col < pixel_count; col++) { | 688 for (int col = 0; col < pixel_count; col++) { |
| 701 int src_alpha = 255; | 689 int src_alpha = 255; |
| 702 if (clip_scan) { | 690 if (clip_scan) { |
| 703 src_alpha = clip_scan[col]; | 691 src_alpha = clip_scan[col]; |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 inline void _CompositeRow_8bppPal2Gray(uint8_t* dest_scan, | 1830 inline void _CompositeRow_8bppPal2Gray(uint8_t* dest_scan, |
| 1843 const uint8_t* src_scan, | 1831 const uint8_t* src_scan, |
| 1844 const uint8_t* pPalette, | 1832 const uint8_t* pPalette, |
| 1845 int pixel_count, | 1833 int pixel_count, |
| 1846 int blend_type, | 1834 int blend_type, |
| 1847 const uint8_t* clip_scan, | 1835 const uint8_t* clip_scan, |
| 1848 const uint8_t* src_alpha_scan) { | 1836 const uint8_t* src_alpha_scan) { |
| 1849 if (src_alpha_scan) { | 1837 if (src_alpha_scan) { |
| 1850 if (blend_type) { | 1838 if (blend_type) { |
| 1851 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1839 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1852 int blended_color; | |
| 1853 for (int col = 0; col < pixel_count; col++) { | 1840 for (int col = 0; col < pixel_count; col++) { |
| 1854 uint8_t gray = pPalette[*src_scan]; | 1841 uint8_t gray = pPalette[*src_scan]; |
| 1855 int src_alpha = *src_alpha_scan++; | 1842 int src_alpha = *src_alpha_scan++; |
| 1856 if (clip_scan) { | 1843 if (clip_scan) { |
| 1857 src_alpha = clip_scan[col] * src_alpha / 255; | 1844 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1858 } | 1845 } |
| 1859 if (bNonseparableBlend) { | 1846 if (bNonseparableBlend) |
| 1860 blended_color = | 1847 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1861 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 1848 else |
| 1862 } | 1849 gray = _BLEND(blend_type, *dest_scan, gray); |
| 1863 gray = bNonseparableBlend ? blended_color | |
| 1864 : _BLEND(blend_type, *dest_scan, gray); | |
| 1865 if (src_alpha) { | 1850 if (src_alpha) { |
| 1866 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 1851 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 1867 } else { | 1852 } else { |
| 1868 *dest_scan = gray; | 1853 *dest_scan = gray; |
| 1869 } | 1854 } |
| 1870 dest_scan++; | 1855 dest_scan++; |
| 1871 src_scan++; | 1856 src_scan++; |
| 1872 } | 1857 } |
| 1873 return; | 1858 return; |
| 1874 } | 1859 } |
| 1875 for (int col = 0; col < pixel_count; col++) { | 1860 for (int col = 0; col < pixel_count; col++) { |
| 1876 uint8_t gray = pPalette[*src_scan]; | 1861 uint8_t gray = pPalette[*src_scan]; |
| 1877 int src_alpha = *src_alpha_scan++; | 1862 int src_alpha = *src_alpha_scan++; |
| 1878 if (clip_scan) { | 1863 if (clip_scan) { |
| 1879 src_alpha = clip_scan[col] * src_alpha / 255; | 1864 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1880 } | 1865 } |
| 1881 if (src_alpha) { | 1866 if (src_alpha) { |
| 1882 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); | 1867 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); |
| 1883 } else { | 1868 } else { |
| 1884 *dest_scan = gray; | 1869 *dest_scan = gray; |
| 1885 } | 1870 } |
| 1886 dest_scan++; | 1871 dest_scan++; |
| 1887 src_scan++; | 1872 src_scan++; |
| 1888 } | 1873 } |
| 1889 } else { | 1874 } else { |
| 1890 if (blend_type) { | 1875 if (blend_type) { |
| 1891 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1876 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1892 int blended_color; | |
| 1893 for (int col = 0; col < pixel_count; col++) { | 1877 for (int col = 0; col < pixel_count; col++) { |
| 1894 uint8_t gray = pPalette[*src_scan]; | 1878 uint8_t gray = pPalette[*src_scan]; |
| 1895 if (bNonseparableBlend) { | 1879 if (bNonseparableBlend) |
| 1896 blended_color = | 1880 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1897 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 1881 else |
| 1898 } | 1882 gray = _BLEND(blend_type, *dest_scan, gray); |
| 1899 gray = bNonseparableBlend ? blended_color | |
| 1900 : _BLEND(blend_type, *dest_scan, gray); | |
| 1901 if (clip_scan && clip_scan[col] < 255) { | 1883 if (clip_scan && clip_scan[col] < 255) { |
| 1902 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); | 1884 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 1903 } else { | 1885 } else { |
| 1904 *dest_scan = gray; | 1886 *dest_scan = gray; |
| 1905 } | 1887 } |
| 1906 dest_scan++; | 1888 dest_scan++; |
| 1907 src_scan++; | 1889 src_scan++; |
| 1908 } | 1890 } |
| 1909 return; | 1891 return; |
| 1910 } | 1892 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1924 const uint8_t* src_scan, | 1906 const uint8_t* src_scan, |
| 1925 const uint8_t* pPalette, | 1907 const uint8_t* pPalette, |
| 1926 int pixel_count, | 1908 int pixel_count, |
| 1927 int blend_type, | 1909 int blend_type, |
| 1928 const uint8_t* clip_scan, | 1910 const uint8_t* clip_scan, |
| 1929 uint8_t* dest_alpha_scan, | 1911 uint8_t* dest_alpha_scan, |
| 1930 const uint8_t* src_alpha_scan) { | 1912 const uint8_t* src_alpha_scan) { |
| 1931 if (src_alpha_scan) { | 1913 if (src_alpha_scan) { |
| 1932 if (blend_type) { | 1914 if (blend_type) { |
| 1933 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1915 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 1934 int blended_color; | |
| 1935 for (int col = 0; col < pixel_count; col++) { | 1916 for (int col = 0; col < pixel_count; col++) { |
| 1936 uint8_t gray = pPalette[*src_scan]; | 1917 uint8_t gray = pPalette[*src_scan]; |
| 1937 src_scan++; | 1918 src_scan++; |
| 1938 uint8_t back_alpha = *dest_alpha_scan; | 1919 uint8_t back_alpha = *dest_alpha_scan; |
| 1939 if (back_alpha == 0) { | 1920 if (back_alpha == 0) { |
| 1940 int src_alpha = *src_alpha_scan++; | 1921 int src_alpha = *src_alpha_scan++; |
| 1941 if (clip_scan) { | 1922 if (clip_scan) { |
| 1942 src_alpha = clip_scan[col] * src_alpha / 255; | 1923 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1943 } | 1924 } |
| 1944 if (src_alpha) { | 1925 if (src_alpha) { |
| 1945 *dest_scan = gray; | 1926 *dest_scan = gray; |
| 1946 *dest_alpha_scan = src_alpha; | 1927 *dest_alpha_scan = src_alpha; |
| 1947 } | 1928 } |
| 1948 dest_scan++; | 1929 dest_scan++; |
| 1949 dest_alpha_scan++; | 1930 dest_alpha_scan++; |
| 1950 continue; | 1931 continue; |
| 1951 } | 1932 } |
| 1952 uint8_t src_alpha = *src_alpha_scan++; | 1933 uint8_t src_alpha = *src_alpha_scan++; |
| 1953 if (clip_scan) { | 1934 if (clip_scan) { |
| 1954 src_alpha = clip_scan[col] * src_alpha / 255; | 1935 src_alpha = clip_scan[col] * src_alpha / 255; |
| 1955 } | 1936 } |
| 1956 if (src_alpha == 0) { | 1937 if (src_alpha == 0) { |
| 1957 dest_scan++; | 1938 dest_scan++; |
| 1958 dest_alpha_scan++; | 1939 dest_alpha_scan++; |
| 1959 continue; | 1940 continue; |
| 1960 } | 1941 } |
| 1961 *dest_alpha_scan = | 1942 *dest_alpha_scan = |
| 1962 back_alpha + src_alpha - back_alpha * src_alpha / 255; | 1943 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 1963 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); | 1944 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); |
| 1964 if (bNonseparableBlend) { | 1945 if (bNonseparableBlend) |
| 1965 blended_color = | 1946 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 1966 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 1947 else |
| 1967 } | 1948 gray = _BLEND(blend_type, *dest_scan, gray); |
| 1968 gray = bNonseparableBlend ? blended_color | |
| 1969 : _BLEND(blend_type, *dest_scan, gray); | |
| 1970 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 1949 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 1971 dest_alpha_scan++; | 1950 dest_alpha_scan++; |
| 1972 dest_scan++; | 1951 dest_scan++; |
| 1973 } | 1952 } |
| 1974 return; | 1953 return; |
| 1975 } | 1954 } |
| 1976 for (int col = 0; col < pixel_count; col++) { | 1955 for (int col = 0; col < pixel_count; col++) { |
| 1977 uint8_t gray = pPalette[*src_scan]; | 1956 uint8_t gray = pPalette[*src_scan]; |
| 1978 src_scan++; | 1957 src_scan++; |
| 1979 uint8_t back_alpha = *dest_alpha_scan; | 1958 uint8_t back_alpha = *dest_alpha_scan; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2001 } | 1980 } |
| 2002 *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; | 1981 *dest_alpha_scan = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2003 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); | 1982 int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); |
| 2004 dest_alpha_scan++; | 1983 dest_alpha_scan++; |
| 2005 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 1984 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 2006 dest_scan++; | 1985 dest_scan++; |
| 2007 } | 1986 } |
| 2008 } else { | 1987 } else { |
| 2009 if (blend_type) { | 1988 if (blend_type) { |
| 2010 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 1989 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 2011 int blended_color; | |
| 2012 for (int col = 0; col < pixel_count; col++) { | 1990 for (int col = 0; col < pixel_count; col++) { |
| 2013 uint8_t gray = pPalette[*src_scan]; | 1991 uint8_t gray = pPalette[*src_scan]; |
| 2014 src_scan++; | 1992 src_scan++; |
| 2015 if (!clip_scan || clip_scan[col] == 255) { | 1993 if (!clip_scan || clip_scan[col] == 255) { |
| 2016 *dest_scan++ = gray; | 1994 *dest_scan++ = gray; |
| 2017 *dest_alpha_scan++ = 255; | 1995 *dest_alpha_scan++ = 255; |
| 2018 continue; | 1996 continue; |
| 2019 } | 1997 } |
| 2020 int src_alpha = clip_scan[col]; | 1998 int src_alpha = clip_scan[col]; |
| 2021 if (src_alpha == 0) { | 1999 if (src_alpha == 0) { |
| 2022 dest_scan++; | 2000 dest_scan++; |
| 2023 dest_alpha_scan++; | 2001 dest_alpha_scan++; |
| 2024 continue; | 2002 continue; |
| 2025 } | 2003 } |
| 2026 int back_alpha = *dest_alpha_scan; | 2004 int back_alpha = *dest_alpha_scan; |
| 2027 uint8_t dest_alpha = | 2005 uint8_t dest_alpha = |
| 2028 back_alpha + src_alpha - back_alpha * src_alpha / 255; | 2006 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2029 *dest_alpha_scan++ = dest_alpha; | 2007 *dest_alpha_scan++ = dest_alpha; |
| 2030 int alpha_ratio = src_alpha * 255 / dest_alpha; | 2008 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2031 if (bNonseparableBlend) { | 2009 if (bNonseparableBlend) |
| 2032 blended_color = | 2010 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2033 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 2011 else |
| 2034 } | 2012 gray = _BLEND(blend_type, *dest_scan, gray); |
| 2035 gray = bNonseparableBlend ? blended_color | |
| 2036 : _BLEND(blend_type, *dest_scan, gray); | |
| 2037 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 2013 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 2038 dest_scan++; | 2014 dest_scan++; |
| 2039 } | 2015 } |
| 2040 return; | 2016 return; |
| 2041 } | 2017 } |
| 2042 for (int col = 0; col < pixel_count; col++) { | 2018 for (int col = 0; col < pixel_count; col++) { |
| 2043 uint8_t gray = pPalette[*src_scan]; | 2019 uint8_t gray = pPalette[*src_scan]; |
| 2044 src_scan++; | 2020 src_scan++; |
| 2045 if (!clip_scan || clip_scan[col] == 255) { | 2021 if (!clip_scan || clip_scan[col] == 255) { |
| 2046 *dest_scan++ = gray; | 2022 *dest_scan++ = gray; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2067 const uint8_t* src_scan, | 2043 const uint8_t* src_scan, |
| 2068 int src_left, | 2044 int src_left, |
| 2069 const uint8_t* pPalette, | 2045 const uint8_t* pPalette, |
| 2070 int pixel_count, | 2046 int pixel_count, |
| 2071 int blend_type, | 2047 int blend_type, |
| 2072 const uint8_t* clip_scan) { | 2048 const uint8_t* clip_scan) { |
| 2073 int reset_gray = pPalette[0]; | 2049 int reset_gray = pPalette[0]; |
| 2074 int set_gray = pPalette[1]; | 2050 int set_gray = pPalette[1]; |
| 2075 if (blend_type) { | 2051 if (blend_type) { |
| 2076 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 2052 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 2077 int blended_color; | |
| 2078 for (int col = 0; col < pixel_count; col++) { | 2053 for (int col = 0; col < pixel_count; col++) { |
| 2079 uint8_t gray = | 2054 uint8_t gray = |
| 2080 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) | 2055 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2081 ? set_gray | 2056 ? set_gray |
| 2082 : reset_gray; | 2057 : reset_gray; |
| 2083 if (bNonseparableBlend) { | 2058 if (bNonseparableBlend) |
| 2084 blended_color = | 2059 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2085 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 2060 else |
| 2086 } | 2061 gray = _BLEND(blend_type, *dest_scan, gray); |
| 2087 gray = bNonseparableBlend ? blended_color | |
| 2088 : _BLEND(blend_type, *dest_scan, gray); | |
| 2089 if (clip_scan && clip_scan[col] < 255) { | 2062 if (clip_scan && clip_scan[col] < 255) { |
| 2090 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); | 2063 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); |
| 2091 } else { | 2064 } else { |
| 2092 *dest_scan = gray; | 2065 *dest_scan = gray; |
| 2093 } | 2066 } |
| 2094 dest_scan++; | 2067 dest_scan++; |
| 2095 } | 2068 } |
| 2096 return; | 2069 return; |
| 2097 } | 2070 } |
| 2098 for (int col = 0; col < pixel_count; col++) { | 2071 for (int col = 0; col < pixel_count; col++) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2113 int src_left, | 2086 int src_left, |
| 2114 const uint8_t* pPalette, | 2087 const uint8_t* pPalette, |
| 2115 int pixel_count, | 2088 int pixel_count, |
| 2116 int blend_type, | 2089 int blend_type, |
| 2117 const uint8_t* clip_scan, | 2090 const uint8_t* clip_scan, |
| 2118 uint8_t* dest_alpha_scan) { | 2091 uint8_t* dest_alpha_scan) { |
| 2119 int reset_gray = pPalette[0]; | 2092 int reset_gray = pPalette[0]; |
| 2120 int set_gray = pPalette[1]; | 2093 int set_gray = pPalette[1]; |
| 2121 if (blend_type) { | 2094 if (blend_type) { |
| 2122 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; | 2095 FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; |
| 2123 int blended_color; | |
| 2124 for (int col = 0; col < pixel_count; col++) { | 2096 for (int col = 0; col < pixel_count; col++) { |
| 2125 uint8_t gray = | 2097 uint8_t gray = |
| 2126 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) | 2098 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2127 ? set_gray | 2099 ? set_gray |
| 2128 : reset_gray; | 2100 : reset_gray; |
| 2129 if (!clip_scan || clip_scan[col] == 255) { | 2101 if (!clip_scan || clip_scan[col] == 255) { |
| 2130 *dest_scan++ = gray; | 2102 *dest_scan++ = gray; |
| 2131 *dest_alpha_scan++ = 255; | 2103 *dest_alpha_scan++ = 255; |
| 2132 continue; | 2104 continue; |
| 2133 } | 2105 } |
| 2134 int src_alpha = clip_scan[col]; | 2106 int src_alpha = clip_scan[col]; |
| 2135 if (src_alpha == 0) { | 2107 if (src_alpha == 0) { |
| 2136 dest_scan++; | 2108 dest_scan++; |
| 2137 dest_alpha_scan++; | 2109 dest_alpha_scan++; |
| 2138 continue; | 2110 continue; |
| 2139 } | 2111 } |
| 2140 int back_alpha = *dest_alpha_scan; | 2112 int back_alpha = *dest_alpha_scan; |
| 2141 uint8_t dest_alpha = | 2113 uint8_t dest_alpha = |
| 2142 back_alpha + src_alpha - back_alpha * src_alpha / 255; | 2114 back_alpha + src_alpha - back_alpha * src_alpha / 255; |
| 2143 *dest_alpha_scan++ = dest_alpha; | 2115 *dest_alpha_scan++ = dest_alpha; |
| 2144 int alpha_ratio = src_alpha * 255 / dest_alpha; | 2116 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 2145 if (bNonseparableBlend) { | 2117 if (bNonseparableBlend) |
| 2146 blended_color = | 2118 gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; |
| 2147 blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; | 2119 else |
| 2148 } | 2120 gray = _BLEND(blend_type, *dest_scan, gray); |
| 2149 gray = bNonseparableBlend ? blended_color | |
| 2150 : _BLEND(blend_type, *dest_scan, gray); | |
| 2151 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 2121 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
| 2152 dest_scan++; | 2122 dest_scan++; |
| 2153 } | 2123 } |
| 2154 return; | 2124 return; |
| 2155 } | 2125 } |
| 2156 for (int col = 0; col < pixel_count; col++) { | 2126 for (int col = 0; col < pixel_count; col++) { |
| 2157 uint8_t gray = | 2127 uint8_t gray = |
| 2158 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) | 2128 (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8))) |
| 2159 ? set_gray | 2129 ? set_gray |
| 2160 : reset_gray; | 2130 : reset_gray; |
| (...skipping 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5201 } | 5171 } |
| 5202 src_alpha_scan = m_pScanlineAlphaV; | 5172 src_alpha_scan = m_pScanlineAlphaV; |
| 5203 dest_alpha_scan = dest_alpha_buf; | 5173 dest_alpha_scan = dest_alpha_buf; |
| 5204 if (dest_alpha_scan) { | 5174 if (dest_alpha_scan) { |
| 5205 for (i = 0; i < m_DestHeight; i++) { | 5175 for (i = 0; i < m_DestHeight; i++) { |
| 5206 *dest_alpha_scan = *src_alpha_scan++; | 5176 *dest_alpha_scan = *src_alpha_scan++; |
| 5207 dest_alpha_scan += y_alpha_step; | 5177 dest_alpha_scan += y_alpha_step; |
| 5208 } | 5178 } |
| 5209 } | 5179 } |
| 5210 } | 5180 } |
| OLD | NEW |