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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 count >>= 1; | 930 count >>= 1; |
931 for (int i = 0; i < count; ++i) { | 931 for (int i = 0; i < count; ++i) { |
932 (Sk4s::Load(&src[0].fX) * scale4 + trans4).store(&dst[0].fX); | 932 (Sk4s::Load(&src[0].fX) * scale4 + trans4).store(&dst[0].fX); |
933 (Sk4s::Load(&src[2].fX) * scale4 + trans4).store(&dst[2].fX); | 933 (Sk4s::Load(&src[2].fX) * scale4 + trans4).store(&dst[2].fX); |
934 src += 4; | 934 src += 4; |
935 dst += 4; | 935 dst += 4; |
936 } | 936 } |
937 } | 937 } |
938 } | 938 } |
939 | 939 |
940 void SkMatrix::Rot_pts(const SkMatrix& m, SkPoint dst[], | |
941 const SkPoint src[], int count) { | |
942 SkASSERT((m.getType() & (kPerspective_Mask | kTranslate_Mask)) == 0); | |
943 | |
944 if (count > 0) { | |
945 SkScalar mx = m.fMat[kMScaleX]; | |
946 SkScalar my = m.fMat[kMScaleY]; | |
947 SkScalar kx = m.fMat[kMSkewX]; | |
948 SkScalar ky = m.fMat[kMSkewY]; | |
949 do { | |
950 SkScalar sy = src->fY; | |
951 SkScalar sx = src->fX; | |
952 src += 1; | |
953 dst->fY = sdot(sx, ky, sy, my); | |
954 dst->fX = sdot(sx, mx, sy, kx); | |
955 dst += 1; | |
956 } while (--count); | |
957 } | |
958 } | |
959 | |
960 void SkMatrix::RotTrans_pts(const SkMatrix& m, SkPoint dst[], | |
961 const SkPoint src[], int count) { | |
962 SkASSERT(!m.hasPerspective()); | |
963 | |
964 if (count > 0) { | |
965 SkScalar mx = m.fMat[kMScaleX]; | |
966 SkScalar my = m.fMat[kMScaleY]; | |
967 SkScalar kx = m.fMat[kMSkewX]; | |
968 SkScalar ky = m.fMat[kMSkewY]; | |
969 SkScalar tx = m.fMat[kMTransX]; | |
970 SkScalar ty = m.fMat[kMTransY]; | |
971 do { | |
972 SkScalar sy = src->fY; | |
973 SkScalar sx = src->fX; | |
974 src += 1; | |
975 #ifdef SK_LEGACY_MATRIX_MATH_ORDER | |
976 dst->fY = sx * ky + (sy * my + ty); | |
977 dst->fX = sx * mx + (sy * kx + tx); | |
978 #else | |
979 dst->fY = sdot(sx, ky, sy, my) + ty; | |
980 dst->fX = sdot(sx, mx, sy, kx) + tx; | |
981 #endif | |
982 dst += 1; | |
983 } while (--count); | |
984 } | |
985 } | |
986 | |
987 void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], | 940 void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], |
988 const SkPoint src[], int count) { | 941 const SkPoint src[], int count) { |
989 SkASSERT(m.hasPerspective()); | 942 SkASSERT(m.hasPerspective()); |
990 | 943 |
991 if (count > 0) { | 944 if (count > 0) { |
992 do { | 945 do { |
993 SkScalar sy = src->fY; | 946 SkScalar sy = src->fY; |
994 SkScalar sx = src->fX; | 947 SkScalar sx = src->fX; |
995 src += 1; | 948 src += 1; |
996 | 949 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 (src4 * scale4 + swz4 * skew4 + trans4).store(&dst->fX); | 991 (src4 * scale4 + swz4 * skew4 + trans4).store(&dst->fX); |
1039 src += 2; | 992 src += 2; |
1040 dst += 2; | 993 dst += 2; |
1041 } | 994 } |
1042 } | 995 } |
1043 } | 996 } |
1044 | 997 |
1045 const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = { | 998 const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = { |
1046 SkMatrix::Identity_pts, SkMatrix::Trans_pts, | 999 SkMatrix::Identity_pts, SkMatrix::Trans_pts, |
1047 SkMatrix::Scale_pts, SkMatrix::Scale_pts, | 1000 SkMatrix::Scale_pts, SkMatrix::Scale_pts, |
1048 #ifdef SK_SUPPORT_LEGACY_SCALAR_MAPPOINTS | |
1049 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts, | |
1050 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts, | |
1051 #else | |
1052 SkMatrix::Affine_vpts, SkMatrix::Affine_vpts, | 1001 SkMatrix::Affine_vpts, SkMatrix::Affine_vpts, |
1053 SkMatrix::Affine_vpts, SkMatrix::Affine_vpts, | 1002 SkMatrix::Affine_vpts, SkMatrix::Affine_vpts, |
1054 #endif | |
1055 // repeat the persp proc 8 times | 1003 // repeat the persp proc 8 times |
1056 SkMatrix::Persp_pts, SkMatrix::Persp_pts, | 1004 SkMatrix::Persp_pts, SkMatrix::Persp_pts, |
1057 SkMatrix::Persp_pts, SkMatrix::Persp_pts, | 1005 SkMatrix::Persp_pts, SkMatrix::Persp_pts, |
1058 SkMatrix::Persp_pts, SkMatrix::Persp_pts, | 1006 SkMatrix::Persp_pts, SkMatrix::Persp_pts, |
1059 SkMatrix::Persp_pts, SkMatrix::Persp_pts | 1007 SkMatrix::Persp_pts, SkMatrix::Persp_pts |
1060 }; | 1008 }; |
1061 | 1009 |
1062 /////////////////////////////////////////////////////////////////////////////// | 1010 /////////////////////////////////////////////////////////////////////////////// |
1063 | 1011 |
1064 void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int co
unt) const { | 1012 void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int co
unt) const { |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 rotation1->fX = cos1; | 1793 rotation1->fX = cos1; |
1846 rotation1->fY = sin1; | 1794 rotation1->fY = sin1; |
1847 } | 1795 } |
1848 if (rotation2) { | 1796 if (rotation2) { |
1849 rotation2->fX = cos2; | 1797 rotation2->fX = cos2; |
1850 rotation2->fY = sin2; | 1798 rotation2->fY = sin2; |
1851 } | 1799 } |
1852 | 1800 |
1853 return true; | 1801 return true; |
1854 } | 1802 } |
OLD | NEW |