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 20 matching lines...) Expand all Loading... |
31 #include "platform/geometry/FloatBox.h" | 31 #include "platform/geometry/FloatBox.h" |
32 #include "platform/geometry/FloatQuad.h" | 32 #include "platform/geometry/FloatQuad.h" |
33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "platform/geometry/IntRect.h" | 34 #include "platform/geometry/IntRect.h" |
35 #include "platform/geometry/LayoutRect.h" | 35 #include "platform/geometry/LayoutRect.h" |
36 #include "platform/transforms/AffineTransform.h" | 36 #include "platform/transforms/AffineTransform.h" |
37 | 37 |
38 #include "wtf/Assertions.h" | 38 #include "wtf/Assertions.h" |
39 #include "wtf/MathExtras.h" | 39 #include "wtf/MathExtras.h" |
40 | 40 |
| 41 #include <cmath> |
| 42 #include <cstdlib> |
| 43 |
41 #if CPU(X86_64) | 44 #if CPU(X86_64) |
42 #include <emmintrin.h> | 45 #include <emmintrin.h> |
43 #endif | 46 #endif |
44 | 47 |
45 namespace blink { | 48 namespace blink { |
46 | 49 |
47 // | 50 // |
48 // Supporting Math Functions | 51 // Supporting Math Functions |
49 // | 52 // |
50 // This is a set of function from various places (attributed inline) to do thing
s like | 53 // 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... |
590 double ax, ay, az, aw; | 593 double ax, ay, az, aw; |
591 double bx, by, bz, bw; | 594 double bx, by, bz, bw; |
592 double cx, cy, cz, cw; | 595 double cx, cy, cz, cw; |
593 double product; | 596 double product; |
594 | 597 |
595 ax = qa[0]; ay = qa[1]; az = qa[2]; aw = qa[3]; | 598 ax = qa[0]; ay = qa[1]; az = qa[2]; aw = qa[3]; |
596 bx = qb[0]; by = qb[1]; bz = qb[2]; bw = qb[3]; | 599 bx = qb[0]; by = qb[1]; bz = qb[2]; bw = qb[3]; |
597 | 600 |
598 product = ax * bx + ay * by + az * bz + aw * bw; | 601 product = ax * bx + ay * by + az * bz + aw * bw; |
599 | 602 |
600 // Clamp product to -1.0 <= product <= 1.0. | 603 product = clampTo(product, -1.0, 1.0); |
601 product = std::min(std::max(product, -1.0), 1.0); | |
602 | 604 |
603 const double epsilon = 1e-5; | 605 const double epsilon = 1e-5; |
604 if (std::abs(product - 1.0) < epsilon) { | 606 if (std::abs(product - 1.0) < epsilon) { |
605 // Result is qa, so just return | 607 // Result is qa, so just return |
606 return; | 608 return; |
607 } | 609 } |
608 | 610 |
609 double denom = std::sqrt(1.0 - product * product); | 611 double denom = std::sqrt(1.0 - product * product); |
610 double theta = std::acos(product); | 612 double theta = std::acos(product); |
611 double w = std::sin(t * theta) * (1.0 / denom); | 613 double w = std::sin(t * theta) * (1.0 / denom); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4; | 706 bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4; |
705 if (everythingWasClipped) | 707 if (everythingWasClipped) |
706 return FloatQuad(); | 708 return FloatQuad(); |
707 | 709 |
708 return projectedQuad; | 710 return projectedQuad; |
709 } | 711 } |
710 | 712 |
711 static float clampEdgeValue(float f) | 713 static float clampEdgeValue(float f) |
712 { | 714 { |
713 ASSERT(!std::isnan(f)); | 715 ASSERT(!std::isnan(f)); |
714 return std::min<float>(std::max<float>(f, (-LayoutUnit::max() / 2).toFloat()
), (LayoutUnit::max() / 2).toFloat()); | 716 return clampTo(f, (-LayoutUnit::max() / 2).toFloat(), (LayoutUnit::max() / 2
).toFloat()); |
715 } | 717 } |
716 | 718 |
717 LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q
) const | 719 LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q
) const |
718 { | 720 { |
719 FloatRect mappedQuadBounds = projectQuad(q).boundingBox(); | 721 FloatRect mappedQuadBounds = projectQuad(q).boundingBox(); |
720 | 722 |
721 float left = clampEdgeValue(floorf(mappedQuadBounds.x())); | 723 float left = clampEdgeValue(floorf(mappedQuadBounds.x())); |
722 float top = clampEdgeValue(floorf(mappedQuadBounds.y())); | 724 float top = clampEdgeValue(floorf(mappedQuadBounds.y())); |
723 | 725 |
724 float right; | 726 float right; |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 ret.setDouble(2, 2, matrix.m33()); | 1668 ret.setDouble(2, 2, matrix.m33()); |
1667 ret.setDouble(2, 3, matrix.m43()); | 1669 ret.setDouble(2, 3, matrix.m43()); |
1668 ret.setDouble(3, 0, matrix.m14()); | 1670 ret.setDouble(3, 0, matrix.m14()); |
1669 ret.setDouble(3, 1, matrix.m24()); | 1671 ret.setDouble(3, 1, matrix.m24()); |
1670 ret.setDouble(3, 2, matrix.m34()); | 1672 ret.setDouble(3, 2, matrix.m34()); |
1671 ret.setDouble(3, 3, matrix.m44()); | 1673 ret.setDouble(3, 3, matrix.m44()); |
1672 return ret; | 1674 return ret; |
1673 } | 1675 } |
1674 | 1676 |
1675 } | 1677 } |
OLD | NEW |