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 (size_t i = 0; i < 2; ++i) { |
| 655 for (size_t j = 0; j < 2; ++j) { |
| 656 for (size_t k = 0; k < 2; ++k) { |
| 657 FloatPoint3D point(box.x(), box.y(), box.z()); |
| 658 point += FloatPoint3D(i * box.width(), j * box.height(), k * box
.depth()); |
| 659 point = mapPoint(point); |
| 660 if (firstPoint) { |
| 661 bounds.setOrigin(point); |
| 662 firstPoint = false; |
| 663 } else { |
| 664 bounds.expandTo(point); |
| 665 } |
| 666 } |
| 667 } |
| 668 } |
| 669 box = bounds; |
| 670 } |
| 671 |
649 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const | 672 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const |
650 { | 673 { |
651 if (isIdentityOrTranslation()) | 674 if (isIdentityOrTranslation()) |
652 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st
atic_cast<float>(m_matrix[3][1])); | 675 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st
atic_cast<float>(m_matrix[3][1])); |
653 | 676 |
654 return internalMapPoint(p); | 677 return internalMapPoint(p); |
655 } | 678 } |
656 | 679 |
657 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const | 680 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const |
658 { | 681 { |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 ret.setDouble(2, 2, matrix.m33()); | 1546 ret.setDouble(2, 2, matrix.m33()); |
1524 ret.setDouble(2, 3, matrix.m43()); | 1547 ret.setDouble(2, 3, matrix.m43()); |
1525 ret.setDouble(3, 0, matrix.m14()); | 1548 ret.setDouble(3, 0, matrix.m14()); |
1526 ret.setDouble(3, 1, matrix.m24()); | 1549 ret.setDouble(3, 1, matrix.m24()); |
1527 ret.setDouble(3, 2, matrix.m34()); | 1550 ret.setDouble(3, 2, matrix.m34()); |
1528 ret.setDouble(3, 3, matrix.m44()); | 1551 ret.setDouble(3, 3, matrix.m44()); |
1529 return ret; | 1552 return ret; |
1530 } | 1553 } |
1531 | 1554 |
1532 } | 1555 } |
OLD | NEW |