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 "SkFloatBits.h" | 8 #include "SkFloatBits.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } else { | 283 } else { |
284 this->reset(); | 284 this->reset(); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void SkMatrix::preTranslate(SkScalar dx, SkScalar dy) { | 288 void SkMatrix::preTranslate(SkScalar dx, SkScalar dy) { |
289 if (!dx && !dy) { | 289 if (!dx && !dy) { |
290 return; | 290 return; |
291 } | 291 } |
292 | 292 |
293 if (fTypeMask <= kTranslate_Mask) { | 293 if (this->hasPerspective()) { |
294 fMat[kMTransX] += dx; | |
295 fMat[kMTransY] += dy; | |
296 this->setTypeMask((fMat[kMTransX] != 0 || fMat[kMTransY] != 0) ? kTransl
ate_Mask | |
297 : kIdenti
ty_Mask); | |
298 } else if (this->hasPerspective()) { | |
299 SkMatrix m; | 294 SkMatrix m; |
300 m.setTranslate(dx, dy); | 295 m.setTranslate(dx, dy); |
301 this->preConcat(m); | 296 this->preConcat(m); |
302 } else { | 297 } else { |
303 fMat[kMTransX] += sdot(fMat[kMScaleX], dx, fMat[kMSkewX], dy); | 298 fMat[kMTransX] += sdot(fMat[kMScaleX], dx, fMat[kMSkewX], dy); |
304 fMat[kMTransY] += sdot(fMat[kMSkewY], dx, fMat[kMScaleY], dy); | 299 fMat[kMTransY] += sdot(fMat[kMSkewY], dx, fMat[kMScaleY], dy); |
305 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); | 300 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
306 } | 301 } |
307 } | 302 } |
308 | 303 |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1093 |
1099 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; | 1094 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; |
1100 tmp.clearTypeMask(kTranslate_Mask); | 1095 tmp.clearTypeMask(kTranslate_Mask); |
1101 tmp.mapPoints(dst, src, count); | 1096 tmp.mapPoints(dst, src, count); |
1102 } | 1097 } |
1103 } | 1098 } |
1104 | 1099 |
1105 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { | 1100 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
1106 SkASSERT(dst); | 1101 SkASSERT(dst); |
1107 SkASSERT(this->isScaleTranslate()); | 1102 SkASSERT(this->isScaleTranslate()); |
1108 | 1103 |
1109 SkScalar sx = fMat[kMScaleX]; | 1104 SkScalar sx = fMat[kMScaleX]; |
1110 SkScalar sy = fMat[kMScaleY]; | 1105 SkScalar sy = fMat[kMScaleY]; |
1111 SkScalar tx = fMat[kMTransX]; | 1106 SkScalar tx = fMat[kMTransX]; |
1112 SkScalar ty = fMat[kMTransY]; | 1107 SkScalar ty = fMat[kMTransY]; |
1113 Sk4f scale(sx, sy, sx, sy); | 1108 Sk4f scale(sx, sy, sx, sy); |
1114 Sk4f trans(tx, ty, tx, ty); | 1109 Sk4f trans(tx, ty, tx, ty); |
1115 | 1110 |
1116 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; | 1111 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; |
1117 // need to sort so we're not inverted | 1112 // need to sort so we're not inverted |
1118 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); | 1113 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 const SkScalar m10 = -m01; | 1886 const SkScalar m10 = -m01; |
1892 const SkScalar m11 = m00; | 1887 const SkScalar m11 = m00; |
1893 const SkScalar m12 = fTy; | 1888 const SkScalar m12 = fTy; |
1894 | 1889 |
1895 quad[0].set(m02, m12); | 1890 quad[0].set(m02, m12); |
1896 quad[1].set(m00 * width + m02, m10 * width + m12); | 1891 quad[1].set(m00 * width + m02, m10 * width + m12); |
1897 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); | 1892 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); |
1898 quad[3].set(m01 * height + m02, m11 * height + m12); | 1893 quad[3].set(m01 * height + m02, m11 * height + m12); |
1899 #endif | 1894 #endif |
1900 } | 1895 } |
OLD | NEW |