diff options
author | Hal Canary <halcanary@google.com> | 2018-01-02 16:25:53 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-03 19:59:31 +0000 |
commit | 3c36ef6be93400368fee3ea2e0dca6cff4972bb0 (patch) | |
tree | 69ce7be26f6771d4fcb3d1da3bc979fc0120285f /src/pdf/SkPDFUtils.h | |
parent | 0d825666f79f4d9baea489b21506da3163f73aa9 (diff) |
SkFloatToDecimal moved to src/utils
This change stages SkFloatToDecimal() for possible re-use by pdfium.
Change-Id: Iedc0c78c8a633f0b0973365d2d8b540b5443590d
Reviewed-on: https://skia-review.googlesource.com/90400
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/pdf/SkPDFUtils.h')
-rw-r--r-- | src/pdf/SkPDFUtils.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pdf/SkPDFUtils.h b/src/pdf/SkPDFUtils.h index 27d0a3adbe..a291914a5a 100644 --- a/src/pdf/SkPDFUtils.h +++ b/src/pdf/SkPDFUtils.h @@ -7,6 +7,7 @@ #ifndef SkPDFUtils_DEFINED #define SkPDFUtils_DEFINED +#include "SkFloatToDecimal.h" #include "SkPDFTypes.h" #include "SkPaint.h" #include "SkPath.h" @@ -76,14 +77,13 @@ inline void AppendColorComponent(uint8_t value, SkWStream* wStream) { wStream->write(buffer, len); } -// 3 = '-', '.', and '\0' characters. -// 9 = number of significant digits -// abs(FLT_MIN_10_EXP) = number of zeros in FLT_MIN -const size_t kMaximumFloatDecimalLength = 3 + 9 - FLT_MIN_10_EXP; -// FloatToDecimal is exposed for unit tests. -size_t FloatToDecimal(float value, - char output[kMaximumFloatDecimalLength]); -void AppendScalar(SkScalar value, SkWStream* stream); +inline void AppendScalar(SkScalar value, SkWStream* stream) { + char result[kMaximumSkFloatToDecimalLength]; + size_t len = SkFloatToDecimal(SkScalarToFloat(value), result); + SkASSERT(len < kMaximumSkFloatToDecimalLength); + stream->write(result, len); +} + void WriteString(SkWStream* wStream, const char* input, size_t len); inline void WriteUInt16BE(SkDynamicMemoryWStream* wStream, uint16_t value) { |