OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 #include "SkFloatBits.h" | 9 #include "SkFloatBits.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1596 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask); | 1596 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask); |
1597 | 1597 |
1598 static const PODMatrix invalid = | 1598 static const PODMatrix invalid = |
1599 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1599 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
1600 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, | 1600 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, |
1601 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax }, | 1601 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax }, |
1602 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask }; | 1602 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask }; |
1603 return invalid.asSkMatrix(); | 1603 return invalid.asSkMatrix(); |
1604 } | 1604 } |
1605 | 1605 |
1606 bool SkMatrix::decomposeScale(SkSize* scale, SkMatrix* remaining) const { | |
1607 if (this->hasPerspective()) { | |
1608 return false; | |
1609 } | |
1610 | |
1611 const SkScalar sx = SkVector::Length(this->getScaleX(), this->getSkewY()); | |
1612 const SkScalar sy = SkVector::Length(this->getSkewX(), this->getScaleY()); | |
1613 if (0 == sx || 0 == sy) { | |
1614 return false; | |
1615 } | |
1616 | |
1617 if (scale) { | |
1618 scale->set(sx, sy); | |
1619 } | |
1620 if (remaining) { | |
1621 *remaining = *this; | |
1622 remaining->postScale(SkScalarInvert(sx), SkScalarInvert(sy)); | |
Stephen White
2015/03/19 18:27:50
Hmm.. for my uses, I was also extracting the trans
| |
1623 } | |
1624 return true; | |
1625 } | |
1626 | |
1606 /////////////////////////////////////////////////////////////////////////////// | 1627 /////////////////////////////////////////////////////////////////////////////// |
1607 | 1628 |
1608 size_t SkMatrix::writeToMemory(void* buffer) const { | 1629 size_t SkMatrix::writeToMemory(void* buffer) const { |
1609 // TODO write less for simple matrices | 1630 // TODO write less for simple matrices |
1610 static const size_t sizeInMemory = 9 * sizeof(SkScalar); | 1631 static const size_t sizeInMemory = 9 * sizeof(SkScalar); |
1611 if (buffer) { | 1632 if (buffer) { |
1612 memcpy(buffer, fMat, sizeInMemory); | 1633 memcpy(buffer, fMat, sizeInMemory); |
1613 } | 1634 } |
1614 return sizeInMemory; | 1635 return sizeInMemory; |
1615 } | 1636 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1784 rotation1->fX = cos1; | 1805 rotation1->fX = cos1; |
1785 rotation1->fY = sin1; | 1806 rotation1->fY = sin1; |
1786 } | 1807 } |
1787 if (rotation2) { | 1808 if (rotation2) { |
1788 rotation2->fX = cos2; | 1809 rotation2->fX = cos2; |
1789 rotation2->fY = sin2; | 1810 rotation2->fY = sin2; |
1790 } | 1811 } |
1791 | 1812 |
1792 return true; | 1813 return true; |
1793 } | 1814 } |
OLD | NEW |