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 26 matching lines...) Expand all Loading... |
37 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 37 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; |
38 pArray = pDict->GetArrayBy("Extend"); | 38 pArray = pDict->GetArrayBy("Extend"); |
39 if (pArray) { | 39 if (pArray) { |
40 bStartExtend = pArray->GetIntegerAt(0); | 40 bStartExtend = pArray->GetIntegerAt(0); |
41 bEndExtend = pArray->GetIntegerAt(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 = (x_span * x_span) + (y_span * y_span); |
48 FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_span); | |
49 CFX_Matrix matrix; | 48 CFX_Matrix matrix; |
50 matrix.SetReverse(*pObject2Bitmap); | 49 matrix.SetReverse(*pObject2Bitmap); |
51 int total_results = 0; | 50 int total_results = 0; |
52 for (int j = 0; j < nFuncs; j++) { | 51 for (int j = 0; j < nFuncs; j++) { |
53 if (pFuncs[j]) { | 52 if (pFuncs[j]) { |
54 total_results += pFuncs[j]->CountOutputs(); | 53 total_results += pFuncs[j]->CountOutputs(); |
55 } | 54 } |
56 } | 55 } |
57 if (pCS->CountComponents() > total_results) { | 56 if (pCS->CountComponents() > total_results) { |
58 total_results = pCS->CountComponents(); | 57 total_results = pCS->CountComponents(); |
(...skipping 19 matching lines...) Expand all Loading... |
78 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), | 77 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), |
79 FXSYS_round(G * 255), FXSYS_round(B * 255))); | 78 FXSYS_round(G * 255), FXSYS_round(B * 255))); |
80 } | 79 } |
81 int pitch = pBitmap->GetPitch(); | 80 int pitch = pBitmap->GetPitch(); |
82 for (int row = 0; row < height; row++) { | 81 for (int row = 0; row < height; row++) { |
83 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 82 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); |
84 for (int column = 0; column < width; column++) { | 83 for (int column = 0; column < width; column++) { |
85 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 84 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
86 matrix.Transform(x, y); | 85 matrix.Transform(x, y); |
87 FX_FLOAT scale = FXSYS_Div( | 86 FX_FLOAT scale = FXSYS_Div( |
88 FXSYS_Mul(x - start_x, x_span) + FXSYS_Mul(y - start_y, y_span), | 87 ((x - start_x) * x_span) + ((y - start_y) * y_span), axis_len_square); |
89 axis_len_square); | |
90 int index = (int32_t)(scale * (SHADING_STEPS - 1)); | 88 int index = (int32_t)(scale * (SHADING_STEPS - 1)); |
91 if (index < 0) { | 89 if (index < 0) { |
92 if (!bStartExtend) { | 90 if (!bStartExtend) { |
93 continue; | 91 continue; |
94 } | 92 } |
95 index = 0; | 93 index = 0; |
96 } else if (index >= SHADING_STEPS) { | 94 } else if (index >= SHADING_STEPS) { |
97 if (!bEndExtend) { | 95 if (!bEndExtend) { |
98 continue; | 96 continue; |
99 } | 97 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 offset += nresults; | 156 offset += nresults; |
159 } | 157 } |
160 } | 158 } |
161 } | 159 } |
162 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 160 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
163 pCS->GetRGB(pResults, R, G, B); | 161 pCS->GetRGB(pResults, R, G, B); |
164 rgb_array[i] = | 162 rgb_array[i] = |
165 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), | 163 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), |
166 FXSYS_round(G * 255), FXSYS_round(B * 255))); | 164 FXSYS_round(G * 255), FXSYS_round(B * 255))); |
167 } | 165 } |
168 FX_FLOAT a = FXSYS_Mul(start_x - end_x, start_x - end_x) + | 166 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + |
169 FXSYS_Mul(start_y - end_y, start_y - end_y) - | 167 ((start_y - end_y) * (start_y - end_y)) - |
170 FXSYS_Mul(start_r - end_r, start_r - end_r); | 168 ((start_r - end_r) * (start_r - end_r)); |
171 int width = pBitmap->GetWidth(); | 169 int width = pBitmap->GetWidth(); |
172 int height = pBitmap->GetHeight(); | 170 int height = pBitmap->GetHeight(); |
173 int pitch = pBitmap->GetPitch(); | 171 int pitch = pBitmap->GetPitch(); |
174 FX_BOOL bDecreasing = FALSE; | 172 FX_BOOL bDecreasing = FALSE; |
175 if (start_r > end_r) { | 173 if (start_r > end_r) { |
176 int length = (int)FXSYS_sqrt((FXSYS_Mul(start_x - end_x, start_x - end_x) + | 174 int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) + |
177 FXSYS_Mul(start_y - end_y, start_y - end_y))); | 175 ((start_y - end_y) * (start_y - end_y)))); |
178 if (length < start_r - end_r) { | 176 if (length < start_r - end_r) { |
179 bDecreasing = TRUE; | 177 bDecreasing = TRUE; |
180 } | 178 } |
181 } | 179 } |
182 for (int row = 0; row < height; row++) { | 180 for (int row = 0; row < height; row++) { |
183 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 181 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); |
184 for (int column = 0; column < width; column++) { | 182 for (int column = 0; column < width; column++) { |
185 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 183 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
186 matrix.Transform(x, y); | 184 matrix.Transform(x, y); |
187 FX_FLOAT b = -2 * (FXSYS_Mul(x - start_x, end_x - start_x) + | 185 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + |
188 FXSYS_Mul(y - start_y, end_y - start_y) + | 186 ((y - start_y) * (end_y - start_y)) + |
189 FXSYS_Mul(start_r, end_r - start_r)); | 187 (start_r * (end_r - start_r))); |
190 FX_FLOAT c = FXSYS_Mul(x - start_x, x - start_x) + | 188 FX_FLOAT c = ((x - start_x) * (x - start_x)) + |
191 FXSYS_Mul(y - start_y, y - start_y) - | 189 ((y - start_y) * (y - start_y)) - (start_r * start_r); |
192 FXSYS_Mul(start_r, start_r); | |
193 FX_FLOAT s; | 190 FX_FLOAT s; |
194 if (a == 0) { | 191 if (a == 0) { |
195 s = FXSYS_Div(-c, b); | 192 s = FXSYS_Div(-c, b); |
196 } else { | 193 } else { |
197 FX_FLOAT b2_4ac = FXSYS_Mul(b, b) - 4 * FXSYS_Mul(a, c); | 194 FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); |
198 if (b2_4ac < 0) { | 195 if (b2_4ac < 0) { |
199 continue; | 196 continue; |
200 } | 197 } |
201 FX_FLOAT root = FXSYS_sqrt(b2_4ac); | 198 FX_FLOAT root = FXSYS_sqrt(b2_4ac); |
202 FX_FLOAT s1, s2; | 199 FX_FLOAT s1, s2; |
203 if (a > 0) { | 200 if (a > 0) { |
204 s1 = FXSYS_Div(-b - root, 2 * a); | 201 s1 = FXSYS_Div(-b - root, 2 * a); |
205 s2 = FXSYS_Div(-b + root, 2 * a); | 202 s2 = FXSYS_Div(-b + root, 2 * a); |
206 } else { | 203 } else { |
207 s2 = FXSYS_Div(-b - root, 2 * a); | 204 s2 = FXSYS_Div(-b - root, 2 * a); |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1204 } |
1208 } | 1205 } |
1209 if (bStroke) { | 1206 if (bStroke) { |
1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1207 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
1211 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1208 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1209 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
1213 bStroke = FALSE; | 1210 bStroke = FALSE; |
1214 } | 1211 } |
1215 } | 1212 } |
1216 } | 1213 } |
OLD | NEW |