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

Unified Diff: src/core/SkRect.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/core/SkRect.cpp
diff --git a/src/core/SkRect.cpp b/src/core/SkRect.cpp
index 97de0a6a4a65b1b0633fde32d38a7096134641a0..bb51ede7573dbe95eace7faf1437d4bf7631f3b2 100644
--- a/src/core/SkRect.cpp
+++ b/src/core/SkRect.cpp
@@ -55,21 +55,6 @@ void SkRect::toQuad(SkPoint quad[4]) const {
quad[3].set(fLeft, fBottom);
}
-#ifdef SK_SCALAR_IS_FLOAT
- #define SkFLOATCODE(code) code
-#else
- #define SkFLOATCODE(code)
-#endif
-
-// For float compares (at least on x86, by removing the else from the min/max
-// computation, we get MAXSS and MINSS instructions, and no branches.
-// Fixed point has no such opportunity (afaik), so we leave the else in that case
-#ifdef SK_SCALAR_IS_FLOAT
- #define MINMAX_ELSE
-#else
- #define MINMAX_ELSE else
-#endif
-
bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
SkASSERT((pts && count > 0) || count == 0);
@@ -85,17 +70,22 @@ bool SkRect::setBoundsCheck(const SkPoint pts[], int count) {
// If all of the points are finite, accum should stay 0. If we encounter
// a NaN or infinity, then accum should become NaN.
- SkFLOATCODE(float accum = 0;)
- SkFLOATCODE(accum *= l; accum *= t;)
+ float accum = 0;
+ accum *= l; accum *= t;
for (int i = 1; i < count; i++) {
SkScalar x = pts[i].fX;
SkScalar y = pts[i].fY;
- SkFLOATCODE(accum *= x; accum *= y;)
+ accum *= x; accum *= y;
+
+ // we use if instead of if/else, so we can generate min/max
+ // float instructions (at least on SSE)
+ if (x < l) l = x;
+ if (x > r) r = x;
- if (x < l) l = x; MINMAX_ELSE if (x > r) r = x;
- if (y < t) t = y; MINMAX_ELSE if (y > b) b = y;
+ if (y < t) t = y;
+ if (y > b) b = y;
}
SkASSERT(!accum || !SkScalarIsFinite(accum));
« src/core/SkCanvas.cpp ('K') | « src/core/SkPicture.cpp ('k') | src/core/SkScan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698