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 "SkRSXform.h" | 10 #include "SkRSXform.h" |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 inv->fMat[kMScaleY] = invY; | 851 inv->fMat[kMScaleY] = invY; |
852 inv->fMat[kMPersp2] = 1; | 852 inv->fMat[kMPersp2] = 1; |
853 inv->fMat[kMTransX] = -fMat[kMTransX] * invX; | 853 inv->fMat[kMTransX] = -fMat[kMTransX] * invX; |
854 inv->fMat[kMTransY] = -fMat[kMTransY] * invY; | 854 inv->fMat[kMTransY] = -fMat[kMTransY] * invY; |
855 | 855 |
856 inv->setTypeMask(mask | kRectStaysRect_Mask); | 856 inv->setTypeMask(mask | kRectStaysRect_Mask); |
857 } else { | 857 } else { |
858 // translate only | 858 // translate only |
859 inv->setTranslate(-fMat[kMTransX], -fMat[kMTransY]); | 859 inv->setTranslate(-fMat[kMTransX], -fMat[kMTransY]); |
860 } | 860 } |
861 } else { // inv is NULL, just check if we're invertible | 861 } else { // inv is nullptr, just check if we're invertible |
862 if (!fMat[kMScaleX] || !fMat[kMScaleY]) { | 862 if (!fMat[kMScaleX] || !fMat[kMScaleY]) { |
863 invertible = false; | 863 invertible = false; |
864 } | 864 } |
865 } | 865 } |
866 return invertible; | 866 return invertible; |
867 } | 867 } |
868 | 868 |
869 int isPersp = mask & kPerspective_Mask; | 869 int isPersp = mask & kPerspective_Mask; |
870 double invDet = sk_inv_determinant(fMat, isPersp); | 870 double invDet = sk_inv_determinant(fMat, isPersp); |
871 | 871 |
872 if (invDet == 0) { // underflow | 872 if (invDet == 0) { // underflow |
873 return false; | 873 return false; |
874 } | 874 } |
875 | 875 |
876 bool applyingInPlace = (inv == this); | 876 bool applyingInPlace = (inv == this); |
877 | 877 |
878 SkMatrix* tmp = inv; | 878 SkMatrix* tmp = inv; |
879 | 879 |
880 SkMatrix storage; | 880 SkMatrix storage; |
881 if (applyingInPlace || NULL == tmp) { | 881 if (applyingInPlace || nullptr == tmp) { |
882 tmp = &storage; // we either need to avoid trampling memory or have
no memory | 882 tmp = &storage; // we either need to avoid trampling memory or have
no memory |
883 } | 883 } |
884 | 884 |
885 ComputeInv(tmp->fMat, fMat, invDet, isPersp); | 885 ComputeInv(tmp->fMat, fMat, invDet, isPersp); |
886 if (!tmp->isFinite()) { | 886 if (!tmp->isFinite()) { |
887 return false; | 887 return false; |
888 } | 888 } |
889 | 889 |
890 tmp->setTypeMask(fTypeMask); | 890 tmp->setTypeMask(fTypeMask); |
891 | 891 |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 const SkScalar m11 = m00; | 1851 const SkScalar m11 = m00; |
1852 const SkScalar m12 = fTy; | 1852 const SkScalar m12 = fTy; |
1853 | 1853 |
1854 quad[0].set(m02, m12); | 1854 quad[0].set(m02, m12); |
1855 quad[1].set(m00 * width + m02, m10 * width + m12); | 1855 quad[1].set(m00 * width + m02, m10 * width + m12); |
1856 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); | 1856 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); |
1857 quad[3].set(m01 * height + m02, m11 * height + m12); | 1857 quad[3].set(m01 * height + m02, m11 * height + m12); |
1858 #endif | 1858 #endif |
1859 } | 1859 } |
1860 | 1860 |
OLD | NEW |