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

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

Issue 2139523002: 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, 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 | « 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 , but on 1116 // 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). 1117 // ARM this sequence generates the fastest (a single instruction).
1117 SkRect dst; 1118 Sk4f(min[2], min[3], max[0], max[1]).store(&dst->fLeft);
1118 Sk4f(min[0], min[1], max[0], max[1]).store(&dst.fLeft);
1119 return dst;
1120 } 1119 }
1121 1120
1122 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const { 1121 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src) const {
1123 SkASSERT(dst); 1122 SkASSERT(dst);
1124 1123
1125 if (this->isScaleTranslate()) { 1124 if (this->isScaleTranslate()) {
1126 *dst = this->mapRectScaleTranslate(src); 1125 this->mapRectScaleTranslate(dst, src);
1127 return true; 1126 return true;
1128 } else { 1127 } else {
1129 SkPoint quad[4]; 1128 SkPoint quad[4];
1130 1129
1131 src.toQuad(quad); 1130 src.toQuad(quad);
1132 this->mapPoints(quad, quad, 4); 1131 this->mapPoints(quad, quad, 4);
1133 dst->set(quad, 4); 1132 dst->set(quad, 4);
1134 return false; 1133 return false;
1135 } 1134 }
1136 } 1135 }
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 const SkScalar m10 = -m01; 1877 const SkScalar m10 = -m01;
1879 const SkScalar m11 = m00; 1878 const SkScalar m11 = m00;
1880 const SkScalar m12 = fTy; 1879 const SkScalar m12 = fTy;
1881 1880
1882 quad[0].set(m02, m12); 1881 quad[0].set(m02, m12);
1883 quad[1].set(m00 * width + m02, m10 * width + m12); 1882 quad[1].set(m00 * width + m02, m10 * width + m12);
1884 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1883 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1885 quad[3].set(m01 * height + m02, m11 * height + m12); 1884 quad[3].set(m01 * height + m02, m11 * height + m12);
1886 #endif 1885 #endif
1887 } 1886 }
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