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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" | 9 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" |
10 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 bStartExtend = pArray->GetIntegerAt(0); | 51 bStartExtend = pArray->GetIntegerAt(0); |
52 bEndExtend = pArray->GetIntegerAt(1); | 52 bEndExtend = pArray->GetIntegerAt(1); |
53 } | 53 } |
54 int width = pBitmap->GetWidth(); | 54 int width = pBitmap->GetWidth(); |
55 int height = pBitmap->GetHeight(); | 55 int height = pBitmap->GetHeight(); |
56 FX_FLOAT x_span = end_x - start_x; | 56 FX_FLOAT x_span = end_x - start_x; |
57 FX_FLOAT y_span = end_y - start_y; | 57 FX_FLOAT y_span = end_y - start_y; |
58 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); | 58 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); |
59 CFX_Matrix matrix; | 59 CFX_Matrix matrix; |
60 matrix.SetReverse(*pObject2Bitmap); | 60 matrix.SetReverse(*pObject2Bitmap); |
61 int total_results = 0; | 61 uint32_t total_results = 0; |
62 for (int j = 0; j < nFuncs; j++) { | 62 for (int j = 0; j < nFuncs; j++) { |
63 if (pFuncs[j]) { | 63 if (pFuncs[j]) |
64 total_results += pFuncs[j]->CountOutputs(); | 64 total_results += pFuncs[j]->CountOutputs(); |
65 } | |
66 } | 65 } |
67 if (pCS->CountComponents() > total_results) { | 66 if (pCS->CountComponents() > total_results) |
68 total_results = pCS->CountComponents(); | 67 total_results = pCS->CountComponents(); |
69 } | |
70 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 68 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
71 FX_FLOAT* pResults = result_array; | 69 FX_FLOAT* pResults = result_array; |
72 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); | 70 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); |
73 uint32_t rgb_array[SHADING_STEPS]; | 71 uint32_t rgb_array[SHADING_STEPS]; |
74 for (int i = 0; i < SHADING_STEPS; i++) { | 72 for (int i = 0; i < SHADING_STEPS; i++) { |
75 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; | 73 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; |
76 int offset = 0; | 74 int offset = 0; |
77 for (int j = 0; j < nFuncs; j++) { | 75 for (int j = 0; j < nFuncs; j++) { |
78 if (pFuncs[j]) { | 76 if (pFuncs[j]) { |
79 int nresults = 0; | 77 int nresults = 0; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (pArray) { | 135 if (pArray) { |
138 t_min = pArray->GetNumberAt(0); | 136 t_min = pArray->GetNumberAt(0); |
139 t_max = pArray->GetNumberAt(1); | 137 t_max = pArray->GetNumberAt(1); |
140 } | 138 } |
141 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 139 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; |
142 pArray = pDict->GetArrayBy("Extend"); | 140 pArray = pDict->GetArrayBy("Extend"); |
143 if (pArray) { | 141 if (pArray) { |
144 bStartExtend = pArray->GetIntegerAt(0); | 142 bStartExtend = pArray->GetIntegerAt(0); |
145 bEndExtend = pArray->GetIntegerAt(1); | 143 bEndExtend = pArray->GetIntegerAt(1); |
146 } | 144 } |
147 int total_results = 0; | 145 uint32_t total_results = 0; |
148 for (int j = 0; j < nFuncs; j++) { | 146 for (int j = 0; j < nFuncs; j++) { |
149 if (pFuncs[j]) { | 147 if (pFuncs[j]) { |
150 total_results += pFuncs[j]->CountOutputs(); | 148 total_results += pFuncs[j]->CountOutputs(); |
151 } | 149 } |
152 } | 150 } |
153 if (pCS->CountComponents() > total_results) { | 151 if (pCS->CountComponents() > total_results) { |
154 total_results = pCS->CountComponents(); | 152 total_results = pCS->CountComponents(); |
155 } | 153 } |
156 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 154 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
157 FX_FLOAT* pResults = result_array; | 155 FX_FLOAT* pResults = result_array; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 ymax = pDomain->GetNumberAt(3); | 264 ymax = pDomain->GetNumberAt(3); |
267 } | 265 } |
268 CFX_Matrix mtDomain2Target = pDict->GetMatrixBy("Matrix"); | 266 CFX_Matrix mtDomain2Target = pDict->GetMatrixBy("Matrix"); |
269 CFX_Matrix matrix, reverse_matrix; | 267 CFX_Matrix matrix, reverse_matrix; |
270 matrix.SetReverse(*pObject2Bitmap); | 268 matrix.SetReverse(*pObject2Bitmap); |
271 reverse_matrix.SetReverse(mtDomain2Target); | 269 reverse_matrix.SetReverse(mtDomain2Target); |
272 matrix.Concat(reverse_matrix); | 270 matrix.Concat(reverse_matrix); |
273 int width = pBitmap->GetWidth(); | 271 int width = pBitmap->GetWidth(); |
274 int height = pBitmap->GetHeight(); | 272 int height = pBitmap->GetHeight(); |
275 int pitch = pBitmap->GetPitch(); | 273 int pitch = pBitmap->GetPitch(); |
276 int total_results = 0; | 274 uint32_t total_results = 0; |
277 for (int j = 0; j < nFuncs; j++) { | 275 for (int j = 0; j < nFuncs; j++) { |
278 if (pFuncs[j]) { | 276 if (pFuncs[j]) |
279 total_results += pFuncs[j]->CountOutputs(); | 277 total_results += pFuncs[j]->CountOutputs(); |
280 } | |
281 } | 278 } |
282 if (pCS->CountComponents() > total_results) { | 279 if (pCS->CountComponents() > total_results) |
283 total_results = pCS->CountComponents(); | 280 total_results = pCS->CountComponents(); |
284 } | |
285 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 281 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
286 FX_FLOAT* pResults = result_array; | 282 FX_FLOAT* pResults = result_array; |
287 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); | 283 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); |
288 for (int row = 0; row < height; row++) { | 284 for (int row = 0; row < height; row++) { |
289 uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); | 285 uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); |
290 for (int column = 0; column < width; column++) { | 286 for (int column = 0; column < width; column++) { |
291 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 287 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
292 matrix.Transform(x, y); | 288 matrix.Transform(x, y); |
293 if (x < xmin || x > xmax || y < ymin || y > ymax) { | 289 if (x < xmin || x > xmax || y < ymin || y > ymax) { |
294 continue; | 290 continue; |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 return; | 834 return; |
839 } | 835 } |
840 FX_ARGB background = 0; | 836 FX_ARGB background = 0; |
841 if (!pPattern->m_bShadingObj && | 837 if (!pPattern->m_bShadingObj && |
842 pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) { | 838 pPattern->m_pShadingObj->GetDict()->KeyExist("Background")) { |
843 CPDF_Array* pBackColor = | 839 CPDF_Array* pBackColor = |
844 pPattern->m_pShadingObj->GetDict()->GetArrayBy("Background"); | 840 pPattern->m_pShadingObj->GetDict()->GetArrayBy("Background"); |
845 if (pBackColor && | 841 if (pBackColor && |
846 pBackColor->GetCount() >= pColorSpace->CountComponents()) { | 842 pBackColor->GetCount() >= pColorSpace->CountComponents()) { |
847 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); | 843 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); |
848 for (int i = 0; i < pColorSpace->CountComponents(); i++) { | 844 for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++) |
849 comps[i] = pBackColor->GetNumberAt(i); | 845 comps[i] = pBackColor->GetNumberAt(i); |
850 } | |
851 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 846 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
852 pColorSpace->GetRGB(comps, R, G, B); | 847 pColorSpace->GetRGB(comps, R, G, B); |
853 background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), | 848 background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), |
854 (int32_t)(B * 255)); | 849 (int32_t)(B * 255)); |
855 } | 850 } |
856 } | 851 } |
857 if (pDict->KeyExist("BBox")) { | 852 if (pDict->KeyExist("BBox")) { |
858 CFX_FloatRect rect = pDict->GetRectBy("BBox"); | 853 CFX_FloatRect rect = pDict->GetRectBy("BBox"); |
859 rect.Transform(pMatrix); | 854 rect.Transform(pMatrix); |
860 clip_rect.Intersect(rect.GetOutterRect()); | 855 clip_rect.Intersect(rect.GetOutterRect()); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } | 1207 } |
1213 } | 1208 } |
1214 if (bStroke) { | 1209 if (bStroke) { |
1215 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
1216 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1211 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
1217 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
1218 bStroke = FALSE; | 1213 bStroke = FALSE; |
1219 } | 1214 } |
1220 } | 1215 } |
1221 } | 1216 } |
OLD | NEW |