Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: third_party/agg23/agg_math.h

Issue 1726893002: Remove FXSYS_MulDiv(a, b, c). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 //---------------------------------------------------------------------------- 2 //----------------------------------------------------------------------------
3 // Anti-Grain Geometry - Version 2.3 3 // Anti-Grain Geometry - Version 2.3
4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) 4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // 5 //
6 // Permission to copy, use, modify, sell and distribute this software 6 // Permission to copy, use, modify, sell and distribute this software
7 // is granted provided this copyright notice appears in all copies. 7 // is granted provided this copyright notice appears in all copies.
8 // This software is provided "as is" without express or implied 8 // This software is provided "as is" without express or implied
9 // warranty, and with no claim as to its suitability for any purpose. 9 // warranty, and with no claim as to its suitability for any purpose.
10 // 10 //
(...skipping 26 matching lines...) Expand all
37 AGG_INLINE FX_FLOAT calc_line_point_distance(FX_FLOAT x1, FX_FLOAT y1, 37 AGG_INLINE FX_FLOAT calc_line_point_distance(FX_FLOAT x1, FX_FLOAT y1,
38 FX_FLOAT x2, FX_FLOAT y2, 38 FX_FLOAT x2, FX_FLOAT y2,
39 FX_FLOAT x, FX_FLOAT y) 39 FX_FLOAT x, FX_FLOAT y)
40 { 40 {
41 FX_FLOAT dx = x2 - x1; 41 FX_FLOAT dx = x2 - x1;
42 FX_FLOAT dy = y2 - y1; 42 FX_FLOAT dy = y2 - y1;
43 FX_FLOAT d = FXSYS_sqrt2(dx, dy); 43 FX_FLOAT d = FXSYS_sqrt2(dx, dy);
44 if(d < intersection_epsilon) { 44 if(d < intersection_epsilon) {
45 return calc_distance(x1, y1, x, y); 45 return calc_distance(x1, y1, x, y);
46 } 46 }
47 return FXSYS_MulDiv(x - x2, dy, d) - FXSYS_MulDiv(y - y2, dx, d); 47 return ((x - x2) * dy / d) - ((y - y2) * dx / d);
48 } 48 }
49 AGG_INLINE bool calc_intersection(FX_FLOAT ax, FX_FLOAT ay, FX_FLOAT bx, FX_FLOA T by, 49 AGG_INLINE bool calc_intersection(FX_FLOAT ax, FX_FLOAT ay, FX_FLOAT bx, FX_FLOA T by,
50 FX_FLOAT cx, FX_FLOAT cy, FX_FLOAT dx, FX_FLOA T dy, 50 FX_FLOAT cx, FX_FLOAT cy, FX_FLOAT dx, FX_FLOA T dy,
51 FX_FLOAT* x, FX_FLOAT* y) 51 FX_FLOAT* x, FX_FLOAT* y)
52 { 52 {
53 FX_FLOAT num = ((ay - cy) * (dx - cx)) - ((ax - cx) * (dy - cy)); 53 FX_FLOAT num = ((ay - cy) * (dx - cx)) - ((ax - cx) * (dy - cy));
54 FX_FLOAT den = ((bx - ax) * (dy - cy)) - ((by - ay) * (dx - cx)); 54 FX_FLOAT den = ((bx - ax) * (dy - cy)) - ((by - ay) * (dx - cx));
55 if (FXSYS_fabs(den) < intersection_epsilon) { 55 if (FXSYS_fabs(den) < intersection_epsilon) {
56 return false; 56 return false;
57 } 57 }
58 *x = ax + FXSYS_MulDiv(bx - ax, num, den); 58 *x = ax + ((bx - ax) * num / den);
59 *y = ay + FXSYS_MulDiv(by - ay, num, den); 59 *y = ay + ((by - ay) * num / den);
60 return true; 60 return true;
61 } 61 }
62 } 62 }
63 #endif 63 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698