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 #include "core/include/fxge/fx_ge.h" | 5 #include "core/include/fxge/fx_ge.h" |
6 | 6 |
7 //#define _SKIA_SUPPORT_ | 7 // #define _SKIA_SUPPORT_ |
Tom Sepez
2016/02/23 17:44:19
Nit: remove this line.
dsinclair
2016/02/23 19:14:01
Done.
| |
8 #if defined(_SKIA_SUPPORT_) | 8 #if defined(_SKIA_SUPPORT_) |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "core/include/fxcodec/fx_codec.h" | 10 #include "core/include/fxcodec/fx_codec.h" |
11 #include "core/src/fxge/skia/fx_skia_blitter_new.h" | 11 #include "core/src/fxge/skia/fx_skia_blitter_new.h" |
12 | 12 |
13 // We use our own renderer here to make it simple | 13 // We use our own renderer here to make it simple |
14 void CFX_SkiaRenderer::blitAntiH(int x, | 14 void CFX_SkiaRenderer::blitAntiH(int x, |
15 int y, | 15 int y, |
16 const SkAlpha antialias[], | 16 const SkAlpha antialias[], |
17 const int16_t runs[]) { | 17 const int16_t runs[]) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 383 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
384 int col_end = | 384 int col_end = |
385 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 385 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
386 if (col_end < col_start) | 386 if (col_end < col_start) |
387 return; // do nothing. | 387 return; // do nothing. |
388 dest_scan += col_start << 2; | 388 dest_scan += col_start << 2; |
389 if (m_Alpha == 255 && cover_scan == 255) { | 389 if (m_Alpha == 255 && cover_scan == 255) { |
390 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); | 390 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
391 return; | 391 return; |
392 } | 392 } |
393 int src_alpha; | 393 int src_alpha = m_Alpha * cover_scan / 255; |
394 #if 0 | |
395 if (m_bFullCover) { | |
396 if (m_Alpha == 255) { | |
397 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | |
398 return; | |
399 } | |
400 } | |
401 else | |
402 #endif | |
403 src_alpha = m_Alpha * cover_scan / 255; | |
404 for (int col = col_start; col < col_end; col++) { | 394 for (int col = col_start; col < col_end; col++) { |
405 // Dest format: Argb | 395 // Dest format: Argb |
406 // calculate destination alpha (it's union of source and dest alpha) | 396 // calculate destination alpha (it's union of source and dest alpha) |
407 if (dest_scan[3] == 0) { | 397 if (dest_scan[3] == 0) { |
408 dest_scan[3] = src_alpha; | 398 dest_scan[3] = src_alpha; |
409 *dest_scan++ = m_Blue; | 399 *dest_scan++ = m_Blue; |
410 *dest_scan++ = m_Green; | 400 *dest_scan++ = m_Green; |
411 *dest_scan = m_Red; | 401 *dest_scan = m_Red; |
412 dest_scan += 2; | 402 dest_scan += 2; |
413 continue; | 403 continue; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 674 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
685 int col_end = | 675 int col_end = |
686 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 676 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
687 if (col_end < col_start) | 677 if (col_end < col_start) |
688 return; // do nothing. | 678 return; // do nothing. |
689 dest_scan += (col_start << 2); | 679 dest_scan += (col_start << 2); |
690 if (m_Alpha == 255 && cover_scan == 255) { | 680 if (m_Alpha == 255 && cover_scan == 255) { |
691 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); | 681 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
692 return; | 682 return; |
693 } | 683 } |
694 int src_alpha; | 684 int src_alpha = m_Alpha * cover_scan / 255; |
695 #if 0 | |
696 if (m_bFullCover) | |
697 src_alpha = m_Alpha; | |
698 else | |
699 #endif | |
700 src_alpha = m_Alpha * cover_scan / 255; | |
701 for (int col = col_start; col < col_end; col++) { | 685 for (int col = col_start; col < col_end; col++) { |
702 // Dest format: Rgb32 | 686 // Dest format: Rgb32 |
703 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); | 687 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
704 dest_scan++; | 688 dest_scan++; |
705 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); | 689 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
706 dest_scan++; | 690 dest_scan++; |
707 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); | 691 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
708 dest_scan += 2; | 692 dest_scan += 2; |
709 } | 693 } |
710 } | 694 } |
(...skipping 17 matching lines...) Expand all Loading... | |
728 if (col_end < col_start) | 712 if (col_end < col_start) |
729 return; // do nothing. | 713 return; // do nothing. |
730 dest_scan += col_start << 2; | 714 dest_scan += col_start << 2; |
731 ori_scan += col_start << 2; | 715 ori_scan += col_start << 2; |
732 if (m_Alpha == 255 && cover_scan == 255) { | 716 if (m_Alpha == 255 && cover_scan == 255) { |
733 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); | 717 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
734 return; | 718 return; |
735 } | 719 } |
736 int src_alpha = m_Alpha; | 720 int src_alpha = m_Alpha; |
737 for (int col = col_start; col < col_end; col++) { | 721 for (int col = col_start; col < col_end; col++) { |
738 #if 0 | |
739 if (m_bFullCover) { | |
740 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha) ; | |
741 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha ); | |
742 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | |
743 dest_scan += 2; ori_scan += 2; | |
744 continue; | |
745 } | |
746 #endif | |
747 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | 722 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
748 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | 723 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
749 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 724 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
750 ori_scan += 2; | 725 ori_scan += 2; |
751 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); | 726 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
752 dest_scan++; | 727 dest_scan++; |
753 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 728 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
754 dest_scan++; | 729 dest_scan++; |
755 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 730 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
756 dest_scan += 2; | 731 dest_scan += 2; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 uint8_t* clip_scan, | 922 uint8_t* clip_scan, |
948 uint8_t* dest_extra_alpha_scan) { | 923 uint8_t* dest_extra_alpha_scan) { |
949 dest_scan = | 924 dest_scan = |
950 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); | 925 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
951 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 926 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
952 int col_end = | 927 int col_end = |
953 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 928 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
954 if (col_end < col_start) | 929 if (col_end < col_start) |
955 return; // do nothing. | 930 return; // do nothing. |
956 dest_scan += (col_start << 1) + col_start; | 931 dest_scan += (col_start << 1) + col_start; |
957 int src_alpha; | 932 int src_alpha = m_Alpha * cover_scan / 255; |
958 #if 0 | |
959 if (m_bFullCover) | |
960 src_alpha = m_Alpha; | |
961 else | |
962 #endif | |
963 src_alpha = m_Alpha * cover_scan / 255; | |
964 if (src_alpha == 255) { | 933 if (src_alpha == 255) { |
965 for (int col = col_start; col < col_end; col++) { | 934 for (int col = col_start; col < col_end; col++) { |
966 *dest_scan++ = m_Blue; | 935 *dest_scan++ = m_Blue; |
967 *dest_scan++ = m_Green; | 936 *dest_scan++ = m_Green; |
968 *dest_scan++ = m_Red; | 937 *dest_scan++ = m_Red; |
969 } | 938 } |
970 return; | 939 return; |
971 } | 940 } |
972 for (int col = col_start; col < col_end; col++) { | 941 for (int col = col_start; col < col_end; col++) { |
973 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); | 942 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
(...skipping 30 matching lines...) Expand all Loading... | |
1004 ori_scan += (col_start << 1) + col_start; | 973 ori_scan += (col_start << 1) + col_start; |
1005 if (m_Alpha == 255 && cover_scan == 255) { | 974 if (m_Alpha == 255 && cover_scan == 255) { |
1006 for (int col = col_start; col < col_end; col++) { | 975 for (int col = col_start; col < col_end; col++) { |
1007 *dest_scan++ = m_Blue; | 976 *dest_scan++ = m_Blue; |
1008 *dest_scan++ = m_Green; | 977 *dest_scan++ = m_Green; |
1009 *dest_scan++ = m_Red; | 978 *dest_scan++ = m_Red; |
1010 } | 979 } |
1011 return; | 980 return; |
1012 } | 981 } |
1013 for (int col = col_start; col < col_end; col++) { | 982 for (int col = col_start; col < col_end; col++) { |
1014 #if 0 | |
1015 if (m_bFullCover) { | |
1016 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); | |
1017 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); | |
1018 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); | |
1019 continue; | |
1020 } | |
1021 #endif | |
1022 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); | 983 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); |
1023 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); | 984 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); |
1024 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); | 985 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); |
1025 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); | 986 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
1026 dest_scan++; | 987 dest_scan++; |
1027 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 988 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
1028 dest_scan++; | 989 dest_scan++; |
1029 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 990 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
1030 dest_scan++; | 991 dest_scan++; |
1031 } | 992 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 | 1484 |
1524 //-------------------------------------------------------------------- | 1485 //-------------------------------------------------------------------- |
1525 FX_BOOL CFX_SkiaRenderer::Init( | 1486 FX_BOOL CFX_SkiaRenderer::Init( |
1526 CFX_DIBitmap* pDevice, | 1487 CFX_DIBitmap* pDevice, |
1527 CFX_DIBitmap* pOriDevice, | 1488 CFX_DIBitmap* pOriDevice, |
1528 const CFX_ClipRgn* pClipRgn, | 1489 const CFX_ClipRgn* pClipRgn, |
1529 FX_DWORD color, | 1490 FX_DWORD color, |
1530 FX_BOOL bFullCover, | 1491 FX_BOOL bFullCover, |
1531 FX_BOOL bRgbByteOrder, | 1492 FX_BOOL bRgbByteOrder, |
1532 int alpha_flag, | 1493 int alpha_flag, |
1533 void* pIccTransform) // The alpha flag must be fill_flag if exist. | 1494 void* pIccTransform) { // The alpha flag must be fill_flag if exist. |
1534 { | |
1535 m_pDevice = pDevice; | 1495 m_pDevice = pDevice; |
1536 m_pClipRgn = pClipRgn; | 1496 m_pClipRgn = pClipRgn; |
1537 m_bRgbByteOrder = bRgbByteOrder; | 1497 m_bRgbByteOrder = bRgbByteOrder; |
1538 m_pOriDevice = pOriDevice; | 1498 m_pOriDevice = pOriDevice; |
1539 m_pDestScan = NULL; | 1499 m_pDestScan = NULL; |
1540 m_pDestExtraAlphaScan = NULL; | 1500 m_pDestExtraAlphaScan = NULL; |
1541 m_pOriScan = NULL; | 1501 m_pOriScan = NULL; |
1542 m_pClipScan = NULL; | 1502 m_pClipScan = NULL; |
1543 composite_span = NULL; | 1503 composite_span = NULL; |
1544 if (m_pClipRgn) | 1504 if (m_pClipRgn) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1596 m_Gray = FXRGB2GRAY(r, g, b); | 1556 m_Gray = FXRGB2GRAY(r, g, b); |
1597 } else { | 1557 } else { |
1598 m_Gray = | 1558 m_Gray = |
1599 FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); | 1559 FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); |
1600 } | 1560 } |
1601 } | 1561 } |
1602 } | 1562 } |
1603 } else { | 1563 } else { |
1604 if (bDeviceCMYK) { // Cmyk(a) Device | 1564 if (bDeviceCMYK) { // Cmyk(a) Device |
1605 ASSERT(!m_bRgbByteOrder); | 1565 ASSERT(!m_bRgbByteOrder); |
1606 // TODO... opt for cmyk | 1566 // TODO ... opt for cmyk |
1607 composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; | 1567 composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; |
1608 if (bObjectCMYK) { | 1568 if (bObjectCMYK) { |
1609 m_Color = FXCMYK_TODIB(color); | 1569 m_Color = FXCMYK_TODIB(color); |
1610 if (pIccTransform) | 1570 if (pIccTransform) |
1611 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, | 1571 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
1612 (const uint8_t*)&m_Color, 1); | 1572 (const uint8_t*)&m_Color, 1); |
1613 } else { // Object RGB | 1573 } else { // Object RGB |
1614 if (!pIccTransform) | 1574 if (!pIccTransform) |
1615 return FALSE; | 1575 return FALSE; |
1616 color = FXARGB_TODIB(color); | 1576 color = FXARGB_TODIB(color); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1722 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; | 1682 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; |
1723 } break; | 1683 } break; |
1724 case 1: | 1684 case 1: |
1725 case 5: | 1685 case 5: |
1726 case 8: | 1686 case 8: |
1727 case 9: | 1687 case 9: |
1728 case 11: | 1688 case 11: |
1729 case 12: | 1689 case 12: |
1730 case 13: | 1690 case 13: |
1731 case 15: | 1691 case 15: |
1732 // TODO... | 1692 // TODO ... |
1733 break; | 1693 break; |
1734 case 10: | 1694 case 10: |
1735 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; | 1695 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; |
1736 break; | 1696 break; |
1737 case 14: | 1697 case 14: |
1738 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; | 1698 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; |
1739 break; | 1699 break; |
1740 } | 1700 } |
1741 return !!composite_span; | 1701 return !!composite_span; |
1742 } | 1702 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1841 m_pDevice = pDevice; | 1801 m_pDevice = pDevice; |
1842 m_Left = Left; | 1802 m_Left = Left; |
1843 m_Top = Top; | 1803 m_Top = Top; |
1844 if (pDevice) { | 1804 if (pDevice) { |
1845 m_dstWidth = m_Left + pDevice->GetWidth(); | 1805 m_dstWidth = m_Left + pDevice->GetWidth(); |
1846 m_dstHeight = m_Top + pDevice->GetHeight(); | 1806 m_dstHeight = m_Top + pDevice->GetHeight(); |
1847 } | 1807 } |
1848 return TRUE; | 1808 return TRUE; |
1849 } | 1809 } |
1850 #endif | 1810 #endif |
OLD | NEW |