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 "Sk64.h" | 9 #include "Sk64.h" |
10 #include "SkFloatBits.h" | 10 #include "SkFloatBits.h" |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const { | 1220 void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const { |
1221 SkASSERT((dst && src && count > 0) || count == 0); | 1221 SkASSERT((dst && src && count > 0) || count == 0); |
1222 // no partial overlap | 1222 // no partial overlap |
1223 SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= count); | 1223 SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= count); |
1224 | 1224 |
1225 this->getMapPtsProc()(*this, dst, src, count); | 1225 this->getMapPtsProc()(*this, dst, src, count); |
1226 } | 1226 } |
1227 | 1227 |
1228 /////////////////////////////////////////////////////////////////////////////// | 1228 /////////////////////////////////////////////////////////////////////////////// |
1229 | 1229 |
| 1230 void SkMatrix::Homogeneous_pts(const SkMatrix& m, SkScalar dst[], |
| 1231 const SkScalar src[], int count) { |
| 1232 if (count > 0) { |
| 1233 do { |
| 1234 SkScalar sx = src[0]; |
| 1235 SkScalar sy = src[1]; |
| 1236 SkScalar sw = src[2]; |
| 1237 src += 3; |
| 1238 |
| 1239 SkScalar x = SkScalarMul(sx, m.fMat[kMScaleX]) + |
| 1240 SkScalarMul(sy, m.fMat[kMSkewX]) + |
| 1241 SkScalarMul(sw, m.fMat[kMTransX]); |
| 1242 SkScalar y = SkScalarMul(sx, m.fMat[kMSkewY]) + |
| 1243 SkScalarMul(sy, m.fMat[kMScaleY]) + |
| 1244 SkScalarMul(sw, m.fMat[kMTransY]); |
| 1245 SkScalar w = SkScalarMul(sx, m.fMat[kMPersp0]) + |
| 1246 SkScalarMul(sy, m.fMat[kMPersp1]) + |
| 1247 SkScalarMul(sw, m.fMat[kMPersp2]); |
| 1248 |
| 1249 dst[0] = x; |
| 1250 dst[1] = y; |
| 1251 dst[2] = w; |
| 1252 dst += 3; |
| 1253 } while (--count); |
| 1254 } |
| 1255 } |
| 1256 |
| 1257 void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int co
unt) const { |
| 1258 SkASSERT((dst && src && count > 0) || count == 0); |
| 1259 // no partial overlap |
| 1260 SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= 3*count); |
| 1261 |
| 1262 SkMatrix::Homogeneous_pts(*this, dst, src, count); |
| 1263 } |
| 1264 |
| 1265 /////////////////////////////////////////////////////////////////////////////// |
| 1266 |
1230 void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { | 1267 void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { |
1231 if (this->hasPerspective()) { | 1268 if (this->hasPerspective()) { |
1232 SkPoint origin; | 1269 SkPoint origin; |
1233 | 1270 |
1234 MapXYProc proc = this->getMapXYProc(); | 1271 MapXYProc proc = this->getMapXYProc(); |
1235 proc(*this, 0, 0, &origin); | 1272 proc(*this, 0, 0, &origin); |
1236 | 1273 |
1237 for (int i = count - 1; i >= 0; --i) { | 1274 for (int i = count - 1; i >= 0; --i) { |
1238 SkPoint tmp; | 1275 SkPoint tmp; |
1239 | 1276 |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 } | 2085 } |
2049 if (NULL != rotation0) { | 2086 if (NULL != rotation0) { |
2050 *rotation0 = r0; | 2087 *rotation0 = r0; |
2051 } | 2088 } |
2052 if (NULL != rotation1) { | 2089 if (NULL != rotation1) { |
2053 *rotation1 = r1; | 2090 *rotation1 = r1; |
2054 } | 2091 } |
2055 | 2092 |
2056 return true; | 2093 return true; |
2057 } | 2094 } |
OLD | NEW |