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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 } | 1090 } |
1091 } else { | 1091 } else { |
1092 SkMatrix tmp = *this; | 1092 SkMatrix tmp = *this; |
1093 | 1093 |
1094 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; | 1094 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; |
1095 tmp.clearTypeMask(kTranslate_Mask); | 1095 tmp.clearTypeMask(kTranslate_Mask); |
1096 tmp.mapPoints(dst, src, count); | 1096 tmp.mapPoints(dst, src, count); |
1097 } | 1097 } |
1098 } | 1098 } |
1099 | 1099 |
| 1100 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
| 1101 SkASSERT(dst); |
| 1102 SkASSERT(this->isScaleTranslate()); |
| 1103 |
| 1104 SkScalar sx = fMat[kMScaleX]; |
| 1105 SkScalar sy = fMat[kMScaleY]; |
| 1106 SkScalar tx = fMat[kMTransX]; |
| 1107 SkScalar ty = fMat[kMTransY]; |
| 1108 Sk4f scale(sx, sy, sx, sy); |
| 1109 Sk4f trans(tx, ty, tx, ty); |
| 1110 |
| 1111 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; |
| 1112 // need to sort so we're not inverted |
| 1113 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
| 1114 Sk4f min = Sk4f::Min(ltrb, rblt); |
| 1115 Sk4f max = Sk4f::Max(ltrb, rblt); |
| 1116 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on |
| 1117 // ARM this sequence generates the fastest (a single instruction). |
| 1118 Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft); |
| 1119 } |
| 1120 |
1100 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { | 1121 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { |
1101 SkASSERT(dst); | 1122 SkASSERT(dst); |
1102 | 1123 |
1103 if (this->rectStaysRect()) { | 1124 if (this->isScaleTranslate()) { |
1104 this->mapPoints((SkPoint*)dst, (const SkPoint*)&src, 2); | 1125 this->mapRectScaleTranslate(dst, src); |
1105 dst->sort(); | |
1106 return true; | 1126 return true; |
1107 } else { | 1127 } else { |
1108 SkPoint quad[4]; | 1128 SkPoint quad[4]; |
1109 | 1129 |
1110 src.toQuad(quad); | 1130 src.toQuad(quad); |
1111 this->mapPoints(quad, quad, 4); | 1131 this->mapPoints(quad, quad, 4); |
1112 dst->set(quad, 4); | 1132 dst->set(quad, 4); |
1113 return false; | 1133 return false; |
1114 } | 1134 } |
1115 } | 1135 } |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 const SkScalar m10 = -m01; | 1877 const SkScalar m10 = -m01; |
1858 const SkScalar m11 = m00; | 1878 const SkScalar m11 = m00; |
1859 const SkScalar m12 = fTy; | 1879 const SkScalar m12 = fTy; |
1860 | 1880 |
1861 quad[0].set(m02, m12); | 1881 quad[0].set(m02, m12); |
1862 quad[1].set(m00 * width + m02, m10 * width + m12); | 1882 quad[1].set(m00 * width + m02, m10 * width + m12); |
1863 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); | 1883 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); |
1864 quad[3].set(m01 * height + m02, m11 * height + m12); | 1884 quad[3].set(m01 * height + m02, m11 * height + m12); |
1865 #endif | 1885 #endif |
1866 } | 1886 } |
OLD | NEW |