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

Side by Side Diff: xfa/src/fxgraphics/src/fx_path_generator.cpp

Issue 1729613003: Remove FXSYS_Mul. (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 // 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 "xfa/src/fxgraphics/src/fx_path_generator.h" 7 #include "xfa/src/fxgraphics/src/fx_path_generator.h"
8 #include "xfa/src/fxgraphics/src/pre.h" 8 #include "xfa/src/fxgraphics/src/pre.h"
9 CFX_PathGenerator::CFX_PathGenerator() { 9 CFX_PathGenerator::CFX_PathGenerator() {
10 m_pPathData = NULL; 10 m_pPathData = NULL;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 void CFX_PathGenerator::ArcTo(FX_FLOAT x, 114 void CFX_PathGenerator::ArcTo(FX_FLOAT x,
115 FX_FLOAT y, 115 FX_FLOAT y,
116 FX_FLOAT width, 116 FX_FLOAT width,
117 FX_FLOAT height, 117 FX_FLOAT height,
118 FX_FLOAT start_angle, 118 FX_FLOAT start_angle,
119 FX_FLOAT sweep_angle) { 119 FX_FLOAT sweep_angle) {
120 FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2); 120 FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
121 FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2); 121 FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
122 FX_FLOAT tx = FXSYS_Div((1.0f - x0) * 4, 3 * 1.0f); 122 FX_FLOAT tx = FXSYS_Div((1.0f - x0) * 4, 3 * 1.0f);
123 FX_FLOAT ty = y0 - FXSYS_Div(FXSYS_Mul(tx, x0), y0); 123 FX_FLOAT ty = y0 - FXSYS_Div(tx * x0, y0);
124 FX_FLOAT px[3], py[3]; 124 FX_FLOAT px[3], py[3];
125 px[0] = x0 + tx; 125 px[0] = x0 + tx;
126 py[0] = -ty; 126 py[0] = -ty;
127 px[1] = x0 + tx; 127 px[1] = x0 + tx;
128 py[1] = ty; 128 py[1] = ty;
129 FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2); 129 FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
130 FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2); 130 FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
131 int old_count = m_pPathData->GetPointCount(); 131 int old_count = m_pPathData->GetPointCount();
132 m_pPathData->AddPointCount(3); 132 m_pPathData->AddPointCount(3);
133 FX_FLOAT bezier_x, bezier_y; 133 FX_FLOAT bezier_x, bezier_y;
134 bezier_x = x + FXSYS_Mul(width, FXSYS_Mul(px[0], cs) - FXSYS_Mul(py[0], sn)); 134 bezier_x = x + (width * ((px[0] * cs) - (py[0] * sn)));
135 bezier_y = y + FXSYS_Mul(height, FXSYS_Mul(px[0], sn) + FXSYS_Mul(py[0], cs)); 135 bezier_y = y + (height * ((px[0] * sn) + (py[0] * cs)));
136 m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO); 136 m_pPathData->SetPoint(old_count, bezier_x, bezier_y, FXPT_BEZIERTO);
137 bezier_x = x + FXSYS_Mul(width, FXSYS_Mul(px[1], cs) - FXSYS_Mul(py[1], sn)); 137 bezier_x = x + (width * ((px[1] * cs) - (py[1] * sn)));
138 bezier_y = y + FXSYS_Mul(height, FXSYS_Mul(px[1], sn) + FXSYS_Mul(py[1], cs)); 138 bezier_y = y + (height * ((px[1] * sn) + (py[1] * cs)));
139 m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO); 139 m_pPathData->SetPoint(old_count + 1, bezier_x, bezier_y, FXPT_BEZIERTO);
140 bezier_x = x + FXSYS_Mul(width, FXSYS_cos(start_angle + sweep_angle)), 140 bezier_x = x + (width * FXSYS_cos(start_angle + sweep_angle));
141 bezier_y = y + FXSYS_Mul(height, FXSYS_sin(start_angle + sweep_angle)); 141 bezier_y = y + (height * FXSYS_sin(start_angle + sweep_angle));
142 m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO); 142 m_pPathData->SetPoint(old_count + 2, bezier_x, bezier_y, FXPT_BEZIERTO);
143 } 143 }
144 void CFX_PathGenerator::AddArc(FX_FLOAT x, 144 void CFX_PathGenerator::AddArc(FX_FLOAT x,
145 FX_FLOAT y, 145 FX_FLOAT y,
146 FX_FLOAT width, 146 FX_FLOAT width,
147 FX_FLOAT height, 147 FX_FLOAT height,
148 FX_FLOAT start_angle, 148 FX_FLOAT start_angle,
149 FX_FLOAT sweep_angle) { 149 FX_FLOAT sweep_angle) {
150 #if 0 150 #if 0
151 FX_FIXFLOAT32 sweep = sweep_angle; 151 FX_FIXFLOAT32 sweep = sweep_angle;
(...skipping 30 matching lines...) Expand all
182 start_angle += FX_PI * 2; 182 start_angle += FX_PI * 2;
183 } 183 }
184 if (sweep_angle >= FX_PI * 2) { 184 if (sweep_angle >= FX_PI * 2) {
185 sweep_angle = FX_PI * 2; 185 sweep_angle = FX_PI * 2;
186 } 186 }
187 if (sweep_angle <= -FX_PI * 2) { 187 if (sweep_angle <= -FX_PI * 2) {
188 sweep_angle = -FX_PI * 2; 188 sweep_angle = -FX_PI * 2;
189 } 189 }
190 m_pPathData->AddPointCount(1); 190 m_pPathData->AddPointCount(1);
191 m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, 191 m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1,
192 x + FXSYS_Mul(width, FXSYS_cos(start_angle)), 192 x + (width * FXSYS_cos(start_angle)),
193 y + FXSYS_Mul(height, FXSYS_sin(start_angle)), 193 y + (height * FXSYS_sin(start_angle)), FXPT_MOVETO);
194 FXPT_MOVETO);
195 FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0; 194 FX_FLOAT total_sweep = 0, local_sweep = 0, prev_sweep = 0;
196 FX_BOOL done = FALSE; 195 FX_BOOL done = FALSE;
197 do { 196 do {
198 if (sweep_angle < 0) { 197 if (sweep_angle < 0) {
199 prev_sweep = total_sweep; 198 prev_sweep = total_sweep;
200 local_sweep = -FX_PI / 2; 199 local_sweep = -FX_PI / 2;
201 total_sweep -= FX_PI / 2; 200 total_sweep -= FX_PI / 2;
202 if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { 201 if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) {
203 local_sweep = sweep_angle - prev_sweep; 202 local_sweep = sweep_angle - prev_sweep;
204 done = TRUE; 203 done = TRUE;
(...skipping 15 matching lines...) Expand all
220 void CFX_PathGenerator::AddPie(FX_FLOAT x, 219 void CFX_PathGenerator::AddPie(FX_FLOAT x,
221 FX_FLOAT y, 220 FX_FLOAT y,
222 FX_FLOAT width, 221 FX_FLOAT width,
223 FX_FLOAT height, 222 FX_FLOAT height,
224 FX_FLOAT start_angle, 223 FX_FLOAT start_angle,
225 FX_FLOAT sweep_angle) { 224 FX_FLOAT sweep_angle) {
226 if (sweep_angle == 0) { 225 if (sweep_angle == 0) {
227 int old_count = m_pPathData->GetPointCount(); 226 int old_count = m_pPathData->GetPointCount();
228 m_pPathData->AddPointCount(2); 227 m_pPathData->AddPointCount(2);
229 m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO); 228 m_pPathData->SetPoint(old_count, x, y, FXPT_MOVETO);
230 m_pPathData->SetPoint( 229 m_pPathData->SetPoint(old_count + 1, x + (width * FXSYS_cos(start_angle)),
231 old_count + 1, x + FXSYS_Mul(width, FXSYS_cos(start_angle)), 230 y + (height * FXSYS_sin(start_angle)), FXPT_LINETO);
232 y + FXSYS_Mul(height, FXSYS_sin(start_angle)), FXPT_LINETO);
233 return; 231 return;
234 } 232 }
235 AddArc(x, y, width, height, start_angle, sweep_angle); 233 AddArc(x, y, width, height, start_angle, sweep_angle);
236 m_pPathData->AddPointCount(1); 234 m_pPathData->AddPointCount(1);
237 m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y, 235 m_pPathData->SetPoint(m_pPathData->GetPointCount() - 1, x, y,
238 FXPT_LINETO | FXPT_CLOSEFIGURE); 236 FXPT_LINETO | FXPT_CLOSEFIGURE);
239 } 237 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698