OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkMatrix44.h" | 8 #include "SkMatrix44.h" |
9 | 9 |
10 static inline bool eq4(const SkMScalar* SK_RESTRICT a, | 10 static inline bool eq4(const SkMScalar* SK_RESTRICT a, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const SkMScalar* src = &fMat[0][0]; | 78 const SkMScalar* src = &fMat[0][0]; |
79 #ifdef SK_MSCALAR_IS_DOUBLE | 79 #ifdef SK_MSCALAR_IS_DOUBLE |
80 for (int i = 0; i < 16; ++i) { | 80 for (int i = 0; i < 16; ++i) { |
81 dst[i] = SkMScalarToFloat(src[i]); | 81 dst[i] = SkMScalarToFloat(src[i]); |
82 } | 82 } |
83 #elif defined SK_MSCALAR_IS_FLOAT | 83 #elif defined SK_MSCALAR_IS_FLOAT |
84 memcpy(dst, src, 16 * sizeof(float)); | 84 memcpy(dst, src, 16 * sizeof(float)); |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
| 88 void SkMatrix44::as4x3ColMajorf(float dst[]) const { |
| 89 const SkMScalar* src = &fMat[0][0]; |
| 90 #ifdef SK_MSCALAR_IS_DOUBLE |
| 91 for (int i = 0; i < 12; ++i) { |
| 92 dst[i] = SkMScalarToFloat(src[i]); |
| 93 } |
| 94 #elif defined SK_MSCALAR_IS_FLOAT |
| 95 memcpy(dst, src, 12 * sizeof(float)); |
| 96 #endif |
| 97 } |
| 98 |
88 void SkMatrix44::asColMajord(double dst[]) const { | 99 void SkMatrix44::asColMajord(double dst[]) const { |
89 const SkMScalar* src = &fMat[0][0]; | 100 const SkMScalar* src = &fMat[0][0]; |
90 #ifdef SK_MSCALAR_IS_DOUBLE | 101 #ifdef SK_MSCALAR_IS_DOUBLE |
91 memcpy(dst, src, 16 * sizeof(double)); | 102 memcpy(dst, src, 16 * sizeof(double)); |
92 #elif defined SK_MSCALAR_IS_FLOAT | 103 #elif defined SK_MSCALAR_IS_FLOAT |
93 for (int i = 0; i < 16; ++i) { | 104 for (int i = 0; i < 16; ++i) { |
94 dst[i] = SkMScalarToDouble(src[i]); | 105 dst[i] = SkMScalarToDouble(src[i]); |
95 } | 106 } |
96 #endif | 107 #endif |
97 } | 108 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 221 } |
211 | 222 |
212 void SkMatrix44::set3x3ColMajorf(const float src[]) { | 223 void SkMatrix44::set3x3ColMajorf(const float src[]) { |
213 fMat[0][0] = src[0]; fMat[0][1] = src[3]; fMat[0][2] = src[6]; fMat[0][3] =
0; | 224 fMat[0][0] = src[0]; fMat[0][1] = src[3]; fMat[0][2] = src[6]; fMat[0][3] =
0; |
214 fMat[1][0] = src[1]; fMat[1][1] = src[4]; fMat[1][2] = src[7]; fMat[1][3] =
0; | 225 fMat[1][0] = src[1]; fMat[1][1] = src[4]; fMat[1][2] = src[7]; fMat[1][3] =
0; |
215 fMat[2][0] = src[2]; fMat[2][1] = src[5]; fMat[2][2] = src[8]; fMat[2][3] =
0; | 226 fMat[2][0] = src[2]; fMat[2][1] = src[5]; fMat[2][2] = src[8]; fMat[2][3] =
0; |
216 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] =
1; | 227 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] =
1; |
217 this->dirtyTypeMask(); | 228 this->dirtyTypeMask(); |
218 } | 229 } |
219 | 230 |
| 231 void SkMatrix44::set4x3ColMajorf(const float src[]) { |
| 232 fMat[0][0] = src[0]; fMat[0][1] = src[1]; fMat[0][2] = src[2]; fMat[0][3] =
src[3]; |
| 233 fMat[1][0] = src[4]; fMat[1][1] = src[5]; fMat[1][2] = src[6]; fMat[1][3] =
src[7]; |
| 234 fMat[2][0] = src[8]; fMat[2][1] = src[9]; fMat[2][2] = src[10]; fMat[2][3] =
src[11]; |
| 235 fMat[3][0] = 0; fMat[3][1] = 0; fMat[3][2] = 0; fMat[3][3] =
1; |
| 236 this->dirtyTypeMask(); |
| 237 } |
| 238 |
220 /////////////////////////////////////////////////////////////////////////////// | 239 /////////////////////////////////////////////////////////////////////////////// |
221 | 240 |
222 void SkMatrix44::setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz) { | 241 void SkMatrix44::setTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz) { |
223 this->setIdentity(); | 242 this->setIdentity(); |
224 | 243 |
225 if (!dx && !dy && !dz) { | 244 if (!dx && !dy && !dz) { |
226 return; | 245 return; |
227 } | 246 } |
228 | 247 |
229 fMat[3][0] = dx; | 248 fMat[3][0] = dx; |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]); | 1014 dst[SkMatrix::kMSkewY] = SkMScalarToScalar(fMat[0][1]); |
996 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); | 1015 dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); |
997 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); | 1016 dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); |
998 | 1017 |
999 dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]); | 1018 dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]); |
1000 dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]); | 1019 dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]); |
1001 dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]); | 1020 dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]); |
1002 | 1021 |
1003 return dst; | 1022 return dst; |
1004 } | 1023 } |
OLD | NEW |