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

Side by Side Diff: core/src/fxcrt/fx_basic_coords.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « core/src/fxcrt/fx_basic_buffer.cpp ('k') | core/src/fxcrt/fx_basic_gcc.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 // 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 <limits.h> 7 #include <limits.h>
8 8
9 #include "../../include/fxcrt/fx_coordinates.h" 9 #include "../../include/fxcrt/fx_coordinates.h"
10 #include "../../include/fxcrt/fx_ext.h" 10 #include "../../include/fxcrt/fx_ext.h"
(...skipping 27 matching lines...) Expand all
38 void FX_RECT::Union(const FX_RECT& other_rect) 38 void FX_RECT::Union(const FX_RECT& other_rect)
39 { 39 {
40 Normalize(); 40 Normalize();
41 FX_RECT other = other_rect; 41 FX_RECT other = other_rect;
42 other.Normalize(); 42 other.Normalize();
43 left = left < other.left ? left : other.left; 43 left = left < other.left ? left : other.left;
44 right = right > other.right ? right : other.right; 44 right = right > other.right ? right : other.right;
45 bottom = bottom > other.bottom ? bottom : other.bottom; 45 bottom = bottom > other.bottom ? bottom : other.bottom;
46 top = top < other.top ? top : other.top; 46 top = top < other.top ? top : other.top;
47 } 47 }
48 FX_BOOL GetIntersection(FX_FLOAT low1, FX_FLOAT high1, FX_FLOAT low2, FX_FLOAT h igh2, 48 bool GetIntersection(FX_FLOAT low1, FX_FLOAT high1, FX_FLOAT low2, FX_FLOAT high 2,
49 FX_FLOAT& interlow, FX_FLOAT& interhigh) 49 FX_FLOAT& interlow, FX_FLOAT& interhigh)
50 { 50 {
51 if (low1 >= high2 || low2 >= high1) { 51 if (low1 >= high2 || low2 >= high1) {
52 return FALSE; 52 return false;
53 } 53 }
54 interlow = low1 > low2 ? low1 : low2; 54 interlow = low1 > low2 ? low1 : low2;
55 interhigh = high1 > high2 ? high2 : high1; 55 interhigh = high1 > high2 ? high2 : high1;
56 return TRUE; 56 return true;
57 } 57 }
58 extern "C" int FXSYS_round(FX_FLOAT d) 58 extern "C" int FXSYS_round(FX_FLOAT d)
59 { 59 {
60 if (d < (FX_FLOAT)INT_MIN) { 60 if (d < (FX_FLOAT)INT_MIN) {
61 return INT_MIN; 61 return INT_MIN;
62 } 62 }
63 if (d > (FX_FLOAT)INT_MAX) { 63 if (d > (FX_FLOAT)INT_MAX) {
64 return INT_MAX; 64 return INT_MAX;
65 } 65 }
66 66
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 FX_RECT CFX_FloatRect::GetClosestRect() const 192 FX_RECT CFX_FloatRect::GetClosestRect() const
193 { 193 {
194 CFX_FloatRect rect1 = *this; 194 CFX_FloatRect rect1 = *this;
195 FX_RECT rect; 195 FX_RECT rect;
196 _MatchFloatRange(rect1.left, rect1.right, rect.left, rect.right); 196 _MatchFloatRange(rect1.left, rect1.right, rect.left, rect.right);
197 _MatchFloatRange(rect1.bottom, rect1.top, rect.top, rect.bottom); 197 _MatchFloatRange(rect1.bottom, rect1.top, rect.top, rect.bottom);
198 rect.Normalize(); 198 rect.Normalize();
199 return rect; 199 return rect;
200 } 200 }
201 FX_BOOL CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const 201 bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const
202 { 202 {
203 CFX_FloatRect n1 = *this; 203 CFX_FloatRect n1 = *this;
204 n1.Normalize(); 204 n1.Normalize();
205 CFX_FloatRect n2 = other_rect; 205 CFX_FloatRect n2 = other_rect;
206 n2.Normalize(); 206 n2.Normalize();
207 if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom && n2.top <= n1.top) { 207 if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom && n2.top <= n1.top) {
208 return TRUE; 208 return true;
209 } 209 }
210 return FALSE; 210 return false;
211 } 211 }
212 FX_BOOL CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const 212 bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const
213 { 213 {
214 CFX_FloatRect n1 = *this; 214 CFX_FloatRect n1 = *this;
215 n1.Normalize(); 215 n1.Normalize();
216 return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom; 216 return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom;
217 } 217 }
218 void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) 218 void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y)
219 { 219 {
220 if (left > x) { 220 if (left > x) {
221 left = x; 221 left = x;
222 } 222 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 static void FXCRT_Matrix_Concat(CFX_Matrix &m, const CFX_Matrix &m1, const CFX_M atrix &m2) 292 static void FXCRT_Matrix_Concat(CFX_Matrix &m, const CFX_Matrix &m1, const CFX_M atrix &m2)
293 { 293 {
294 FX_FLOAT aa = m1.a * m2.a + m1.b * m2.c; 294 FX_FLOAT aa = m1.a * m2.a + m1.b * m2.c;
295 FX_FLOAT bb = m1.a * m2.b + m1.b * m2.d; 295 FX_FLOAT bb = m1.a * m2.b + m1.b * m2.d;
296 FX_FLOAT cc = m1.c * m2.a + m1.d * m2.c; 296 FX_FLOAT cc = m1.c * m2.a + m1.d * m2.c;
297 FX_FLOAT dd = m1.c * m2.b + m1.d * m2.d; 297 FX_FLOAT dd = m1.c * m2.b + m1.d * m2.d;
298 FX_FLOAT ee = m1.e * m2.a + m1.f * m2.c + m2.e; 298 FX_FLOAT ee = m1.e * m2.a + m1.f * m2.c + m2.e;
299 FX_FLOAT ff = m1.e * m2.b + m1.f * m2.d + m2.f; 299 FX_FLOAT ff = m1.e * m2.b + m1.f * m2.d + m2.f;
300 m.a = aa, m.b = bb, m.c = cc, m.d = dd, m.e = ee, m.f = ff; 300 m.a = aa, m.b = bb, m.c = cc, m.d = dd, m.e = ee, m.f = ff;
301 } 301 }
302 void CFX_Matrix::Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended) 302 void CFX_Matrix::Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, bool bPrepended)
303 { 303 {
304 CFX_Matrix m; 304 CFX_Matrix m;
305 m.Set(a, b, c, d, e, f); 305 m.Set(a, b, c, d, e, f);
306 Concat(m, bPrepended); 306 Concat(m, bPrepended);
307 } 307 }
308 void CFX_Matrix::Concat(const CFX_Matrix &m, FX_BOOL bPrepended) 308 void CFX_Matrix::Concat(const CFX_Matrix &m, bool bPrepended)
309 { 309 {
310 if (bPrepended) { 310 if (bPrepended) {
311 FXCRT_Matrix_Concat(*this, m, *this); 311 FXCRT_Matrix_Concat(*this, m, *this);
312 } else { 312 } else {
313 FXCRT_Matrix_Concat(*this, *this, m); 313 FXCRT_Matrix_Concat(*this, *this, m);
314 } 314 }
315 } 315 }
316 void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, FX_BOOL bPrepended) 316 void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended)
317 { 317 {
318 CFX_Matrix m; 318 CFX_Matrix m;
319 m.SetReverse(src); 319 m.SetReverse(src);
320 Concat(m, bPrepended); 320 Concat(m, bPrepended);
321 } 321 }
322 FX_BOOL CFX_Matrix::IsInvertible() const 322 bool CFX_Matrix::IsInvertible() const
323 { 323 {
324 return FXSYS_fabs(a * d - b * c) >= 0.0001f; 324 return FXSYS_fabs(a * d - b * c) >= 0.0001f;
325 } 325 }
326 FX_BOOL CFX_Matrix::Is90Rotated() const 326 bool CFX_Matrix::Is90Rotated() const
327 { 327 {
328 return FXSYS_fabs(a * 1000) < FXSYS_fabs(b) && FXSYS_fabs(d * 1000) < FXSYS_ fabs(c); 328 return FXSYS_fabs(a * 1000) < FXSYS_fabs(b) && FXSYS_fabs(d * 1000) < FXSYS_ fabs(c);
329 } 329 }
330 FX_BOOL CFX_Matrix::IsScaled() const 330 bool CFX_Matrix::IsScaled() const
331 { 331 {
332 return FXSYS_fabs(b * 1000) < FXSYS_fabs(a) && FXSYS_fabs(c * 1000) < FXSYS_ fabs(d); 332 return FXSYS_fabs(b * 1000) < FXSYS_fabs(a) && FXSYS_fabs(c * 1000) < FXSYS_ fabs(d);
333 } 333 }
334 void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended) 334 void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended)
335 { 335 {
336 if (bPrepended) { 336 if (bPrepended) {
337 e += x * a + y * c; 337 e += x * a + y * c;
338 f += y * d + x * b; 338 f += y * d + x * b;
339 } else { 339 } else {
340 e += x, f += y; 340 e += x, f += y;
341 } 341 }
342 } 342 }
343 void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended) 343 void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended)
344 { 344 {
345 a *= sx, d *= sy; 345 a *= sx, d *= sy;
346 if (bPrepended) { 346 if (bPrepended) {
347 b *= sx; 347 b *= sx;
348 c *= sy; 348 c *= sy;
349 } else { 349 } else {
350 b *= sy; 350 b *= sy;
351 c *= sx; 351 c *= sx;
352 e *= sx; 352 e *= sx;
353 f *= sy; 353 f *= sy;
354 } 354 }
355 } 355 }
356 void CFX_Matrix::Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended) 356 void CFX_Matrix::Rotate(FX_FLOAT fRadian, bool bPrepended)
357 { 357 {
358 FX_FLOAT cosValue = FXSYS_cos(fRadian); 358 FX_FLOAT cosValue = FXSYS_cos(fRadian);
359 FX_FLOAT sinValue = FXSYS_sin(fRadian); 359 FX_FLOAT sinValue = FXSYS_sin(fRadian);
360 CFX_Matrix m; 360 CFX_Matrix m;
361 m.Set(cosValue, sinValue, -sinValue, cosValue, 0, 0); 361 m.Set(cosValue, sinValue, -sinValue, cosValue, 0, 0);
362 if (bPrepended) { 362 if (bPrepended) {
363 FXCRT_Matrix_Concat(*this, m, *this); 363 FXCRT_Matrix_Concat(*this, m, *this);
364 } else { 364 } else {
365 FXCRT_Matrix_Concat(*this, *this, m); 365 FXCRT_Matrix_Concat(*this, *this, m);
366 } 366 }
367 } 367 }
368 void CFX_Matrix::RotateAt(FX_FLOAT fRadian, FX_FLOAT dx, FX_FLOAT dy, FX_BOOL bP repended) 368 void CFX_Matrix::RotateAt(FX_FLOAT fRadian, FX_FLOAT dx, FX_FLOAT dy, bool bPrep ended)
369 { 369 {
370 Translate(dx, dy, bPrepended); 370 Translate(dx, dy, bPrepended);
371 Rotate(fRadian, bPrepended); 371 Rotate(fRadian, bPrepended);
372 Translate(-dx, -dy, bPrepended); 372 Translate(-dx, -dy, bPrepended);
373 } 373 }
374 void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPre pended) 374 void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, bool bPrepen ded)
375 { 375 {
376 CFX_Matrix m; 376 CFX_Matrix m;
377 m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0); 377 m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0);
378 if (bPrepended) { 378 if (bPrepended) {
379 FXCRT_Matrix_Concat(*this, m, *this); 379 FXCRT_Matrix_Concat(*this, m, *this);
380 } else { 380 } else {
381 FXCRT_Matrix_Concat(*this, *this, m); 381 FXCRT_Matrix_Concat(*this, *this, m);
382 } 382 }
383 } 383 }
384 void CFX_Matrix::MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src) 384 void CFX_Matrix::MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src)
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 left = x[i]; 560 left = x[i];
561 } 561 }
562 if (top < y[i]) { 562 if (top < y[i]) {
563 top = y[i]; 563 top = y[i];
564 } 564 }
565 if (bottom > y[i]) { 565 if (bottom > y[i]) {
566 bottom = y[i]; 566 bottom = y[i];
567 } 567 }
568 } 568 }
569 } 569 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_buffer.cpp ('k') | core/src/fxcrt/fx_basic_gcc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698