Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkMatrix.cpp

Issue 2268443002: add SkMatrixPriv for specialized helpers Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkMatrix.h ('k') | src/core/SkMatrixPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | src/core/SkMatrixPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698