aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-01-02 16:25:53 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-03 19:59:31 +0000
commit3c36ef6be93400368fee3ea2e0dca6cff4972bb0 (patch)
tree69ce7be26f6771d4fcb3d1da3bc979fc0120285f /bench
parent0d825666f79f4d9baea489b21506da3163f73aa9 (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 'bench')
-rw-r--r--bench/PDFBench.cpp39
1 files changed, 20 insertions, 19 deletions
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<SkPDFObject> object) {
@@ -164,23 +183,6 @@ private:
std::unique_ptr<SkStreamAsset> 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;)