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/include/fxcrt/fx_system.h" | 7 #include "core/include/fxcrt/fx_system.h" |
8 #include "core/include/fxge/fx_ge.h" | 8 #include "core/include/fxge/fx_ge.h" |
9 #include "third_party/base/numerics/safe_math.h" | 9 #include "third_party/base/numerics/safe_math.h" |
10 | 10 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 FX_BOOL bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20; | 256 FX_BOOL bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20; |
257 FX_BOOL bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20; | 257 FX_BOOL bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20; |
258 if (bStartVert && bEndVert) { | 258 if (bStartVert && bEndVert) { |
259 int start_dir = middle_y > start_y ? 1 : -1; | 259 int start_dir = middle_y > start_y ? 1 : -1; |
260 FX_FLOAT point_y = middle_y + half_width * start_dir; | 260 FX_FLOAT point_y = middle_y + half_width * start_dir; |
261 rect.UpdateRect(middle_x + half_width, point_y); | 261 rect.UpdateRect(middle_x + half_width, point_y); |
262 rect.UpdateRect(middle_x - half_width, point_y); | 262 rect.UpdateRect(middle_x - half_width, point_y); |
263 return; | 263 return; |
264 } | 264 } |
265 if (!bStartVert) { | 265 if (!bStartVert) { |
266 start_k = FXSYS_Div(middle_y - start_y, middle_x - start_x); | 266 start_k = (middle_y - start_y) / (middle_x - start_x); |
267 start_c = middle_y - (start_k * middle_x); | 267 start_c = middle_y - (start_k * middle_x); |
268 start_len = FXSYS_sqrt2(start_x - middle_x, start_y - middle_y); | 268 start_len = FXSYS_sqrt2(start_x - middle_x, start_y - middle_y); |
269 start_dc = (FX_FLOAT)FXSYS_fabs( | 269 start_dc = (FX_FLOAT)FXSYS_fabs( |
270 FXSYS_MulDiv(half_width, start_len, start_x - middle_x)); | 270 FXSYS_MulDiv(half_width, start_len, start_x - middle_x)); |
271 } | 271 } |
272 if (!bEndVert) { | 272 if (!bEndVert) { |
273 end_k = FXSYS_Div(end_y - middle_y, end_x - middle_x); | 273 end_k = (end_y - middle_y) / (end_x - middle_x); |
274 end_c = middle_y - (end_k * middle_x); | 274 end_c = middle_y - (end_k * middle_x); |
275 end_len = FXSYS_sqrt2(end_x - middle_x, end_y - middle_y); | 275 end_len = FXSYS_sqrt2(end_x - middle_x, end_y - middle_y); |
276 end_dc = (FX_FLOAT)FXSYS_fabs( | 276 end_dc = (FX_FLOAT)FXSYS_fabs( |
277 FXSYS_MulDiv(half_width, end_len, end_x - middle_x)); | 277 FXSYS_MulDiv(half_width, end_len, end_x - middle_x)); |
278 } | 278 } |
279 if (bStartVert) { | 279 if (bStartVert) { |
280 FX_FLOAT outside_x = start_x; | 280 FX_FLOAT outside_x = start_x; |
281 if (end_x < start_x) { | 281 if (end_x < start_x) { |
282 outside_x += half_width; | 282 outside_x += half_width; |
283 } else { | 283 } else { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 start_outside_c += start_dc; | 324 start_outside_c += start_dc; |
325 } else { | 325 } else { |
326 start_outside_c -= start_dc; | 326 start_outside_c -= start_dc; |
327 } | 327 } |
328 FX_FLOAT end_outside_c = end_c; | 328 FX_FLOAT end_outside_c = end_c; |
329 if (start_y < (end_k * start_x) + end_c) { | 329 if (start_y < (end_k * start_x) + end_c) { |
330 end_outside_c += end_dc; | 330 end_outside_c += end_dc; |
331 } else { | 331 } else { |
332 end_outside_c -= end_dc; | 332 end_outside_c -= end_dc; |
333 } | 333 } |
334 FX_FLOAT join_x = FXSYS_Div(end_outside_c - start_outside_c, start_k - end_k); | 334 FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); |
335 FX_FLOAT join_y = (start_k * join_x) + start_outside_c; | 335 FX_FLOAT join_y = (start_k * join_x) + start_outside_c; |
336 rect.UpdateRect(join_x, join_y); | 336 rect.UpdateRect(join_x, join_y); |
337 } | 337 } |
338 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, | 338 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, |
339 FX_FLOAT miter_limit) const { | 339 FX_FLOAT miter_limit) const { |
340 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, | 340 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, |
341 -100000 * 1.0f); | 341 -100000 * 1.0f); |
342 int iPoint = 0; | 342 int iPoint = 0; |
343 FX_FLOAT half_width = line_width; | 343 FX_FLOAT half_width = line_width; |
344 int iStartPoint, iEndPoint, iMiddlePoint; | 344 int iStartPoint, iEndPoint, iMiddlePoint; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 648 } |
649 void CFX_GraphStateData::SetDashCount(int count) { | 649 void CFX_GraphStateData::SetDashCount(int count) { |
650 FX_Free(m_DashArray); | 650 FX_Free(m_DashArray); |
651 m_DashArray = NULL; | 651 m_DashArray = NULL; |
652 m_DashCount = count; | 652 m_DashCount = count; |
653 if (count == 0) { | 653 if (count == 0) { |
654 return; | 654 return; |
655 } | 655 } |
656 m_DashArray = FX_Alloc(FX_FLOAT, count); | 656 m_DashArray = FX_Alloc(FX_FLOAT, count); |
657 } | 657 } |
OLD | NEW |