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 "../../../include/fpdfapi/fpdf_render.h" | 7 #include "../../../include/fpdfapi/fpdf_render.h" |
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 left *= 2; | 655 left *= 2; |
656 bottom *= 2; | 656 bottom *= 2; |
657 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi
rst_half(), m2f); | 657 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi
rst_half(), m2f); |
658 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D
1.second_half(), m2s); | 658 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D
1.second_half(), m2s); |
659 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s,
m2f, D2.first_half()); | 659 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s,
m2f, D2.first_half()); |
660 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half
(), m2s, D2.second_half()); | 660 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half
(), m2s, D2.second_half()); |
661 } | 661 } |
662 } | 662 } |
663 } | 663 } |
664 }; | 664 }; |
| 665 |
| 666 FX_BOOL _CheckCoonTensorPara(const CPDF_MeshStream &stream) |
| 667 { |
| 668 FX_BOOL bCoorBits = ( stream.m_nCoordBits== 1 || |
| 669 stream.m_nCoordBits == 2 || |
| 670 stream.m_nCoordBits == 4 || |
| 671 stream.m_nCoordBits == 8 || |
| 672 stream.m_nCoordBits == 12 || |
| 673 stream.m_nCoordBits == 16 || |
| 674 stream.m_nCoordBits == 24 || |
| 675 stream.m_nCoordBits == 32 ); |
| 676 |
| 677 FX_BOOL bCompBits = ( stream.m_nCompBits == 1 || |
| 678 stream.m_nCompBits == 2 || |
| 679 stream.m_nCompBits == 4 || |
| 680 stream.m_nCompBits == 8 || |
| 681 stream.m_nCompBits == 12 || |
| 682 stream.m_nCompBits == 16 ); |
| 683 |
| 684 FX_BOOL bFlagBits = ( stream.m_nFlagBits == 2 || |
| 685 stream.m_nFlagBits == 4 || |
| 686 stream.m_nFlagBits == 8 ); |
| 687 |
| 688 return bCoorBits && bCompBits && bFlagBits; |
| 689 } |
| 690 |
665 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, CFX_DIBitmap* pBitmap, CFX_Aff
ineMatrix* pObject2Bitmap, | 691 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, CFX_DIBitmap* pBitmap, CFX_Aff
ineMatrix* pObject2Bitmap, |
666 CPDF_Stream* pShadingStream, CPDF_Function** pF
uncs, int nFuncs, | 692 CPDF_Stream* pShadingStream, CPDF_Function** pF
uncs, int nFuncs, |
667 CPDF_ColorSpace* pCS, int fill_mode, int alpha) | 693 CPDF_ColorSpace* pCS, int fill_mode, int alpha) |
668 { | 694 { |
669 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 695 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
670 if (pShadingStream->GetType() != PDFOBJ_STREAM) { | 696 if (pShadingStream->GetType() != PDFOBJ_STREAM) { |
671 return; | 697 return; |
672 } | 698 } |
673 CFX_FxgeDevice device; | 699 CFX_FxgeDevice device; |
674 device.Attach(pBitmap); | 700 device.Attach(pBitmap); |
675 CPDF_MeshStream stream; | 701 CPDF_MeshStream stream; |
676 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { | 702 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { |
677 return; | 703 return; |
678 } | 704 } |
| 705 |
| 706 if (!_CheckCoonTensorPara(stream)) { |
| 707 return; |
| 708 } |
| 709 |
679 CPDF_PatchDrawer patch; | 710 CPDF_PatchDrawer patch; |
680 patch.alpha = alpha; | 711 patch.alpha = alpha; |
681 patch.pDevice = &device; | 712 patch.pDevice = &device; |
682 patch.fill_mode = fill_mode; | 713 patch.fill_mode = fill_mode; |
683 patch.path.SetPointCount(13); | 714 patch.path.SetPointCount(13); |
684 FX_PATHPOINT* pPoints = patch.path.GetPoints(); | 715 FX_PATHPOINT* pPoints = patch.path.GetPoints(); |
685 pPoints[0].m_Flag = FXPT_MOVETO; | 716 pPoints[0].m_Flag = FXPT_MOVETO; |
686 for (int i = 1; i < 13; i ++) { | 717 for (int i = 1; i < 13; i ++) { |
687 pPoints[i].m_Flag = FXPT_BEZIERTO; | 718 pPoints[i].m_Flag = FXPT_BEZIERTO; |
688 } | 719 } |
689 CFX_FloatPoint coords[16]; | 720 CFX_FloatPoint coords[16]; |
690 for (int i = 0; i < 16; i ++) | 721 for (int i = 0; i < 16; i ++) { |
691 { | |
692 coords[i].Set(0.0f, 0.0f); | 722 coords[i].Set(0.0f, 0.0f); |
693 } | 723 } |
694 | 724 |
695 int point_count = bTensor ? 16 : 12; | 725 int point_count = bTensor ? 16 : 12; |
696 while (!stream.m_BitStream.IsEOF()) { | 726 while (!stream.m_BitStream.IsEOF()) { |
697 FX_DWORD flag = stream.GetFlag(); | 727 FX_DWORD flag = stream.GetFlag(); |
698 int iStartPoint = 0, iStartColor = 0, i; | 728 int iStartPoint = 0, iStartColor = 0, i = 0; |
699 if (flag) { | 729 if (flag) { |
700 iStartPoint = 4; | 730 iStartPoint = 4; |
701 iStartColor = 2; | 731 iStartColor = 2; |
702 CFX_FloatPoint tempCoords[4]; | 732 CFX_FloatPoint tempCoords[4]; |
703 for (int i = 0; i < 4; i ++) { | 733 for (i = 0; i < 4; i ++) { |
704 tempCoords[i] = coords[(flag * 3 + i) % 12]; | 734 tempCoords[i] = coords[(flag * 3 + i) % 12]; |
705 } | 735 } |
706 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4); | 736 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4); |
707 Coon_Color tempColors[2]; | 737 Coon_Color tempColors[2]; |
708 tempColors[0] = patch.patch_colors[flag]; | 738 tempColors[0] = patch.patch_colors[flag]; |
709 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; | 739 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; |
710 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) *
2); | 740 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) *
2); |
711 } | 741 } |
712 for (i = iStartPoint; i < point_count; i ++) { | 742 for (i = iStartPoint; i < point_count; i ++) { |
713 stream.GetCoords(coords[i].x, coords[i].y); | 743 stream.GetCoords(coords[i].x, coords[i].y); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 bStroke = FALSE; | 1116 bStroke = FALSE; |
1087 bPattern = TRUE; | 1117 bPattern = TRUE; |
1088 } | 1118 } |
1089 } | 1119 } |
1090 #ifdef _FPDFAPI_MINI_ | 1120 #ifdef _FPDFAPI_MINI_ |
1091 if (bPattern && m_DitherBits) { | 1121 if (bPattern && m_DitherBits) { |
1092 DitherObjectArea(pPathObj, pObj2Device); | 1122 DitherObjectArea(pPathObj, pObj2Device); |
1093 } | 1123 } |
1094 #endif | 1124 #endif |
1095 } | 1125 } |
OLD | NEW |