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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } | 1095 } |
1096 } else { | 1096 } else { |
1097 SkMatrix tmp = *this; | 1097 SkMatrix tmp = *this; |
1098 | 1098 |
1099 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; | 1099 tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0; |
1100 tmp.clearTypeMask(kTranslate_Mask); | 1100 tmp.clearTypeMask(kTranslate_Mask); |
1101 tmp.mapPoints(dst, src, count); | 1101 tmp.mapPoints(dst, src, count); |
1102 } | 1102 } |
1103 } | 1103 } |
1104 | 1104 |
| 1105 static Sk4f sort_as_rect(const Sk4f& ltrb) { |
| 1106 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
| 1107 Sk4f min = Sk4f::Min(ltrb, rblt); |
| 1108 Sk4f max = Sk4f::Max(ltrb, rblt); |
| 1109 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on |
| 1110 // ARM this sequence generates the fastest (a single instruction). |
| 1111 return Sk4f(min[2], min[3], max[0], max[1]); |
| 1112 } |
| 1113 |
1105 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { | 1114 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const { |
1106 SkASSERT(dst); | 1115 SkASSERT(dst); |
1107 SkASSERT(this->isScaleTranslate()); | 1116 SkASSERT(this->isScaleTranslate()); |
1108 | 1117 |
1109 SkScalar sx = fMat[kMScaleX]; | 1118 SkScalar sx = fMat[kMScaleX]; |
1110 SkScalar sy = fMat[kMScaleY]; | 1119 SkScalar sy = fMat[kMScaleY]; |
1111 SkScalar tx = fMat[kMTransX]; | 1120 SkScalar tx = fMat[kMTransX]; |
1112 SkScalar ty = fMat[kMTransY]; | 1121 SkScalar ty = fMat[kMTransY]; |
1113 Sk4f scale(sx, sy, sx, sy); | 1122 Sk4f scale(sx, sy, sx, sy); |
1114 Sk4f trans(tx, ty, tx, ty); | 1123 Sk4f trans(tx, ty, tx, ty); |
1115 | 1124 sort_as_rect(Sk4f::Load(&src.fLeft) * scale + trans).store(&dst->fLeft); |
1116 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; | |
1117 // need to sort so we're not inverted | |
1118 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); | |
1119 Sk4f min = Sk4f::Min(ltrb, rblt); | |
1120 Sk4f max = Sk4f::Max(ltrb, rblt); | |
1121 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on | |
1122 // ARM this sequence generates the fastest (a single instruction). | |
1123 Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft); | |
1124 } | 1125 } |
1125 | 1126 |
1126 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { | 1127 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { |
1127 SkASSERT(dst); | 1128 SkASSERT(dst); |
1128 | 1129 |
| 1130 if (this->getType() <= kTranslate_Mask) { |
| 1131 SkScalar tx = fMat[kMTransX]; |
| 1132 SkScalar ty = fMat[kMTransY]; |
| 1133 Sk4f trans(tx, ty, tx, ty); |
| 1134 sort_as_rect(Sk4f::Load(&src.fLeft) + trans).store(&dst->fLeft); |
| 1135 return true; |
| 1136 } |
1129 if (this->isScaleTranslate()) { | 1137 if (this->isScaleTranslate()) { |
1130 this->mapRectScaleTranslate(dst, src); | 1138 this->mapRectScaleTranslate(dst, src); |
1131 return true; | 1139 return true; |
1132 } else { | 1140 } else { |
1133 SkPoint quad[4]; | 1141 SkPoint quad[4]; |
1134 | 1142 |
1135 src.toQuad(quad); | 1143 src.toQuad(quad); |
1136 this->mapPoints(quad, quad, 4); | 1144 this->mapPoints(quad, quad, 4); |
1137 dst->set(quad, 4); | 1145 dst->set(quad, 4); |
1138 return false; | 1146 return false; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 const SkScalar m10 = -m01; | 1899 const SkScalar m10 = -m01; |
1892 const SkScalar m11 = m00; | 1900 const SkScalar m11 = m00; |
1893 const SkScalar m12 = fTy; | 1901 const SkScalar m12 = fTy; |
1894 | 1902 |
1895 quad[0].set(m02, m12); | 1903 quad[0].set(m02, m12); |
1896 quad[1].set(m00 * width + m02, m10 * width + m12); | 1904 quad[1].set(m00 * width + m02, m10 * width + m12); |
1897 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); | 1905 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); |
1898 quad[3].set(m01 * height + m02, m11 * height + m12); | 1906 quad[3].set(m01 * height + m02, m11 * height + m12); |
1899 #endif | 1907 #endif |
1900 } | 1908 } |
OLD | NEW |