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