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

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

Issue 1692013002: Change SkMatrix::fixedStepInX to return SkVector rather than SkFixed. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Split fixedStepInX into bool isFixedStepInX and SkVector fixedStepInX. Created 4 years, 10 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/SkShader.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 "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkFloatBits.h" 9 #include "SkFloatBits.h"
10 #include "SkRSXform.h" 10 #include "SkRSXform.h"
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 SkMatrix::Persp_xy, SkMatrix::Persp_xy, 1143 SkMatrix::Persp_xy, SkMatrix::Persp_xy,
1144 SkMatrix::Persp_xy, SkMatrix::Persp_xy, 1144 SkMatrix::Persp_xy, SkMatrix::Persp_xy,
1145 SkMatrix::Persp_xy, SkMatrix::Persp_xy 1145 SkMatrix::Persp_xy, SkMatrix::Persp_xy
1146 }; 1146 };
1147 1147
1148 /////////////////////////////////////////////////////////////////////////////// 1148 ///////////////////////////////////////////////////////////////////////////////
1149 1149
1150 // if its nearly zero (just made up 26, perhaps it should be bigger or smaller) 1150 // if its nearly zero (just made up 26, perhaps it should be bigger or smaller)
1151 #define PerspNearlyZero(x) SkScalarNearlyZero(x, (1.0f / (1 << 26))) 1151 #define PerspNearlyZero(x) SkScalarNearlyZero(x, (1.0f / (1 << 26)))
1152 1152
1153 bool SkMatrix::fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const { 1153 bool SkMatrix::isFixedStepInX() const {
1154 if (PerspNearlyZero(fMat[kMPersp0])) { 1154 return PerspNearlyZero(fMat[kMPersp0]);
1155 if (stepX || stepY) { 1155 }
1156 if (PerspNearlyZero(fMat[kMPersp1]) && 1156
1157 PerspNearlyZero(fMat[kMPersp2] - 1)) { 1157 SkVector SkMatrix::fixedStepInX(SkScalar y) const {
1158 if (stepX) { 1158 SkASSERT(PerspNearlyZero(fMat[kMPersp0]));
1159 *stepX = SkScalarToFixed(fMat[kMScaleX]); 1159 if (PerspNearlyZero(fMat[kMPersp1]) &&
1160 } 1160 PerspNearlyZero(fMat[kMPersp2] - 1)) {
1161 if (stepY) { 1161 return SkVector::Make(fMat[kMScaleX], fMat[kMSkewY]);
1162 *stepY = SkScalarToFixed(fMat[kMSkewY]); 1162 } else {
1163 } 1163 SkScalar z = y * fMat[kMPersp1] + fMat[kMPersp2];
1164 } else { 1164 return SkVector::Make(fMat[kMScaleX] / z, fMat[kMSkewY] / z);
1165 SkScalar z = y * fMat[kMPersp1] + fMat[kMPersp2];
1166 if (stepX) {
1167 *stepX = SkScalarToFixed(fMat[kMScaleX] / z);
1168 }
1169 if (stepY) {
1170 *stepY = SkScalarToFixed(fMat[kMSkewY] / z);
1171 }
1172 }
1173 }
1174 return true;
1175 } 1165 }
1176 return false;
1177 } 1166 }
1178 1167
1179 /////////////////////////////////////////////////////////////////////////////// 1168 ///////////////////////////////////////////////////////////////////////////////
1180 1169
1181 #include "SkPerspIter.h" 1170 #include "SkPerspIter.h"
1182 1171
1183 SkPerspIter::SkPerspIter(const SkMatrix& m, SkScalar x0, SkScalar y0, int count) 1172 SkPerspIter::SkPerspIter(const SkMatrix& m, SkScalar x0, SkScalar y0, int count)
1184 : fMatrix(m), fSX(x0), fSY(y0), fCount(count) { 1173 : fMatrix(m), fSX(x0), fSY(y0), fCount(count) {
1185 SkPoint pt; 1174 SkPoint pt;
1186 1175
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 const SkScalar m10 = -m01; 1782 const SkScalar m10 = -m01;
1794 const SkScalar m11 = m00; 1783 const SkScalar m11 = m00;
1795 const SkScalar m12 = fTy; 1784 const SkScalar m12 = fTy;
1796 1785
1797 quad[0].set(m02, m12); 1786 quad[0].set(m02, m12);
1798 quad[1].set(m00 * width + m02, m10 * width + m12); 1787 quad[1].set(m00 * width + m02, m10 * width + m12);
1799 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1788 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1800 quad[3].set(m01 * height + m02, m11 * height + m12); 1789 quad[3].set(m01 * height + m02, m11 * height + m12);
1801 #endif 1790 #endif
1802 } 1791 }
1803
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | src/core/SkShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698