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

Unified Diff: src/utils/SkMatrix44.cpp

Issue 50423004: Remove SkMatrix44 float conversions without precision loss (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: One more SkMScalarToFloat Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkMatrix44.cpp
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index 37ab8db27f08ee89a71a9376e0b5acb6caf5cb7a..440bf36b62e8cefec9fed415673b48a1be03ae71 100644
--- a/src/utils/SkMatrix44.cpp
+++ b/src/utils/SkMatrix44.cpp
@@ -229,14 +229,8 @@ void SkMatrix44::preTranslate(SkMScalar dx, SkMScalar dy, SkMScalar dz) {
return;
}
- const double X = SkMScalarToDouble(dx);
- const double Y = SkMScalarToDouble(dy);
- const double Z = SkMScalarToDouble(dz);
-
- double tmp;
for (int i = 0; i < 4; ++i) {
- tmp = fMat[0][i] * X + fMat[1][i] * Y + fMat[2][i] * Z + fMat[3][i];
- fMat[3][i] = SkDoubleToMScalar(tmp);
+ fMat[3][i] = fMat[0][i] * dx + fMat[1][i] * dy + fMat[2][i] * dz + fMat[3][i];
}
this->dirtyTypeMask();
}
@@ -783,10 +777,10 @@ static void map2_sd(const SkMScalar mat[][4], const double* SK_RESTRICT src2,
static void map2_af(const SkMScalar mat[][4], const float* SK_RESTRICT src2,
int count, float* SK_RESTRICT dst4) {
- double r;
+ SkMScalar r;
for (int n = 0; n < count; ++n) {
- double sx = src2[0];
- double sy = src2[1];
+ SkMScalar sx = SkFloatToMScalar(src2[0]);
+ SkMScalar sy = SkFloatToMScalar(src2[1]);
r = mat[0][0] * sx + mat[1][0] * sy + mat[3][0];
dst4[0] = SkMScalarToFloat(r);
r = mat[0][1] * sx + mat[1][1] * sy + mat[3][1];
@@ -815,14 +809,13 @@ static void map2_ad(const SkMScalar mat[][4], const double* SK_RESTRICT src2,
static void map2_pf(const SkMScalar mat[][4], const float* SK_RESTRICT src2,
int count, float* SK_RESTRICT dst4) {
+ SkMScalar r;
for (int n = 0; n < count; ++n) {
- float sx = src2[0];
- float sy = src2[1];
+ SkMScalar sx = SkFloatToMScalar(src2[0]);
+ SkMScalar sy = SkFloatToMScalar(src2[1]);
for (int i = 0; i < 4; i++) {
- dst4[i] =
- SkMScalarToFloat(mat[0][i]) * sx +
- SkMScalarToFloat(mat[1][i]) * sy +
- SkMScalarToFloat(mat[3][i]);
+ r = mat[0][i] * sx + mat[1][i] * sy + mat[3][i];
+ dst4[i] = SkMScalarToFloat(r);
}
src2 += 2;
dst4 += 4;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698