diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-02-16 03:46:26 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-16 03:46:26 +0000 |
commit | 844d79e853074c99b7e5e64e051f1e1236c1723e (patch) | |
tree | 7c83ab8ecfa4bf210dc8bb3e7117ccfdd21fd69e /third_party/skia_shared/SkFloatToDecimal.h | |
parent | 2388506a1ba13481463033b414f46c1b8864519e (diff) | |
download | pdfium-844d79e853074c99b7e5e64e051f1e1236c1723e.tar.xz |
Improve performance of writing path floats.
This CL copies the SkPDF code to convert floats into strings when
writing back to PDF files.
Change-Id: I8f8af3924a07aa67f93b9d951af1eef5d2c705db
Reviewed-on: https://pdfium-review.googlesource.com/21990
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Hal Canary <halcanary@chromium.org>
Diffstat (limited to 'third_party/skia_shared/SkFloatToDecimal.h')
-rw-r--r-- | third_party/skia_shared/SkFloatToDecimal.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/third_party/skia_shared/SkFloatToDecimal.h b/third_party/skia_shared/SkFloatToDecimal.h new file mode 100644 index 0000000000..ac1042dbfb --- /dev/null +++ b/third_party/skia_shared/SkFloatToDecimal.h @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkFloatToDecimal_DEFINED +#define SkFloatToDecimal_DEFINED + +constexpr unsigned kMaximumSkFloatToDecimalLength = 49; + +/** \fn SkFloatToDecimal + Convert a float into a decimal string. + + The resulting string will be in the form `[-]?([0-9]*\.)?[0-9]+` (It does + not use scientific notation.) and `sscanf(output, "%f", &x)` will return + the original value if the value is finite. This function accepts all + possible input values. + + INFINITY and -INFINITY are rounded to FLT_MAX and -FLT_MAX. + + NAN values are converted to 0. + + This function will always add a terminating '\0' to the output. + + @param value Any floating-point number + @param output The buffer to write the string into. Must be non-null. + + @return strlen(output) +*/ +unsigned SkFloatToDecimal(float value, char output[kMaximumSkFloatToDecimalLength]); + +#endif // SkFloatToDecimal_DEFINED |