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 10 matching lines...) Expand all Loading... | |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "platform/transforms/TransformationMatrix.h" | 29 #include "platform/transforms/TransformationMatrix.h" |
30 | 30 |
31 #include "platform/geometry/FloatBox.h" | |
31 #include "platform/geometry/FloatQuad.h" | 32 #include "platform/geometry/FloatQuad.h" |
32 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
33 #include "platform/geometry/IntRect.h" | 34 #include "platform/geometry/IntRect.h" |
34 #include "platform/geometry/LayoutRect.h" | 35 #include "platform/geometry/LayoutRect.h" |
35 #include "platform/transforms/AffineTransform.h" | 36 #include "platform/transforms/AffineTransform.h" |
36 | 37 |
37 #include "wtf/Assertions.h" | 38 #include "wtf/Assertions.h" |
38 #include "wtf/MathExtras.h" | 39 #include "wtf/MathExtras.h" |
39 | 40 |
40 #if CPU(X86_64) | 41 #if CPU(X86_64) |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 | 640 |
640 float bottom; | 641 float bottom; |
641 if (std::isinf(mappedQuadBounds.y()) && std::isinf(mappedQuadBounds.height() )) | 642 if (std::isinf(mappedQuadBounds.y()) && std::isinf(mappedQuadBounds.height() )) |
642 bottom = (LayoutUnit::max() / 2).toFloat(); | 643 bottom = (LayoutUnit::max() / 2).toFloat(); |
643 else | 644 else |
644 bottom = clampEdgeValue(ceilf(mappedQuadBounds.maxY())); | 645 bottom = clampEdgeValue(ceilf(mappedQuadBounds.maxY())); |
645 | 646 |
646 return LayoutRect(LayoutUnit::clamp(left), LayoutUnit::clamp(top), LayoutUn it::clamp(right - left), LayoutUnit::clamp(bottom - top)); | 647 return LayoutRect(LayoutUnit::clamp(left), LayoutUnit::clamp(top), LayoutUn it::clamp(right - left), LayoutUnit::clamp(bottom - top)); |
647 } | 648 } |
648 | 649 |
650 void TransformationMatrix::transformBox(FloatBox& box) const | |
651 { | |
652 FloatBox bounds; | |
653 bool firstPoint = true; | |
654 for (int corner = 0; corner < 8; ++corner) { | |
655 FloatPoint3D point(box.x(), box.y(), box.z()); | |
656 point += FloatPoint3D(corner & 1? box.width() : 0, | |
Ian Vollick
2014/06/16 15:23:38
Same comment about this little snippet.
awoloszyn
2014/06/17 14:26:01
Done.
| |
657 corner & 2? box.height() : 0, | |
658 corner & 4? box.depth() : 0); | |
659 point = mapPoint(point); | |
660 if (firstPoint) { | |
661 bounds.setOrigin(point); | |
662 firstPoint = false; | |
663 } else { | |
664 bounds.expandTo(point); | |
665 } | |
666 } | |
667 box = bounds; | |
668 } | |
669 | |
670 | |
649 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const | 671 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const |
650 { | 672 { |
651 if (isIdentityOrTranslation()) | 673 if (isIdentityOrTranslation()) |
652 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st atic_cast<float>(m_matrix[3][1])); | 674 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st atic_cast<float>(m_matrix[3][1])); |
653 | 675 |
654 return internalMapPoint(p); | 676 return internalMapPoint(p); |
655 } | 677 } |
656 | 678 |
657 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const | 679 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const |
658 { | 680 { |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 ret.setDouble(2, 2, matrix.m33()); | 1545 ret.setDouble(2, 2, matrix.m33()); |
1524 ret.setDouble(2, 3, matrix.m43()); | 1546 ret.setDouble(2, 3, matrix.m43()); |
1525 ret.setDouble(3, 0, matrix.m14()); | 1547 ret.setDouble(3, 0, matrix.m14()); |
1526 ret.setDouble(3, 1, matrix.m24()); | 1548 ret.setDouble(3, 1, matrix.m24()); |
1527 ret.setDouble(3, 2, matrix.m34()); | 1549 ret.setDouble(3, 2, matrix.m34()); |
1528 ret.setDouble(3, 3, matrix.m44()); | 1550 ret.setDouble(3, 3, matrix.m44()); |
1529 return ret; | 1551 return ret; |
1530 } | 1552 } |
1531 | 1553 |
1532 } | 1554 } |
OLD | NEW |