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 "render_int.h" | 7 #include "render_int.h" |
8 | 8 |
9 #include "core/include/fpdfapi/fpdf_pageobj.h" | 9 #include "core/include/fpdfapi/fpdf_pageobj.h" |
10 #include "core/include/fpdfapi/fpdf_render.h" | 10 #include "core/include/fpdfapi/fpdf_render.h" |
11 #include "core/include/fxge/fx_ge.h" | 11 #include "core/include/fxge/fx_ge.h" |
12 #include "core/src/fpdfapi/fpdf_page/pageint.h" | 12 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
13 | 13 |
14 #define SHADING_STEPS 256 | 14 #define SHADING_STEPS 256 |
15 static void DrawAxialShading(CFX_DIBitmap* pBitmap, | 15 static void DrawAxialShading(CFX_DIBitmap* pBitmap, |
16 CFX_Matrix* pObject2Bitmap, | 16 CFX_Matrix* pObject2Bitmap, |
17 CPDF_Dictionary* pDict, | 17 CPDF_Dictionary* pDict, |
18 CPDF_Function** pFuncs, | 18 CPDF_Function** pFuncs, |
19 int nFuncs, | 19 int nFuncs, |
20 CPDF_ColorSpace* pCS, | 20 CPDF_ColorSpace* pCS, |
21 int alpha) { | 21 int alpha) { |
22 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 22 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
23 CPDF_Array* pCoords = pDict->GetArray("Coords"); | 23 CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); |
24 if (!pCoords) { | 24 if (!pCoords) { |
25 return; | 25 return; |
26 } | 26 } |
27 FX_FLOAT start_x = pCoords->GetNumber(0); | 27 FX_FLOAT start_x = pCoords->GetNumberAt(0); |
28 FX_FLOAT start_y = pCoords->GetNumber(1); | 28 FX_FLOAT start_y = pCoords->GetNumberAt(1); |
29 FX_FLOAT end_x = pCoords->GetNumber(2); | 29 FX_FLOAT end_x = pCoords->GetNumberAt(2); |
30 FX_FLOAT end_y = pCoords->GetNumber(3); | 30 FX_FLOAT end_y = pCoords->GetNumberAt(3); |
31 FX_FLOAT t_min = 0, t_max = 1.0f; | 31 FX_FLOAT t_min = 0, t_max = 1.0f; |
32 CPDF_Array* pArray = pDict->GetArray("Domain"); | 32 CPDF_Array* pArray = pDict->GetArrayBy("Domain"); |
33 if (pArray) { | 33 if (pArray) { |
34 t_min = pArray->GetNumber(0); | 34 t_min = pArray->GetNumberAt(0); |
35 t_max = pArray->GetNumber(1); | 35 t_max = pArray->GetNumberAt(1); |
36 } | 36 } |
37 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 37 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; |
38 pArray = pDict->GetArray("Extend"); | 38 pArray = pDict->GetArrayBy("Extend"); |
39 if (pArray) { | 39 if (pArray) { |
40 bStartExtend = pArray->GetInteger(0); | 40 bStartExtend = pArray->GetIntegerAt(0); |
41 bEndExtend = pArray->GetInteger(1); | 41 bEndExtend = pArray->GetIntegerAt(1); |
42 } | 42 } |
43 int width = pBitmap->GetWidth(); | 43 int width = pBitmap->GetWidth(); |
44 int height = pBitmap->GetHeight(); | 44 int height = pBitmap->GetHeight(); |
45 FX_FLOAT x_span = end_x - start_x; | 45 FX_FLOAT x_span = end_x - start_x; |
46 FX_FLOAT y_span = end_y - start_y; | 46 FX_FLOAT y_span = end_y - start_y; |
47 FX_FLOAT axis_len_square = | 47 FX_FLOAT axis_len_square = |
48 FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_span); | 48 FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_span); |
49 CFX_Matrix matrix; | 49 CFX_Matrix matrix; |
50 matrix.SetReverse(*pObject2Bitmap); | 50 matrix.SetReverse(*pObject2Bitmap); |
51 int total_results = 0; | 51 int total_results = 0; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 } | 105 } |
106 static void DrawRadialShading(CFX_DIBitmap* pBitmap, | 106 static void DrawRadialShading(CFX_DIBitmap* pBitmap, |
107 CFX_Matrix* pObject2Bitmap, | 107 CFX_Matrix* pObject2Bitmap, |
108 CPDF_Dictionary* pDict, | 108 CPDF_Dictionary* pDict, |
109 CPDF_Function** pFuncs, | 109 CPDF_Function** pFuncs, |
110 int nFuncs, | 110 int nFuncs, |
111 CPDF_ColorSpace* pCS, | 111 CPDF_ColorSpace* pCS, |
112 int alpha) { | 112 int alpha) { |
113 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 113 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
114 CPDF_Array* pCoords = pDict->GetArray("Coords"); | 114 CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); |
115 if (!pCoords) { | 115 if (!pCoords) { |
116 return; | 116 return; |
117 } | 117 } |
118 FX_FLOAT start_x = pCoords->GetNumber(0); | 118 FX_FLOAT start_x = pCoords->GetNumberAt(0); |
119 FX_FLOAT start_y = pCoords->GetNumber(1); | 119 FX_FLOAT start_y = pCoords->GetNumberAt(1); |
120 FX_FLOAT start_r = pCoords->GetNumber(2); | 120 FX_FLOAT start_r = pCoords->GetNumberAt(2); |
121 FX_FLOAT end_x = pCoords->GetNumber(3); | 121 FX_FLOAT end_x = pCoords->GetNumberAt(3); |
122 FX_FLOAT end_y = pCoords->GetNumber(4); | 122 FX_FLOAT end_y = pCoords->GetNumberAt(4); |
123 FX_FLOAT end_r = pCoords->GetNumber(5); | 123 FX_FLOAT end_r = pCoords->GetNumberAt(5); |
124 CFX_Matrix matrix; | 124 CFX_Matrix matrix; |
125 matrix.SetReverse(*pObject2Bitmap); | 125 matrix.SetReverse(*pObject2Bitmap); |
126 FX_FLOAT t_min = 0, t_max = 1.0f; | 126 FX_FLOAT t_min = 0, t_max = 1.0f; |
127 CPDF_Array* pArray = pDict->GetArray("Domain"); | 127 CPDF_Array* pArray = pDict->GetArrayBy("Domain"); |
128 if (pArray) { | 128 if (pArray) { |
129 t_min = pArray->GetNumber(0); | 129 t_min = pArray->GetNumberAt(0); |
130 t_max = pArray->GetNumber(1); | 130 t_max = pArray->GetNumberAt(1); |
131 } | 131 } |
132 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 132 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; |
133 pArray = pDict->GetArray("Extend"); | 133 pArray = pDict->GetArrayBy("Extend"); |
134 if (pArray) { | 134 if (pArray) { |
135 bStartExtend = pArray->GetInteger(0); | 135 bStartExtend = pArray->GetIntegerAt(0); |
136 bEndExtend = pArray->GetInteger(1); | 136 bEndExtend = pArray->GetIntegerAt(1); |
137 } | 137 } |
138 int total_results = 0; | 138 int total_results = 0; |
139 for (int j = 0; j < nFuncs; j++) { | 139 for (int j = 0; j < nFuncs; j++) { |
140 if (pFuncs[j]) { | 140 if (pFuncs[j]) { |
141 total_results += pFuncs[j]->CountOutputs(); | 141 total_results += pFuncs[j]->CountOutputs(); |
142 } | 142 } |
143 } | 143 } |
144 if (pCS->CountComponents() > total_results) { | 144 if (pCS->CountComponents() > total_results) { |
145 total_results = pCS->CountComponents(); | 145 total_results = pCS->CountComponents(); |
146 } | 146 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 } | 243 } |
244 static void DrawFuncShading(CFX_DIBitmap* pBitmap, | 244 static void DrawFuncShading(CFX_DIBitmap* pBitmap, |
245 CFX_Matrix* pObject2Bitmap, | 245 CFX_Matrix* pObject2Bitmap, |
246 CPDF_Dictionary* pDict, | 246 CPDF_Dictionary* pDict, |
247 CPDF_Function** pFuncs, | 247 CPDF_Function** pFuncs, |
248 int nFuncs, | 248 int nFuncs, |
249 CPDF_ColorSpace* pCS, | 249 CPDF_ColorSpace* pCS, |
250 int alpha) { | 250 int alpha) { |
251 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 251 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
252 CPDF_Array* pDomain = pDict->GetArray("Domain"); | 252 CPDF_Array* pDomain = pDict->GetArrayBy("Domain"); |
253 FX_FLOAT xmin = 0, ymin = 0, xmax = 1.0f, ymax = 1.0f; | 253 FX_FLOAT xmin = 0, ymin = 0, xmax = 1.0f, ymax = 1.0f; |
254 if (pDomain) { | 254 if (pDomain) { |
255 xmin = pDomain->GetNumber(0); | 255 xmin = pDomain->GetNumberAt(0); |
256 xmax = pDomain->GetNumber(1); | 256 xmax = pDomain->GetNumberAt(1); |
257 ymin = pDomain->GetNumber(2); | 257 ymin = pDomain->GetNumberAt(2); |
258 ymax = pDomain->GetNumber(3); | 258 ymax = pDomain->GetNumberAt(3); |
259 } | 259 } |
260 CFX_Matrix mtDomain2Target = pDict->GetMatrix("Matrix"); | 260 CFX_Matrix mtDomain2Target = pDict->GetMatrixBy("Matrix"); |
261 CFX_Matrix matrix, reverse_matrix; | 261 CFX_Matrix matrix, reverse_matrix; |
262 matrix.SetReverse(*pObject2Bitmap); | 262 matrix.SetReverse(*pObject2Bitmap); |
263 reverse_matrix.SetReverse(mtDomain2Target); | 263 reverse_matrix.SetReverse(mtDomain2Target); |
264 matrix.Concat(reverse_matrix); | 264 matrix.Concat(reverse_matrix); |
265 int width = pBitmap->GetWidth(); | 265 int width = pBitmap->GetWidth(); |
266 int height = pBitmap->GetHeight(); | 266 int height = pBitmap->GetHeight(); |
267 int pitch = pBitmap->GetPitch(); | 267 int pitch = pBitmap->GetPitch(); |
268 int total_results = 0; | 268 int total_results = 0; |
269 for (int j = 0; j < nFuncs; j++) { | 269 for (int j = 0; j < nFuncs; j++) { |
270 if (pFuncs[j]) { | 270 if (pFuncs[j]) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 static void DrawLatticeGouraudShading(CFX_DIBitmap* pBitmap, | 447 static void DrawLatticeGouraudShading(CFX_DIBitmap* pBitmap, |
448 CFX_Matrix* pObject2Bitmap, | 448 CFX_Matrix* pObject2Bitmap, |
449 CPDF_Stream* pShadingStream, | 449 CPDF_Stream* pShadingStream, |
450 CPDF_Function** pFuncs, | 450 CPDF_Function** pFuncs, |
451 int nFuncs, | 451 int nFuncs, |
452 CPDF_ColorSpace* pCS, | 452 CPDF_ColorSpace* pCS, |
453 int alpha) { | 453 int alpha) { |
454 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 454 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
455 | 455 |
456 int row_verts = pShadingStream->GetDict()->GetInteger("VerticesPerRow"); | 456 int row_verts = pShadingStream->GetDict()->GetIntegerBy("VerticesPerRow"); |
457 if (row_verts < 2) | 457 if (row_verts < 2) |
458 return; | 458 return; |
459 | 459 |
460 CPDF_MeshStream stream; | 460 CPDF_MeshStream stream; |
461 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) | 461 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) |
462 return; | 462 return; |
463 | 463 |
464 CPDF_MeshVertex* vertex = FX_Alloc2D(CPDF_MeshVertex, row_verts, 2); | 464 CPDF_MeshVertex* vertex = FX_Alloc2D(CPDF_MeshVertex, row_verts, 2); |
465 if (!stream.GetVertexRow(vertex, row_verts, pObject2Bitmap)) { | 465 if (!stream.GetVertexRow(vertex, row_verts, pObject2Bitmap)) { |
466 FX_Free(vertex); | 466 FX_Free(vertex); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 int nFuncs = pPattern->m_nFuncs; | 834 int nFuncs = pPattern->m_nFuncs; |
835 CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); | 835 CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); |
836 CPDF_ColorSpace* pColorSpace = pPattern->m_pCS; | 836 CPDF_ColorSpace* pColorSpace = pPattern->m_pCS; |
837 if (!pColorSpace) { | 837 if (!pColorSpace) { |
838 return; | 838 return; |
839 } | 839 } |
840 FX_ARGB background = 0; | 840 FX_ARGB background = 0; |
841 if (!pPattern->m_bShadingObj && | 841 if (!pPattern->m_bShadingObj && |
842 pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) { | 842 pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) { |
843 CPDF_Array* pBackColor = | 843 CPDF_Array* pBackColor = |
844 pPattern->m_pShadingObj->GetDict()->GetArray("Background"); | 844 pPattern->m_pShadingObj->GetDict()->GetArrayBy("Background"); |
845 if (pBackColor && | 845 if (pBackColor && |
846 pBackColor->GetCount() >= (FX_DWORD)pColorSpace->CountComponents()) { | 846 pBackColor->GetCount() >= (FX_DWORD)pColorSpace->CountComponents()) { |
847 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); | 847 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); |
848 for (int i = 0; i < pColorSpace->CountComponents(); i++) { | 848 for (int i = 0; i < pColorSpace->CountComponents(); i++) { |
849 comps[i] = pBackColor->GetNumber(i); | 849 comps[i] = pBackColor->GetNumberAt(i); |
850 } | 850 } |
851 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 851 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
852 pColorSpace->GetRGB(comps, R, G, B); | 852 pColorSpace->GetRGB(comps, R, G, B); |
853 background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), | 853 background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), |
854 (int32_t)(B * 255)); | 854 (int32_t)(B * 255)); |
855 } | 855 } |
856 } | 856 } |
857 if (pDict->KeyExist("BBox")) { | 857 if (pDict->KeyExist("BBox")) { |
858 CFX_FloatRect rect = pDict->GetRect("BBox"); | 858 CFX_FloatRect rect = pDict->GetRectBy("BBox"); |
859 rect.Transform(pMatrix); | 859 rect.Transform(pMatrix); |
860 clip_rect.Intersect(rect.GetOutterRect()); | 860 clip_rect.Intersect(rect.GetOutterRect()); |
861 } | 861 } |
862 CPDF_DeviceBuffer buffer; | 862 CPDF_DeviceBuffer buffer; |
863 buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); | 863 buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); |
864 CFX_Matrix FinalMatrix = *pMatrix; | 864 CFX_Matrix FinalMatrix = *pMatrix; |
865 FinalMatrix.Concat(*buffer.GetMatrix()); | 865 FinalMatrix.Concat(*buffer.GetMatrix()); |
866 CFX_DIBitmap* pBitmap = buffer.GetBitmap(); | 866 CFX_DIBitmap* pBitmap = buffer.GetBitmap(); |
867 if (!pBitmap->GetBuffer()) { | 867 if (!pBitmap->GetBuffer()) { |
868 return; | 868 return; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 max_row = (int)FXSYS_floor( | 1056 max_row = (int)FXSYS_floor( |
1057 FXSYS_Div(clip_box_p.top - pPattern->m_BBox.bottom, pPattern->m_YStep)); | 1057 FXSYS_Div(clip_box_p.top - pPattern->m_BBox.bottom, pPattern->m_YStep)); |
1058 if (width > clip_box.Width() || height > clip_box.Height() || | 1058 if (width > clip_box.Width() || height > clip_box.Height() || |
1059 width * height > clip_box.Width() * clip_box.Height()) { | 1059 width * height > clip_box.Width() * clip_box.Height()) { |
1060 CPDF_GraphicStates* pStates = NULL; | 1060 CPDF_GraphicStates* pStates = NULL; |
1061 if (!pPattern->m_bColored) { | 1061 if (!pPattern->m_bColored) { |
1062 pStates = CloneObjStates(pPageObj, bStroke); | 1062 pStates = CloneObjStates(pPageObj, bStroke); |
1063 } | 1063 } |
1064 CPDF_Dictionary* pFormResource = NULL; | 1064 CPDF_Dictionary* pFormResource = NULL; |
1065 if (pPattern->m_pForm->m_pFormDict) { | 1065 if (pPattern->m_pForm->m_pFormDict) { |
1066 pFormResource = pPattern->m_pForm->m_pFormDict->GetDict("Resources"); | 1066 pFormResource = pPattern->m_pForm->m_pFormDict->GetDictBy("Resources"); |
1067 } | 1067 } |
1068 for (int col = min_col; col <= max_col; col++) | 1068 for (int col = min_col; col <= max_col; col++) |
1069 for (int row = min_row; row <= max_row; row++) { | 1069 for (int row = min_row; row <= max_row; row++) { |
1070 FX_FLOAT orig_x, orig_y; | 1070 FX_FLOAT orig_x, orig_y; |
1071 orig_x = col * pPattern->m_XStep; | 1071 orig_x = col * pPattern->m_XStep; |
1072 orig_y = row * pPattern->m_YStep; | 1072 orig_y = row * pPattern->m_YStep; |
1073 mtPattern2Device.Transform(orig_x, orig_y); | 1073 mtPattern2Device.Transform(orig_x, orig_y); |
1074 CFX_Matrix matrix = *pObj2Device; | 1074 CFX_Matrix matrix = *pObj2Device; |
1075 matrix.Translate(orig_x - mtPattern2Device.e, | 1075 matrix.Translate(orig_x - mtPattern2Device.e, |
1076 orig_y - mtPattern2Device.f); | 1076 orig_y - mtPattern2Device.f); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1207 } |
1208 } | 1208 } |
1209 if (bStroke) { | 1209 if (bStroke) { |
1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
1211 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1211 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
1213 bStroke = FALSE; | 1213 bStroke = FALSE; |
1214 } | 1214 } |
1215 } | 1215 } |
1216 } | 1216 } |
OLD | NEW |