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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = (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 = |
270 FXSYS_MulDiv(half_width, start_len, start_x - middle_x)); | 270 (FX_FLOAT)FXSYS_fabs(half_width * start_len / (start_x - middle_x)); |
271 } | 271 } |
272 if (!bEndVert) { | 272 if (!bEndVert) { |
273 end_k = (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(half_width * end_len / (end_x - middle_x)); |
277 FXSYS_MulDiv(half_width, end_len, end_x - middle_x)); | |
278 } | 277 } |
279 if (bStartVert) { | 278 if (bStartVert) { |
280 FX_FLOAT outside_x = start_x; | 279 FX_FLOAT outside_x = start_x; |
281 if (end_x < start_x) { | 280 if (end_x < start_x) { |
282 outside_x += half_width; | 281 outside_x += half_width; |
283 } else { | 282 } else { |
284 outside_x -= half_width; | 283 outside_x -= half_width; |
285 } | 284 } |
286 FX_FLOAT outside_y; | 285 FX_FLOAT outside_y; |
287 if (start_y < (end_k * start_x) + end_c) { | 286 if (start_y < (end_k * start_x) + end_c) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 647 } |
649 void CFX_GraphStateData::SetDashCount(int count) { | 648 void CFX_GraphStateData::SetDashCount(int count) { |
650 FX_Free(m_DashArray); | 649 FX_Free(m_DashArray); |
651 m_DashArray = NULL; | 650 m_DashArray = NULL; |
652 m_DashCount = count; | 651 m_DashCount = count; |
653 if (count == 0) { | 652 if (count == 0) { |
654 return; | 653 return; |
655 } | 654 } |
656 m_DashArray = FX_Alloc(FX_FLOAT, count); | 655 m_DashArray = FX_Alloc(FX_FLOAT, count); |
657 } | 656 } |
OLD | NEW |