diff options
author | 2011-03-03 18:20:12 +0000 | |
---|---|---|
committer | 2011-03-03 18:20:12 +0000 | |
commit | 677cbedda7dc43844cbc58dbebbe52e37381be8e (patch) | |
tree | 35c2b5def93257220536a3a8894b267c5dfa4ec8 /src/core/SkString.cpp | |
parent | 759876a9223ef64f9d0db235d7a46750f8193cbc (diff) |
Expose explicit functions to stringify float's and fixed's.
See http://codereview.appspot.com/4240050/
Review URL: http://codereview.appspot.com/4240068
git-svn-id: http://skia.googlecode.com/svn/trunk@880 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkString.cpp')
-rw-r--r-- | src/core/SkString.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp index ca97e0b592..b8f99c7c88 100644 --- a/src/core/SkString.cpp +++ b/src/core/SkString.cpp @@ -134,21 +134,23 @@ char* SkStrAppendS64(char string[], int64_t dec, int minDigits) return string; } -char* SkStrAppendScalar(char string[], SkScalar value) +#ifdef SK_CAN_USE_FLOAT +char* SkStrAppendFloat(char string[], float value) { - SkDEBUGCODE(char* start = string;) - -#ifdef SK_SCALAR_IS_FLOAT // since floats have at most 8 significant digits, we limit our %g to that. static const char gFormat[] = "%.8g"; // make it 1 larger for the terminating 0 char buffer[SkStrAppendScalar_MaxSize + 1]; int len = SNPRINTF(buffer, sizeof(buffer), gFormat, value); memcpy(string, buffer, len); + SkASSERT(len <= SkStrAppendScalar_MaxSize); return string + len; -#else - SkFixed x = SkScalarToFixed(value); +} +#endif +char* SkStrAppendFixed(char string[], SkFixed x) +{ + SkDEBUGCODE(char* start = string;) if (x < 0) { *string++ = '-'; @@ -182,7 +184,6 @@ char* SkStrAppendScalar(char string[], SkScalar value) x %= powerOfTen; } while (x != 0); } -#endif SkASSERT(string - start <= SkStrAppendScalar_MaxSize); return string; |