Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: src/core/SkMatrix.cpp

Issue 22816005: Add homogeneous point mapping to Matrix (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts, 1211 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts,
1212 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts, 1212 SkMatrix::Rot_pts, SkMatrix::RotTrans_pts,
1213 // repeat the persp proc 8 times 1213 // repeat the persp proc 8 times
1214 SkMatrix::Persp_pts, SkMatrix::Persp_pts, 1214 SkMatrix::Persp_pts, SkMatrix::Persp_pts,
1215 SkMatrix::Persp_pts, SkMatrix::Persp_pts, 1215 SkMatrix::Persp_pts, SkMatrix::Persp_pts,
1216 SkMatrix::Persp_pts, SkMatrix::Persp_pts, 1216 SkMatrix::Persp_pts, SkMatrix::Persp_pts,
1217 SkMatrix::Persp_pts, SkMatrix::Persp_pts 1217 SkMatrix::Persp_pts, SkMatrix::Persp_pts
1218 }; 1218 };
1219 1219
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) || 0 == count);
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::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int co unt) const {
1231 SkASSERT((dst && src && count > 0) || 0 == count);
1232 // no partial overlap
1233 SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= 3*count);
1234
1235 if (count > 0) {
1236 if (this->isIdentity()) {
1237 memcpy(dst, src, 3*count*sizeof(SkScalar));
1238 return;
1239 }
1240 do {
1241 SkScalar sx = src[0];
1242 SkScalar sy = src[1];
1243 SkScalar sw = src[2];
1244 src += 3;
1245
1246 SkScalar x = SkScalarMul(sx, fMat[kMScaleX]) +
1247 SkScalarMul(sy, fMat[kMSkewX]) +
1248 SkScalarMul(sw, fMat[kMTransX]);
1249 SkScalar y = SkScalarMul(sx, fMat[kMSkewY]) +
1250 SkScalarMul(sy, fMat[kMScaleY]) +
1251 SkScalarMul(sw, fMat[kMTransY]);
1252 SkScalar w = SkScalarMul(sx, fMat[kMPersp0]) +
1253 SkScalarMul(sy, fMat[kMPersp1]) +
1254 SkScalarMul(sw, fMat[kMPersp2]);
1255
1256 dst[0] = x;
1257 dst[1] = y;
1258 dst[2] = w;
1259 dst += 3;
1260 } while (--count);
1261 }
1262 }
1263
1264 ///////////////////////////////////////////////////////////////////////////////
1265
1230 void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { 1266 void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
1231 if (this->hasPerspective()) { 1267 if (this->hasPerspective()) {
1232 SkPoint origin; 1268 SkPoint origin;
1233 1269
1234 MapXYProc proc = this->getMapXYProc(); 1270 MapXYProc proc = this->getMapXYProc();
1235 proc(*this, 0, 0, &origin); 1271 proc(*this, 0, 0, &origin);
1236 1272
1237 for (int i = count - 1; i >= 0; --i) { 1273 for (int i = count - 1; i >= 0; --i) {
1238 SkPoint tmp; 1274 SkPoint tmp;
1239 1275
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 } 2084 }
2049 if (NULL != rotation0) { 2085 if (NULL != rotation0) {
2050 *rotation0 = r0; 2086 *rotation0 = r0;
2051 } 2087 }
2052 if (NULL != rotation1) { 2088 if (NULL != rotation1) {
2053 *rotation1 = r1; 2089 *rotation1 = r1;
2054 } 2090 }
2055 2091
2056 return true; 2092 return true;
2057 } 2093 }
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698