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

Unified Diff: src/utils/SkParse.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/SkParse.cpp
diff --git a/src/utils/SkParse.cpp b/src/utils/SkParse.cpp
index 9609ddc568d1c469178d045675b4a12db19ec150..f6e2a438e85bc15bc5e857090a0eeaeeb1c008b1 100644
--- a/src/utils/SkParse.cpp
+++ b/src/utils/SkParse.cpp
@@ -201,7 +201,7 @@ const char* SkParse::FindMSec(const char str[], SkMSec* value)
const char* SkParse::FindScalar(const char str[], SkScalar* value) {
SkASSERT(str);
str = skip_ws(str);
-#ifdef SK_SCALAR_IS_FLOAT
+
char* stop;
float v = (float)strtod(str, &stop);
if (str == stop) {
@@ -211,49 +211,6 @@ const char* SkParse::FindScalar(const char str[], SkScalar* value) {
*value = v;
}
return stop;
-#else
- int sign = 0;
- if (*str == '-')
- {
- sign = -1;
- str += 1;
- }
-
- if (!is_digit(*str) && *str != '.')
- return NULL;
-
- int n = 0;
- while (is_digit(*str))
- {
- n = 10*n + *str - '0';
- if (n > 0x7FFF)
- return NULL;
- str += 1;
- }
- n <<= 16;
-
- if (*str == '.')
- {
- static const int gFractions[] = { (1 << 24) / 10, (1 << 24) / 100, (1 << 24) / 1000,
- (1 << 24) / 10000, (1 << 24) / 100000 };
- str += 1;
- int d = 0;
- const int* fraction = gFractions;
- const int* end = &fraction[SK_ARRAY_COUNT(gFractions)];
- while (is_digit(*str) && fraction < end)
- d += (*str++ - '0') * *fraction++;
- d += 0x80; // round
- n += d >> 8;
- }
- while (is_digit(*str))
- str += 1;
- if (value)
- {
- n = (n ^ sign) - sign; // apply the sign
- *value = SkFixedToScalar(n);
- }
-#endif
- return str;
}
const char* SkParse::FindScalars(const char str[], SkScalar value[], int count)

Powered by Google App Engine
This is Rietveld 408576698