From 3c36ef6be93400368fee3ea2e0dca6cff4972bb0 Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Tue, 2 Jan 2018 16:25:53 -0500 Subject: 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 Reviewed-by: Cary Clark --- bench/PDFBench.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'bench') diff --git a/bench/PDFBench.cpp b/bench/PDFBench.cpp index 0dd3fa1eb8..599539026f 100644 --- a/bench/PDFBench.cpp +++ b/bench/PDFBench.cpp @@ -10,6 +10,7 @@ #include "Resources.h" #include "SkAutoPixmapStorage.h" #include "SkData.h" +#include "SkFloatToDecimal.h" #include "SkGradientShader.h" #include "SkImage.h" #include "SkPixmap.h" @@ -36,12 +37,30 @@ struct WStreamWriteTextBenchmark : public Benchmark { DEF_BENCH(return new WStreamWriteTextBenchmark;) +// Test speed of SkFloatToDecimal for typical floats that +// might be found in a PDF document. +struct PDFScalarBench : public Benchmark { + bool isSuitableFor(Backend b) override { + return b == kNonRendering_Backend; + } + const char* onGetName() override { return "PDFScalar"; } + void onDraw(int loops, SkCanvas*) override { + SkRandom random; + char dst[kMaximumSkFloatToDecimalLength]; + while (loops-- > 0) { + auto f = random.nextRangeF(-500.0f, 1500.0f); + (void)SkFloatToDecimal(f, dst); + } + } +}; + +DEF_BENCH(return new PDFScalarBench;) + #ifdef SK_SUPPORT_PDF #include "SkPDFBitmap.h" #include "SkPDFDocument.h" #include "SkPDFShader.h" -#include "SkPDFUtils.h" namespace { static void test_pdf_object_serialization(const sk_sp object) { @@ -164,23 +183,6 @@ private: std::unique_ptr fAsset; }; -// Test speed of SkPDFUtils::FloatToDecimal for typical floats that -// might be found in a PDF document. -struct PDFScalarBench : public Benchmark { - bool isSuitableFor(Backend b) override { - return b == kNonRendering_Backend; - } - const char* onGetName() override { return "PDFScalar"; } - void onDraw(int loops, SkCanvas*) override { - SkRandom random; - char dst[SkPDFUtils::kMaximumFloatDecimalLength]; - while (loops-- > 0) { - auto f = random.nextRangeF(-500.0f, 1500.0f); - (void)SkPDFUtils::FloatToDecimal(f, dst); - } - } -}; - struct PDFColorComponentBench : public Benchmark { bool isSuitableFor(Backend b) override { return b == kNonRendering_Backend; @@ -244,7 +246,6 @@ struct WritePDFTextBenchmark : public Benchmark { DEF_BENCH(return new PDFImageBench;) DEF_BENCH(return new PDFJpegImageBench;) DEF_BENCH(return new PDFCompressionBench;) -DEF_BENCH(return new PDFScalarBench;) DEF_BENCH(return new PDFColorComponentBench;) DEF_BENCH(return new PDFShaderBench;) DEF_BENCH(return new WritePDFTextBenchmark;) -- cgit v1.2.3