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

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

Issue 1727793002: Remove FXSYS_Div. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 FX_FLOAT approximation_scale) 51 FX_FLOAT approximation_scale)
52 { 52 {
53 typedef typename VertexConsumer::value_type coord_type; 53 typedef typename VertexConsumer::value_type coord_type;
54 FX_FLOAT a1 = FXSYS_atan2(dy1, dx1); 54 FX_FLOAT a1 = FXSYS_atan2(dy1, dx1);
55 FX_FLOAT a2 = FXSYS_atan2(dy2, dx2); 55 FX_FLOAT a2 = FXSYS_atan2(dy2, dx2);
56 FX_FLOAT da = a1 - a2; 56 FX_FLOAT da = a1 - a2;
57 bool ccw = da > 0 && da < FX_PI; 57 bool ccw = da > 0 && da < FX_PI;
58 if(width < 0) { 58 if(width < 0) {
59 width = -width; 59 width = -width;
60 } 60 }
61 da = FXSYS_acos(FXSYS_Div(width, width + FXSYS_Div(1.0f / 8, approximation_s cale))) * 2; 61 da = FXSYS_acos(width / (width + ((1.0f / 8) / approximation_scale))) * 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 + (width * FXSYS_cos(a1)), 70 out_vertices.add(coord_type(x + (width * FXSYS_cos(a1)),
71 y + (width * FXSYS_sin(a1)))); 71 y + (width * FXSYS_sin(a1))));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = (v1.y - v0.y) / len;
156 FX_FLOAT dy1 = FXSYS_Div(v1.x - v0.x, len); 156 FX_FLOAT dy1 = (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 = dx1 * width; 159 dx1 = dx1 * width;
160 dy1 = 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 =
172 FXSYS_Div(1.0f / 8, approximation_sca le))) * 2; 172 FXSYS_acos(width / (width + ((1.0f / 8) / approximation_scale))) *
173 2;
173 out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1)); 174 out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1));
174 a1 += da; 175 a1 += da;
175 a2 -= da / 4; 176 a2 -= da / 4;
176 while(a1 < a2) { 177 while(a1 < a2) {
177 out_vertices.add(coord_type(v0.x + (width * FXSYS_cos(a1)), 178 out_vertices.add(coord_type(v0.x + (width * FXSYS_cos(a1)),
178 v0.y + (width * FXSYS_sin(a1)))); 179 v0.y + (width * FXSYS_sin(a1))));
179 a1 += da; 180 a1 += da;
180 } 181 }
181 out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); 182 out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1));
182 } 183 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 break; 264 break;
264 default: 265 default:
265 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); 266 out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
266 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); 267 out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2));
267 break; 268 break;
268 } 269 }
269 } 270 }
270 } 271 }
271 } 272 }
272 #endif 273 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698