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

Unified Diff: src/utils/SkCamera.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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
Index: src/utils/SkCamera.cpp
diff --git a/src/utils/SkCamera.cpp b/src/utils/SkCamera.cpp
index f5b51d52595deaf7200d7e7b71f63451e5afb3ad..2e2031e386cc4d33e9b9f21aa491b9aabb974229 100644
--- a/src/utils/SkCamera.cpp
+++ b/src/utils/SkCamera.cpp
@@ -12,7 +12,6 @@
static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
const SkScalar b[], int step_b,
SkScalar denom) {
-#ifdef SK_SCALAR_IS_FLOAT
float prod = 0;
for (int i = 0; i < count; i++) {
prod += a[0] * b[0];
@@ -20,24 +19,10 @@ static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
b += step_b;
}
return prod / denom;
-#else
- Sk64 prod, tmp;
-
- prod.set(0);
- for (int i = 0; i < count; i++) {
- tmp.setMul(a[0], b[0]);
- prod.add(tmp);
- a += step_a;
- b += step_b;
- }
- prod.div(denom, Sk64::kRound_DivOption);
- return prod.get32();
-#endif
}
static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
const SkScalar b[], int step_b) {
-#ifdef SK_SCALAR_IS_FLOAT
float prod = 0;
for (int i = 0; i < count; i++) {
prod += a[0] * b[0];
@@ -45,24 +30,11 @@ static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
b += step_b;
}
return prod;
-#else
- Sk64 prod, tmp;
-
- prod.set(0);
- for (int i = 0; i < count; i++) {
- tmp.setMul(a[0], b[0]);
- prod.add(tmp);
- a += step_a;
- b += step_b;
- }
- return prod.getFixed();
-#endif
}
///////////////////////////////////////////////////////////////////////////////
SkUnitScalar SkPoint3D::normalize(SkUnit3D* unit) const {
-#ifdef SK_SCALAR_IS_FLOAT
float mag = sk_float_sqrt(fX*fX + fY*fY + fZ*fZ);
if (mag) {
float scale = 1.0f / mag;
@@ -72,26 +44,6 @@ SkUnitScalar SkPoint3D::normalize(SkUnit3D* unit) const {
} else {
unit->fX = unit->fY = unit->fZ = 0;
}
-#else
- Sk64 tmp1, tmp2;
-
- tmp1.setMul(fX, fX);
- tmp2.setMul(fY, fY);
- tmp1.add(tmp2);
- tmp2.setMul(fZ, fZ);
- tmp1.add(tmp2);
-
- SkFixed mag = tmp1.getSqrt();
- if (mag) {
- // what if mag < SK_Fixed1 ??? we will underflow the fixdiv
- SkFixed scale = SkFixedDiv(SK_Fract1, mag);
- unit->fX = SkFixedMul(fX, scale);
- unit->fY = SkFixedMul(fY, scale);
- unit->fZ = SkFixedMul(fZ, scale);
- } else {
- unit->fX = unit->fY = unit->fZ = 0;
- }
-#endif
return mag;
}

Powered by Google App Engine
This is Rietveld 408576698