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

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

Issue 2234843002: Revert of Change mapRectScaleTranslate to pass args/ret by value (Closed) 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 | « src/core/SkCanvas.cpp ('k') | src/utils/SkDeferredCanvas.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 SkRect SkMatrix::mapRectScaleTranslate(SkRect src) const { 1100 void SkMatrix::mapRectScaleTranslate(SkRect* dst, const SkRect& src) const {
1101 SkASSERT(dst);
1101 SkASSERT(this->isScaleTranslate()); 1102 SkASSERT(this->isScaleTranslate());
1102 1103
1103 SkScalar sx = fMat[kMScaleX]; 1104 SkScalar sx = fMat[kMScaleX];
1104 SkScalar sy = fMat[kMScaleY]; 1105 SkScalar sy = fMat[kMScaleY];
1105 SkScalar tx = fMat[kMTransX]; 1106 SkScalar tx = fMat[kMTransX];
1106 SkScalar ty = fMat[kMTransY]; 1107 SkScalar ty = fMat[kMTransY];
1107 Sk4f scale(sx, sy, sx, sy); 1108 Sk4f scale(sx, sy, sx, sy);
1108 Sk4f trans(tx, ty, tx, ty); 1109 Sk4f trans(tx, ty, tx, ty);
1109 1110
1110 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans; 1111 Sk4f ltrb = Sk4f::Load(&src.fLeft) * scale + trans;
1111 // need to sort so we're not inverted 1112 // need to sort so we're not inverted
1112 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]); 1113 Sk4f rblt(ltrb[2], ltrb[3], ltrb[0], ltrb[1]);
1113 Sk4f min = Sk4f::Min(ltrb, rblt); 1114 Sk4f min = Sk4f::Min(ltrb, rblt);
1114 Sk4f max = Sk4f::Max(ltrb, rblt); 1115 Sk4f max = Sk4f::Max(ltrb, rblt);
1115 // We can extract either pair [0,1] or [2,3] from min and max and be correct . 1116 // We can extract either pair [0,1] or [2,3] from min and max and be correct , but on
1116 // However, the current ABI for returning multiple floats is to use only 2 s lots in each 1117 // ARM this sequence generates the fastest (a single instruction).
1117 // vector register. Thus we take [0..1] from min and max, as that perfectly matches the ABI. 1118 Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft);
1118 SkRect dst;
1119 Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft);
1120 return dst;
1121 } 1119 }
1122 1120
1123 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { 1121 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const {
1124 SkASSERT(dst); 1122 SkASSERT(dst);
1125 1123
1126 if (this->isScaleTranslate()) { 1124 if (this->isScaleTranslate()) {
1127 *dst = this->mapRectScaleTranslate(src); 1125 this->mapRectScaleTranslate(dst, src);
1128 return true; 1126 return true;
1129 } else { 1127 } else {
1130 SkPoint quad[4]; 1128 SkPoint quad[4];
1131 1129
1132 src.toQuad(quad); 1130 src.toQuad(quad);
1133 this->mapPoints(quad, quad, 4); 1131 this->mapPoints(quad, quad, 4);
1134 dst->set(quad, 4); 1132 dst->set(quad, 4);
1135 return false; 1133 return false;
1136 } 1134 }
1137 } 1135 }
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 const SkScalar m10 = -m01; 1886 const SkScalar m10 = -m01;
1889 const SkScalar m11 = m00; 1887 const SkScalar m11 = m00;
1890 const SkScalar m12 = fTy; 1888 const SkScalar m12 = fTy;
1891 1889
1892 quad[0].set(m02, m12); 1890 quad[0].set(m02, m12);
1893 quad[1].set(m00 * width + m02, m10 * width + m12); 1891 quad[1].set(m00 * width + m02, m10 * width + m12);
1894 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1892 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1895 quad[3].set(m01 * height + m02, m11 * height + m12); 1893 quad[3].set(m01 * height + m02, m11 * height + m12);
1896 #endif 1894 #endif
1897 } 1895 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698