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/src/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/src/fpdfapi/fpdf_render/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" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 rgb_array[i] = | 76 rgb_array[i] = |
77 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), | 77 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), |
78 FXSYS_round(G * 255), FXSYS_round(B * 255))); | 78 FXSYS_round(G * 255), FXSYS_round(B * 255))); |
79 } | 79 } |
80 int pitch = pBitmap->GetPitch(); | 80 int pitch = pBitmap->GetPitch(); |
81 for (int row = 0; row < height; row++) { | 81 for (int row = 0; row < height; row++) { |
82 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 82 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); |
83 for (int column = 0; column < width; column++) { | 83 for (int column = 0; column < width; column++) { |
84 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 84 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
85 matrix.Transform(x, y); | 85 matrix.Transform(x, y); |
86 FX_FLOAT scale = FXSYS_Div( | 86 FX_FLOAT scale = (((x - start_x) * x_span) + ((y - start_y) * y_span)) / |
87 ((x - start_x) * x_span) + ((y - start_y) * y_span), axis_len_square); | 87 axis_len_square; |
88 int index = (int32_t)(scale * (SHADING_STEPS - 1)); | 88 int index = (int32_t)(scale * (SHADING_STEPS - 1)); |
89 if (index < 0) { | 89 if (index < 0) { |
90 if (!bStartExtend) { | 90 if (!bStartExtend) { |
91 continue; | 91 continue; |
92 } | 92 } |
93 index = 0; | 93 index = 0; |
94 } else if (index >= SHADING_STEPS) { | 94 } else if (index >= SHADING_STEPS) { |
95 if (!bEndExtend) { | 95 if (!bEndExtend) { |
96 continue; | 96 continue; |
97 } | 97 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 for (int column = 0; column < width; column++) { | 182 for (int column = 0; column < width; column++) { |
183 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 183 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
184 matrix.Transform(x, y); | 184 matrix.Transform(x, y); |
185 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + | 185 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + |
186 ((y - start_y) * (end_y - start_y)) + | 186 ((y - start_y) * (end_y - start_y)) + |
187 (start_r * (end_r - start_r))); | 187 (start_r * (end_r - start_r))); |
188 FX_FLOAT c = ((x - start_x) * (x - start_x)) + | 188 FX_FLOAT c = ((x - start_x) * (x - start_x)) + |
189 ((y - start_y) * (y - start_y)) - (start_r * start_r); | 189 ((y - start_y) * (y - start_y)) - (start_r * start_r); |
190 FX_FLOAT s; | 190 FX_FLOAT s; |
191 if (a == 0) { | 191 if (a == 0) { |
192 s = FXSYS_Div(-c, b); | 192 s = -c / b; |
193 } else { | 193 } else { |
194 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); | 194 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); |
195 if (b2_4ac < 0) { | 195 if (b2_4ac < 0) { |
196 continue; | 196 continue; |
197 } | 197 } |
198 FX_FLOAT root = FXSYS_sqrt(b2_4ac); | 198 FX_FLOAT root = FXSYS_sqrt(b2_4ac); |
199 FX_FLOAT s1, s2; | 199 FX_FLOAT s1, s2; |
200 if (a > 0) { | 200 if (a > 0) { |
201 s1 = FXSYS_Div(-b - root, 2 * a); | 201 s1 = (-b - root) / (2 * a); |
202 s2 = FXSYS_Div(-b + root, 2 * a); | 202 s2 = (-b + root) / (2 * a); |
203 } else { | 203 } else { |
204 s2 = FXSYS_Div(-b - root, 2 * a); | 204 s2 = (-b - root) / (2 * a); |
205 s1 = FXSYS_Div(-b + root, 2 * a); | 205 s1 = (-b + root) / (2 * a); |
206 } | 206 } |
207 if (bDecreasing) { | 207 if (bDecreasing) { |
208 if (s1 >= 0 || bStartExtend) { | 208 if (s1 >= 0 || bStartExtend) { |
209 s = s1; | 209 s = s1; |
210 } else { | 210 } else { |
211 s = s2; | 211 s = s2; |
212 } | 212 } |
213 } else { | 213 } else { |
214 if (s2 <= 1.0f || bEndExtend) { | 214 if (s2 <= 1.0f || bEndExtend) { |
215 s = s2; | 215 s = s2; |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 width = 1; | 1037 width = 1; |
1038 } | 1038 } |
1039 if (height == 0) { | 1039 if (height == 0) { |
1040 height = 1; | 1040 height = 1; |
1041 } | 1041 } |
1042 int min_col, max_col, min_row, max_row; | 1042 int min_col, max_col, min_row, max_row; |
1043 CFX_Matrix mtDevice2Pattern; | 1043 CFX_Matrix mtDevice2Pattern; |
1044 mtDevice2Pattern.SetReverse(mtPattern2Device); | 1044 mtDevice2Pattern.SetReverse(mtPattern2Device); |
1045 CFX_FloatRect clip_box_p(clip_box); | 1045 CFX_FloatRect clip_box_p(clip_box); |
1046 clip_box_p.Transform(&mtDevice2Pattern); | 1046 clip_box_p.Transform(&mtDevice2Pattern); |
1047 min_col = (int)FXSYS_ceil( | 1047 |
1048 FXSYS_Div(clip_box_p.left - pPattern->m_BBox.right, pPattern->m_XStep)); | 1048 min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->m_BBox.right) / |
1049 max_col = (int)FXSYS_floor( | 1049 pPattern->m_XStep); |
1050 FXSYS_Div(clip_box_p.right - pPattern->m_BBox.left, pPattern->m_XStep)); | 1050 max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->m_BBox.left) / |
1051 min_row = (int)FXSYS_ceil( | 1051 pPattern->m_XStep); |
1052 FXSYS_Div(clip_box_p.bottom - pPattern->m_BBox.top, pPattern->m_YStep)); | 1052 min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->m_BBox.top) / |
1053 max_row = (int)FXSYS_floor( | 1053 pPattern->m_YStep); |
1054 FXSYS_Div(clip_box_p.top - pPattern->m_BBox.bottom, pPattern->m_YStep)); | 1054 max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->m_BBox.bottom) / |
| 1055 pPattern->m_YStep); |
| 1056 |
1055 if (width > clip_box.Width() || height > clip_box.Height() || | 1057 if (width > clip_box.Width() || height > clip_box.Height() || |
1056 width * height > clip_box.Width() * clip_box.Height()) { | 1058 width * height > clip_box.Width() * clip_box.Height()) { |
1057 CPDF_GraphicStates* pStates = NULL; | 1059 CPDF_GraphicStates* pStates = NULL; |
1058 if (!pPattern->m_bColored) { | 1060 if (!pPattern->m_bColored) { |
1059 pStates = CloneObjStates(pPageObj, bStroke); | 1061 pStates = CloneObjStates(pPageObj, bStroke); |
1060 } | 1062 } |
1061 CPDF_Dictionary* pFormResource = NULL; | 1063 CPDF_Dictionary* pFormResource = NULL; |
1062 if (pPattern->m_pForm->m_pFormDict) { | 1064 if (pPattern->m_pForm->m_pFormDict) { |
1063 pFormResource = pPattern->m_pForm->m_pFormDict->GetDictBy("Resources"); | 1065 pFormResource = pPattern->m_pForm->m_pFormDict->GetDictBy("Resources"); |
1064 } | 1066 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 } | 1206 } |
1205 } | 1207 } |
1206 if (bStroke) { | 1208 if (bStroke) { |
1207 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1209 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
1208 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1210 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
1209 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1211 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
1210 bStroke = FALSE; | 1212 bStroke = FALSE; |
1211 } | 1213 } |
1212 } | 1214 } |
1213 } | 1215 } |
OLD | NEW |