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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); | 1112 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
1113 Sk4f min = Sk4f::Min(ltrb, rblt); | 1113 Sk4f min = Sk4f::Min(ltrb, rblt); |
1114 Sk4f max = Sk4f::Max(ltrb, rblt); | 1114 Sk4f max = Sk4f::Max(ltrb, rblt); |
1115 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on | 1115 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on |
1116 // ARM this sequence generates the fastest (a single instruction). | 1116 // ARM this sequence generates the fastest (a single instruction). |
1117 SkRect dst; | 1117 SkRect dst; |
1118 Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft); | 1118 Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft); |
1119 return dst; | 1119 return dst; |
1120 } | 1120 } |
1121 | 1121 |
| 1122 SkRect SkMatrix::mapRectScaleTranslate(SkRect src) const { |
| 1123 SkASSERT(this->isScaleTranslate()); |
| 1124 |
| 1125 SkScalar sx = fMat[kMScaleX]; |
| 1126 SkScalar sy = fMat[kMScaleY]; |
| 1127 SkScalar tx = fMat[kMTransX]; |
| 1128 SkScalar ty = fMat[kMTransY]; |
| 1129 Sk4f scale(sx, sy, sx, sy); |
| 1130 Sk4f trans(tx, ty, tx, ty); |
| 1131 |
| 1132 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; |
| 1133 // need to sort so we're not inverted |
| 1134 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); |
| 1135 Sk4f min = Sk4f::Min(ltrb, rblt); |
| 1136 Sk4f max = Sk4f::Max(ltrb, rblt); |
| 1137 // We can extract either pair [0,1] or [2,3] from min and max and be correct
, but on |
| 1138 // ARM this sequence generates the fastest (a single instruction). |
| 1139 SkRect dst; |
| 1140 Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft); |
| 1141 return dst; |
| 1142 } |
| 1143 |
1122 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { | 1144 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { |
1123 SkASSERT(dst); | 1145 SkASSERT(dst); |
1124 | 1146 |
1125 if (this->isScaleTranslate()) { | 1147 if (this->isScaleTranslate()) { |
1126 *dst = this->mapRectScaleTranslate(src); | 1148 *dst = this->mapRectScaleTranslate(src); |
1127 return true; | 1149 return true; |
1128 } else { | 1150 } else { |
1129 SkPoint quad[4]; | 1151 SkPoint quad[4]; |
1130 | 1152 |
1131 src.toQuad(quad); | 1153 src.toQuad(quad); |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 const SkScalar m10 = -m01; | 1900 const SkScalar m10 = -m01; |
1879 const SkScalar m11 = m00; | 1901 const SkScalar m11 = m00; |
1880 const SkScalar m12 = fTy; | 1902 const SkScalar m12 = fTy; |
1881 | 1903 |
1882 quad[0].set(m02, m12); | 1904 quad[0].set(m02, m12); |
1883 quad[1].set(m00 * width + m02, m10 * width + m12); | 1905 quad[1].set(m00 * width + m02, m10 * width + m12); |
1884 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); | 1906 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
12); |
1885 quad[3].set(m01 * height + m02, m11 * height + m12); | 1907 quad[3].set(m01 * height + m02, m11 * height + m12); |
1886 #endif | 1908 #endif |
1887 } | 1909 } |
OLD | NEW |