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

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

Issue 1729613003: Remove FXSYS_Mul. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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
« no previous file with comments | « third_party/agg23/agg_math.h ('k') | xfa/src/fxgraphics/src/fx_graphics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 da = FXSYS_acos(FXSYS_Div(width, width + FXSYS_Div(1.0f / 8, approximation_s cale))) * 2; 61 da = FXSYS_acos(FXSYS_Div(width, width + FXSYS_Div(1.0f / 8, approximation_s cale))) * 2;
62 out_vertices.add(coord_type(x + dx1, y + dy1)); 62 out_vertices.add(coord_type(x + dx1, y + dy1));
63 if(!ccw) { 63 if(!ccw) {
64 if(a1 > a2) { 64 if(a1 > a2) {
65 a2 += 2 * FX_PI; 65 a2 += 2 * FX_PI;
66 } 66 }
67 a2 -= da / 4; 67 a2 -= da / 4;
68 a1 += da; 68 a1 += da;
69 while(a1 < a2) { 69 while(a1 < a2) {
70 out_vertices.add(coord_type(x + FXSYS_Mul(width, FXSYS_cos(a1)), 70 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)),
71 y + FXSYS_Mul(width, FXSYS_sin(a1)))); 71 y + (width * FXSYS_sin(a1))));
72 a1 += da; 72 a1 += da;
73 } 73 }
74 } else { 74 } else {
75 if(a1 < a2) { 75 if(a1 < a2) {
76 a2 -= 2 * FX_PI; 76 a2 -= 2 * FX_PI;
77 } 77 }
78 a2 += da / 4; 78 a2 += da / 4;
79 a1 -= da; 79 a1 -= da;
80 while(a1 > a2) { 80 while(a1 > a2) {
81 out_vertices.add(coord_type(x + FXSYS_Mul(width, FXSYS_cos(a1)), 81 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)),
82 y + FXSYS_Mul(width, FXSYS_sin(a1)))); 82 y + (width * FXSYS_sin(a1))));
83 a1 -= da; 83 a1 -= da;
84 } 84 }
85 } 85 }
86 out_vertices.add(coord_type(x + dx2, y + dy2)); 86 out_vertices.add(coord_type(x + dx2, y + dy2));
87 } 87 }
88 template<class VertexConsumer> 88 template<class VertexConsumer>
89 void stroke_calc_miter(VertexConsumer& out_vertices, 89 void stroke_calc_miter(VertexConsumer& out_vertices,
90 const vertex_dist& v0, 90 const vertex_dist& v0,
91 const vertex_dist& v1, 91 const vertex_dist& v1,
92 const vertex_dist& v2, 92 const vertex_dist& v2,
93 FX_FLOAT dx1, FX_FLOAT dy1, 93 FX_FLOAT dx1, FX_FLOAT dy1,
94 FX_FLOAT dx2, FX_FLOAT dy2, 94 FX_FLOAT dx2, FX_FLOAT dy2,
95 FX_FLOAT width, 95 FX_FLOAT width,
96 line_join_e line_join, 96 line_join_e line_join,
97 FX_FLOAT miter_limit, 97 FX_FLOAT miter_limit,
98 FX_FLOAT approximation_scale) 98 FX_FLOAT approximation_scale)
99 { 99 {
100 typedef typename VertexConsumer::value_type coord_type; 100 typedef typename VertexConsumer::value_type coord_type;
101 FX_FLOAT xi = v1.x; 101 FX_FLOAT xi = v1.x;
102 FX_FLOAT yi = v1.y; 102 FX_FLOAT yi = v1.y;
103 bool miter_limit_exceeded = true; 103 bool miter_limit_exceeded = true;
104 if(calc_intersection(v0.x + dx1, v0.y - dy1, 104 if(calc_intersection(v0.x + dx1, v0.y - dy1,
105 v1.x + dx1, v1.y - dy1, 105 v1.x + dx1, v1.y - dy1,
106 v1.x + dx2, v1.y - dy2, 106 v1.x + dx2, v1.y - dy2,
107 v2.x + dx2, v2.y - dy2, 107 v2.x + dx2, v2.y - dy2,
108 &xi, &yi)) { 108 &xi, &yi)) {
109 FX_FLOAT d1 = calc_distance(v1.x, v1.y, xi, yi); 109 FX_FLOAT d1 = calc_distance(v1.x, v1.y, xi, yi);
110 FX_FLOAT lim = FXSYS_Mul(width, miter_limit); 110 FX_FLOAT lim = width * miter_limit;
111 if(d1 <= lim) { 111 if(d1 <= lim) {
112 out_vertices.add(coord_type(xi, yi)); 112 out_vertices.add(coord_type(xi, yi));
113 miter_limit_exceeded = false; 113 miter_limit_exceeded = false;
114 } 114 }
115 } else { 115 } else {
116 FX_FLOAT x2 = v1.x + dx1; 116 FX_FLOAT x2 = v1.x + dx1;
117 FX_FLOAT y2 = v1.y - dy1; 117 FX_FLOAT y2 = v1.y - dy1;
118 if((FXSYS_Mul(x2 - v0.x, dy1) - FXSYS_Mul(v0.y - y2, dx1) < 0) != 118 if ((((x2 - v0.x) * dy1) - ((v0.y - y2) * dx1) < 0) !=
119 (FXSYS_Mul(x2 - v2.x, dy1) - FXSYS_Mul(v2.y - y2, dx1) < 0)) { 119 (((x2 - v2.x) * dy1) - ((v2.y - y2) * dx1) < 0)) {
120 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); 120 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
121 miter_limit_exceeded = false; 121 miter_limit_exceeded = false;
122 } 122 }
123 } 123 }
124 if(miter_limit_exceeded) { 124 if(miter_limit_exceeded) {
125 switch(line_join) { 125 switch(line_join) {
126 case miter_join_revert: 126 case miter_join_revert:
127 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); 127 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
128 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); 128 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2));
129 break; 129 break;
130 case miter_join_round: 130 case miter_join_round:
131 stroke_calc_arc(out_vertices, 131 stroke_calc_arc(out_vertices,
132 v1.x, v1.y, dx1, -dy1, dx2, -dy2, 132 v1.x, v1.y, dx1, -dy1, dx2, -dy2,
133 width, approximation_scale); 133 width, approximation_scale);
134 break; 134 break;
135 default: 135 default:
136 out_vertices.add(coord_type(v1.x + dx1 + FXSYS_Mul(dy1, miter_li mit), 136 out_vertices.add(coord_type(v1.x + dx1 + (dy1 * miter_limit),
137 v1.y - dy1 + FXSYS_Mul(dx1, miter_li mit))); 137 v1.y - dy1 + (dx1 * miter_limit)));
138 out_vertices.add(coord_type(v1.x + dx2 - FXSYS_Mul(dy2, miter_li mit), 138 out_vertices.add(coord_type(v1.x + dx2 - (dy2 * miter_limit),
139 v1.y - dy2 - FXSYS_Mul(dx2, miter_li mit))); 139 v1.y - dy2 - (dx2 * miter_limit)));
140 break; 140 break;
141 } 141 }
142 } 142 }
143 } 143 }
144 template<class VertexConsumer> 144 template<class VertexConsumer>
145 void stroke_calc_cap(VertexConsumer& out_vertices, 145 void stroke_calc_cap(VertexConsumer& out_vertices,
146 const vertex_dist& v0, 146 const vertex_dist& v0,
147 const vertex_dist& v1, 147 const vertex_dist& v1,
148 FX_FLOAT len, 148 FX_FLOAT len,
149 line_cap_e line_cap, 149 line_cap_e line_cap,
150 FX_FLOAT width, 150 FX_FLOAT width,
151 FX_FLOAT approximation_scale) 151 FX_FLOAT approximation_scale)
152 { 152 {
153 typedef typename VertexConsumer::value_type coord_type; 153 typedef typename VertexConsumer::value_type coord_type;
154 out_vertices.remove_all(); 154 out_vertices.remove_all();
155 FX_FLOAT dx1 = FXSYS_Div(v1.y - v0.y, len); 155 FX_FLOAT dx1 = FXSYS_Div(v1.y - v0.y, len);
156 FX_FLOAT dy1 = FXSYS_Div(v1.x - v0.x, len); 156 FX_FLOAT dy1 = FXSYS_Div(v1.x - v0.x, len);
157 FX_FLOAT dx2 = 0; 157 FX_FLOAT dx2 = 0;
158 FX_FLOAT dy2 = 0; 158 FX_FLOAT dy2 = 0;
159 dx1 = FXSYS_Mul(dx1, width); 159 dx1 = dx1 * width;
160 dy1 = FXSYS_Mul(dy1, width); 160 dy1 = dy1 * width;
161 if(line_cap != round_cap) { 161 if(line_cap != round_cap) {
162 if(line_cap == square_cap) { 162 if(line_cap == square_cap) {
163 dx2 = dy1; 163 dx2 = dy1;
164 dy2 = dx1; 164 dy2 = dx1;
165 } 165 }
166 out_vertices.add(coord_type(v0.x - dx1 - dx2, v0.y + dy1 - dy2)); 166 out_vertices.add(coord_type(v0.x - dx1 - dx2, v0.y + dy1 - dy2));
167 out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2)); 167 out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2));
168 } else { 168 } else {
169 FX_FLOAT a1 = FXSYS_atan2(dy1, -dx1); 169 FX_FLOAT a1 = FXSYS_atan2(dy1, -dx1);
170 FX_FLOAT a2 = a1 + FX_PI; 170 FX_FLOAT a2 = a1 + FX_PI;
171 FX_FLOAT da = FXSYS_acos(FXSYS_Div(width, width + 171 FX_FLOAT da = FXSYS_acos(FXSYS_Div(width, width +
172 FXSYS_Div(1.0f / 8, approximation_sca le))) * 2; 172 FXSYS_Div(1.0f / 8, approximation_sca le))) * 2;
173 out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1)); 173 out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1));
174 a1 += da; 174 a1 += da;
175 a2 -= da / 4; 175 a2 -= da / 4;
176 while(a1 < a2) { 176 while(a1 < a2) {
177 out_vertices.add(coord_type(v0.x + FXSYS_Mul(width, FXSYS_cos(a1)), 177 out_vertices.add(coord_type(v0.x + (width * FXSYS_cos(a1)),
178 v0.y + FXSYS_Mul(width, FXSYS_sin(a1)))) ; 178 v0.y + (width * FXSYS_sin(a1))));
179 a1 += da; 179 a1 += da;
180 } 180 }
181 out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); 181 out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1));
182 } 182 }
183 } 183 }
184 template<class VertexConsumer> 184 template<class VertexConsumer>
185 void stroke_calc_join(VertexConsumer& out_vertices, 185 void stroke_calc_join(VertexConsumer& out_vertices,
186 const vertex_dist& v0, 186 const vertex_dist& v0,
187 const vertex_dist& v1, 187 const vertex_dist& v1,
188 const vertex_dist& v2, 188 const vertex_dist& v2,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 break; 263 break;
264 default: 264 default:
265 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); 265 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
266 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); 266 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2));
267 break; 267 break;
268 } 268 }
269 } 269 }
270 } 270 }
271 } 271 }
272 #endif 272 #endif
OLDNEW
« no previous file with comments | « third_party/agg23/agg_math.h ('k') | xfa/src/fxgraphics/src/fx_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698