OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. | 3 * Copyright (C) 2009 Torch Mobile, Inc. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "platform/geometry/FloatBox.h" | 30 #include "platform/geometry/FloatBox.h" |
31 #include "platform/geometry/FloatQuad.h" | 31 #include "platform/geometry/FloatQuad.h" |
32 #include "platform/geometry/FloatRect.h" | 32 #include "platform/geometry/FloatRect.h" |
33 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 34 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/transforms/AffineTransform.h" | 35 #include "platform/transforms/AffineTransform.h" |
36 | 36 |
37 #include "wtf/Assertions.h" | 37 #include "wtf/Assertions.h" |
38 #include "wtf/MathExtras.h" | 38 #include "wtf/MathExtras.h" |
39 | 39 |
| 40 #include <cmath> |
| 41 #include <cstdlib> |
| 42 |
40 #if CPU(X86_64) | 43 #if CPU(X86_64) |
41 #include <emmintrin.h> | 44 #include <emmintrin.h> |
42 #endif | 45 #endif |
43 | 46 |
44 namespace blink { | 47 namespace blink { |
45 | 48 |
46 // | 49 // |
47 // Supporting Math Functions | 50 // Supporting Math Functions |
48 // | 51 // |
49 // This is a set of function from various places (attributed inline) to do thing
s like | 52 // This is a set of function from various places (attributed inline) to do thing
s like |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 double ax, ay, az, aw; | 592 double ax, ay, az, aw; |
590 double bx, by, bz, bw; | 593 double bx, by, bz, bw; |
591 double cx, cy, cz, cw; | 594 double cx, cy, cz, cw; |
592 double product; | 595 double product; |
593 | 596 |
594 ax = qa[0]; ay = qa[1]; az = qa[2]; aw = qa[3]; | 597 ax = qa[0]; ay = qa[1]; az = qa[2]; aw = qa[3]; |
595 bx = qb[0]; by = qb[1]; bz = qb[2]; bw = qb[3]; | 598 bx = qb[0]; by = qb[1]; bz = qb[2]; bw = qb[3]; |
596 | 599 |
597 product = ax * bx + ay * by + az * bz + aw * bw; | 600 product = ax * bx + ay * by + az * bz + aw * bw; |
598 | 601 |
599 // Clamp product to -1.0 <= product <= 1.0. | 602 product = clampTo(product, -1.0, 1.0); |
600 product = std::min(std::max(product, -1.0), 1.0); | |
601 | 603 |
602 const double epsilon = 1e-5; | 604 const double epsilon = 1e-5; |
603 if (std::abs(product - 1.0) < epsilon) { | 605 if (std::abs(product - 1.0) < epsilon) { |
604 // Result is qa, so just return | 606 // Result is qa, so just return |
605 return; | 607 return; |
606 } | 608 } |
607 | 609 |
608 double denom = std::sqrt(1.0 - product * product); | 610 double denom = std::sqrt(1.0 - product * product); |
609 double theta = std::acos(product); | 611 double theta = std::acos(product); |
610 double w = std::sin(t * theta) * (1.0 / denom); | 612 double w = std::sin(t * theta) * (1.0 / denom); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4; | 705 bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4; |
704 if (everythingWasClipped) | 706 if (everythingWasClipped) |
705 return FloatQuad(); | 707 return FloatQuad(); |
706 | 708 |
707 return projectedQuad; | 709 return projectedQuad; |
708 } | 710 } |
709 | 711 |
710 static float clampEdgeValue(float f) | 712 static float clampEdgeValue(float f) |
711 { | 713 { |
712 ASSERT(!std::isnan(f)); | 714 ASSERT(!std::isnan(f)); |
713 return std::min<float>(std::max<float>(f, (-LayoutUnit::max() / 2).toFloat()
), (LayoutUnit::max() / 2).toFloat()); | 715 return clampTo(f, (-LayoutUnit::max() / 2).toFloat(), (LayoutUnit::max() / 2
).toFloat()); |
714 } | 716 } |
715 | 717 |
716 LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q
) const | 718 LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q
) const |
717 { | 719 { |
718 FloatRect mappedQuadBounds = projectQuad(q).boundingBox(); | 720 FloatRect mappedQuadBounds = projectQuad(q).boundingBox(); |
719 | 721 |
720 float left = clampEdgeValue(floorf(mappedQuadBounds.x())); | 722 float left = clampEdgeValue(floorf(mappedQuadBounds.x())); |
721 float top = clampEdgeValue(floorf(mappedQuadBounds.y())); | 723 float top = clampEdgeValue(floorf(mappedQuadBounds.y())); |
722 | 724 |
723 float right; | 725 float right; |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 ret.setDouble(2, 2, matrix.m33()); | 1667 ret.setDouble(2, 2, matrix.m33()); |
1666 ret.setDouble(2, 3, matrix.m43()); | 1668 ret.setDouble(2, 3, matrix.m43()); |
1667 ret.setDouble(3, 0, matrix.m14()); | 1669 ret.setDouble(3, 0, matrix.m14()); |
1668 ret.setDouble(3, 1, matrix.m24()); | 1670 ret.setDouble(3, 1, matrix.m24()); |
1669 ret.setDouble(3, 2, matrix.m34()); | 1671 ret.setDouble(3, 2, matrix.m34()); |
1670 ret.setDouble(3, 3, matrix.m44()); | 1672 ret.setDouble(3, 3, matrix.m44()); |
1671 return ret; | 1673 return ret; |
1672 } | 1674 } |
1673 | 1675 |
1674 } | 1676 } |
OLD | NEW |