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

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

Issue 2111703002: speed up maprect for scale+trans case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test on nexus_7 Created 4 years, 5 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') | tests/MatrixTest.cpp » ('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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 #if 1
mtklein 2016/06/30 13:15:39 You're saying this enabled #if case is faster than
reed1 2016/06/30 13:20:51 Done.
1105 SkScalar sx = fMat[kMScaleX];
1106 SkScalar sy = fMat[kMScaleY];
1107 SkScalar tx = fMat[kMTransX];
1108 SkScalar ty = fMat[kMTransY];
1109 Sk4f scale(sx, sy, sx, sy);
1110 Sk4f trans(tx, ty, tx, ty);
1111 #else
1112 Sk4f a = Sk4f::Load(&fMat[0]);
1113 Sk4f b = Sk4f::Load(&fMat[4]);
1114 Sk4f scale(a[0], b[0], a[0], b[0]);
1115 Sk4f trans(a[2], b[1], a[2], b[1]);
1116 #endif
1117
1118 Sk4f result = Sk4f::Load(&src.fLeft) * scale + trans;
mtklein 2016/06/30 13:15:39 I'd personally rename result to ltrb and flipped t
reed1 2016/06/30 13:20:51 Done.
1119 // need to sort so we're not inverted
1120 Sk4f flipped(result[2], result[3], result[0], result[1]);
1121 Sk4f min = Sk4f::Min(result, flipped);
1122 Sk4f max = Sk4f::Max(result, flipped);
1123 Sk4f(min[0], min[1], max[0], max[1]).store(&dst->fLeft);
1124 }
1125
1100 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { 1126 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const {
1101 SkASSERT(dst); 1127 SkASSERT(dst);
1102 1128
1103 if (this->rectStaysRect()) { 1129 if (this->isScaleTranslate()) {
1104 this->mapPoints((SkPoint*)dst, (const SkPoint*)&src, 2); 1130 this->mapRectScaleTranslate(dst, src);
1105 dst->sort();
1106 return true; 1131 return true;
1107 } else { 1132 } else {
1108 SkPoint quad[4]; 1133 SkPoint quad[4];
1109 1134
1110 src.toQuad(quad); 1135 src.toQuad(quad);
1111 this->mapPoints(quad, quad, 4); 1136 this->mapPoints(quad, quad, 4);
1112 dst->set(quad, 4); 1137 dst->set(quad, 4);
1113 return false; 1138 return false;
1114 } 1139 }
1115 } 1140 }
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 const SkScalar m10 = -m01; 1882 const SkScalar m10 = -m01;
1858 const SkScalar m11 = m00; 1883 const SkScalar m11 = m00;
1859 const SkScalar m12 = fTy; 1884 const SkScalar m12 = fTy;
1860 1885
1861 quad[0].set(m02, m12); 1886 quad[0].set(m02, m12);
1862 quad[1].set(m00 * width + m02, m10 * width + m12); 1887 quad[1].set(m00 * width + m02, m10 * width + m12);
1863 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1888 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1864 quad[3].set(m01 * height + m02, m11 * height + m12); 1889 quad[3].set(m01 * height + m02, m11 * height + m12);
1865 #endif 1890 #endif
1866 } 1891 }
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698