| OLD | NEW |
| 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 #include "../../include/fxcrt/fx_ext.h" | 8 #include "../../include/fxcrt/fx_ext.h" |
| 9 void FX_RECT::Normalize() | 9 void FX_RECT::Normalize() |
| 10 { | 10 { |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 FX_FLOAT ac = a + c, bd = b + d; | 423 FX_FLOAT ac = a + c, bd = b + d; |
| 424 FX_FLOAT C = FXSYS_sqrt(ac * ac + bd * bd); | 424 FX_FLOAT C = FXSYS_sqrt(ac * ac + bd * bd); |
| 425 FX_FLOAT P = (A + B + C ) / 2; | 425 FX_FLOAT P = (A + B + C ) / 2; |
| 426 return FXSYS_sqrt(P * (P - A) * (P - B) * (P - C)) * 2; | 426 return FXSYS_sqrt(P * (P - A) * (P - B) * (P - C)) * 2; |
| 427 } | 427 } |
| 428 FX_FLOAT CFX_Matrix::TransformXDistance(FX_FLOAT dx) const | 428 FX_FLOAT CFX_Matrix::TransformXDistance(FX_FLOAT dx) const |
| 429 { | 429 { |
| 430 FX_FLOAT fx = a * dx, fy = b * dx; | 430 FX_FLOAT fx = a * dx, fy = b * dx; |
| 431 return FXSYS_sqrt(fx * fx + fy * fy); | 431 return FXSYS_sqrt(fx * fx + fy * fy); |
| 432 } | 432 } |
| 433 FX_INT32 CFX_Matrix::TransformXDistance(FX_INT32 dx) const | 433 int32_t CFX_Matrix::TransformXDistance(int32_t dx) const |
| 434 { | 434 { |
| 435 FX_FLOAT fx = a * dx, fy = b * dx; | 435 FX_FLOAT fx = a * dx, fy = b * dx; |
| 436 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); | 436 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); |
| 437 } | 437 } |
| 438 FX_FLOAT CFX_Matrix::TransformYDistance(FX_FLOAT dy) const | 438 FX_FLOAT CFX_Matrix::TransformYDistance(FX_FLOAT dy) const |
| 439 { | 439 { |
| 440 FX_FLOAT fx = c * dy, fy = d * dy; | 440 FX_FLOAT fx = c * dy, fy = d * dy; |
| 441 return FXSYS_sqrt(fx * fx + fy * fy); | 441 return FXSYS_sqrt(fx * fx + fy * fy); |
| 442 } | 442 } |
| 443 FX_INT32 CFX_Matrix::TransformYDistance(FX_INT32 dy) const | 443 int32_t CFX_Matrix::TransformYDistance(int32_t dy) const |
| 444 { | 444 { |
| 445 FX_FLOAT fx = c * dy, fy = d * dy; | 445 FX_FLOAT fx = c * dy, fy = d * dy; |
| 446 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); | 446 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); |
| 447 } | 447 } |
| 448 FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const | 448 FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const |
| 449 { | 449 { |
| 450 FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy; | 450 FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy; |
| 451 return FXSYS_sqrt(fx * fx + fy * fy); | 451 return FXSYS_sqrt(fx * fx + fy * fy); |
| 452 } | 452 } |
| 453 FX_INT32 CFX_Matrix::TransformDistance(FX_INT32 dx, FX_INT32 dy) const | 453 int32_t CFX_Matrix::TransformDistance(int32_t dx, int32_t dy) const |
| 454 { | 454 { |
| 455 FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy; | 455 FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy; |
| 456 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); | 456 return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy)); |
| 457 } | 457 } |
| 458 FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT distance) const | 458 FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT distance) const |
| 459 { | 459 { |
| 460 return distance * (GetXUnit() + GetYUnit()) / 2; | 460 return distance * (GetXUnit() + GetYUnit()) / 2; |
| 461 } | 461 } |
| 462 void CFX_Matrix::TransformVector(CFX_VectorF &v) const | 462 void CFX_Matrix::TransformVector(CFX_VectorF &v) const |
| 463 { | 463 { |
| 464 FX_FLOAT fx = a * v.x + c * v.y; | 464 FX_FLOAT fx = a * v.x + c * v.y; |
| 465 FX_FLOAT fy = b * v.x + d * v.y; | 465 FX_FLOAT fy = b * v.x + d * v.y; |
| 466 v.x = fx, v.y = fy; | 466 v.x = fx, v.y = fy; |
| 467 } | 467 } |
| 468 void CFX_Matrix::TransformVector(CFX_Vector &v) const | 468 void CFX_Matrix::TransformVector(CFX_Vector &v) const |
| 469 { | 469 { |
| 470 FX_FLOAT fx = a * v.x + c * v.y; | 470 FX_FLOAT fx = a * v.x + c * v.y; |
| 471 FX_FLOAT fy = b * v.x + d * v.y; | 471 FX_FLOAT fy = b * v.x + d * v.y; |
| 472 v.x = FXSYS_round(fx); | 472 v.x = FXSYS_round(fx); |
| 473 v.y = FXSYS_round(fy); | 473 v.y = FXSYS_round(fy); |
| 474 } | 474 } |
| 475 void CFX_Matrix::TransformPoints(CFX_Point *points, FX_INT32 iCount) const | 475 void CFX_Matrix::TransformPoints(CFX_Point *points, int32_t iCount) const |
| 476 { | 476 { |
| 477 FXSYS_assert(iCount > 0); | 477 FXSYS_assert(iCount > 0); |
| 478 FX_FLOAT fx, fy; | 478 FX_FLOAT fx, fy; |
| 479 for (FX_INT32 i = 0; i < iCount; i ++) { | 479 for (int32_t i = 0; i < iCount; i ++) { |
| 480 fx = a * points->x + c * points->y + e; | 480 fx = a * points->x + c * points->y + e; |
| 481 fy = b * points->x + d * points->y + f; | 481 fy = b * points->x + d * points->y + f; |
| 482 points->x = FXSYS_round(fx); | 482 points->x = FXSYS_round(fx); |
| 483 points->y = FXSYS_round(fy); | 483 points->y = FXSYS_round(fy); |
| 484 points ++; | 484 points ++; |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 void CFX_Matrix::TransformPoints(CFX_PointF *points, FX_INT32 iCount) const | 487 void CFX_Matrix::TransformPoints(CFX_PointF *points, int32_t iCount) const |
| 488 { | 488 { |
| 489 FXSYS_assert(iCount > 0); | 489 FXSYS_assert(iCount > 0); |
| 490 FX_FLOAT fx, fy; | 490 FX_FLOAT fx, fy; |
| 491 for (FX_INT32 i = 0; i < iCount; i ++) { | 491 for (int32_t i = 0; i < iCount; i ++) { |
| 492 fx = a * points->x + c * points->y + e; | 492 fx = a * points->x + c * points->y + e; |
| 493 fy = b * points->x + d * points->y + f; | 493 fy = b * points->x + d * points->y + f; |
| 494 points->x = fx, points->y = fy; | 494 points->x = fx, points->y = fy; |
| 495 points ++; | 495 points ++; |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 void CFX_Matrix::TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const | 498 void CFX_Matrix::TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const |
| 499 { | 499 { |
| 500 FX_FLOAT fx = a * x + c * y + e; | 500 FX_FLOAT fx = a * x + c * y + e; |
| 501 FX_FLOAT fy = b * x + d * y + f; | 501 FX_FLOAT fy = b * x + d * y + f; |
| 502 x = fx, y = fy; | 502 x = fx, y = fy; |
| 503 } | 503 } |
| 504 void CFX_Matrix::TransformPoint(FX_INT32 &x, FX_INT32 &y) const | 504 void CFX_Matrix::TransformPoint(int32_t &x, int32_t &y) const |
| 505 { | 505 { |
| 506 FX_FLOAT fx = a * x + c * y + e; | 506 FX_FLOAT fx = a * x + c * y + e; |
| 507 FX_FLOAT fy = b * x + d * y + f; | 507 FX_FLOAT fy = b * x + d * y + f; |
| 508 x = FXSYS_round(fx); | 508 x = FXSYS_round(fx); |
| 509 y = FXSYS_round(fy); | 509 y = FXSYS_round(fy); |
| 510 } | 510 } |
| 511 void CFX_Matrix::TransformRect(CFX_RectF &rect) const | 511 void CFX_Matrix::TransformRect(CFX_RectF &rect) const |
| 512 { | 512 { |
| 513 FX_FLOAT right = rect.right(), bottom = rect.bottom(); | 513 FX_FLOAT right = rect.right(), bottom = rect.bottom(); |
| 514 TransformRect(rect.left, right, bottom, rect.top); | 514 TransformRect(rect.left, right, bottom, rect.top); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 left = x[i]; | 552 left = x[i]; |
| 553 } | 553 } |
| 554 if (top < y[i]) { | 554 if (top < y[i]) { |
| 555 top = y[i]; | 555 top = y[i]; |
| 556 } | 556 } |
| 557 if (bottom > y[i]) { | 557 if (bottom > y[i]) { |
| 558 bottom = y[i]; | 558 bottom = y[i]; |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 } | 561 } |
| OLD | NEW |