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(), | |
Ian Vollick
2014/06/17 15:54:56
nit: I think this would look prettier on one line
awoloszyn
2014/06/17 20:06:03
Done.
| |
659 j * box.height(), | |
660 k * box.depth()); | |
661 point = mapPoint(point); | |
662 if (firstPoint) { | |
663 bounds.setOrigin(point); | |
664 firstPoint = false; | |
665 } else { | |
666 bounds.expandTo(point); | |
667 } | |
668 } | |
669 } | |
670 } | |
671 box = bounds; | |
672 } | |
Ian Vollick
2014/06/17 15:54:56
nit: extra ws.
awoloszyn
2014/06/17 20:06:03
Done.
| |
673 | |
674 | |
649 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const | 675 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const |
650 { | 676 { |
651 if (isIdentityOrTranslation()) | 677 if (isIdentityOrTranslation()) |
652 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st atic_cast<float>(m_matrix[3][1])); | 678 return FloatPoint(p.x() + static_cast<float>(m_matrix[3][0]), p.y() + st atic_cast<float>(m_matrix[3][1])); |
653 | 679 |
654 return internalMapPoint(p); | 680 return internalMapPoint(p); |
655 } | 681 } |
656 | 682 |
657 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const | 683 FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D& p) const |
658 { | 684 { |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 ret.setDouble(2, 2, matrix.m33()); | 1549 ret.setDouble(2, 2, matrix.m33()); |
1524 ret.setDouble(2, 3, matrix.m43()); | 1550 ret.setDouble(2, 3, matrix.m43()); |
1525 ret.setDouble(3, 0, matrix.m14()); | 1551 ret.setDouble(3, 0, matrix.m14()); |
1526 ret.setDouble(3, 1, matrix.m24()); | 1552 ret.setDouble(3, 1, matrix.m24()); |
1527 ret.setDouble(3, 2, matrix.m34()); | 1553 ret.setDouble(3, 2, matrix.m34()); |
1528 ret.setDouble(3, 3, matrix.m44()); | 1554 ret.setDouble(3, 3, matrix.m44()); |
1529 return ret; | 1555 return ret; |
1530 } | 1556 } |
1531 | 1557 |
1532 } | 1558 } |
OLD | NEW |