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

Unified Diff: src/core/SkFloatBits.cpp

Issue 373383003: ios fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: only build gyp on ios Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/core/SkMathPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkFloatBits.cpp
diff --git a/src/core/SkFloatBits.cpp b/src/core/SkFloatBits.cpp
index 39b51abf1dc8a9939c41e69463ee50a37b9b1956..6b35a75c88f72a30652c883eb598fda7cfb30a0c 100644
--- a/src/core/SkFloatBits.cpp
+++ b/src/core/SkFloatBits.cpp
@@ -85,7 +85,16 @@ int32_t SkFloatBits_toIntFloor(int32_t packed) {
value = SkApplySign(value, SkExtractSign(packed));
exp = -exp;
if (exp > 25) { // underflow
+#ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED
+ // The iOS ARM processor discards small denormalized numbers to go faster.
+ // The comparision below empirically causes the result to agree with the
+ // tests in MathTest test_float_floor
+ if (exp > 149) {
+ return 0;
+ }
+#else
exp = 25;
+#endif
}
// int add = 0;
return value >> exp;
@@ -145,7 +154,17 @@ int32_t SkFloatBits_toIntCeil(int32_t packed) {
value = SkApplySign(value, SkExtractSign(packed));
exp = -exp;
if (exp > 25) { // underflow
+#ifdef SK_DISCARD_DENORMALIZED_FOR_SPEED
+ // The iOS ARM processor discards small denormalized numbers to go faster.
+ // The comparision below empirically causes the result to agree with the
+ // tests in MathTest test_float_ceil
+ if (exp > 149) {
+ return 0;
+ }
+ return 0 < value;
+#else
exp = 25;
+#endif
}
int add = (1 << exp) - 1;
return (value + add) >> exp;
« no previous file with comments | « include/core/SkImageEncoder.h ('k') | src/core/SkMathPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698