add bench for textblobbuilder

Bug: skia:
Change-Id: I133c6f78f1b378c3a86dd91b59990861b5e0d09a
Reviewed-on: https://skia-review.googlesource.com/c/174840
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp
index 05f61cc..3f543362 100644
--- a/bench/TextBlobBench.cpp
+++ b/bench/TextBlobBench.cpp
@@ -34,14 +34,17 @@
         const char* text = "Keep your sentences short, but not overly so.";
 
         fGlyphs.setCount(fFont.countText(text, strlen(text), kUTF8_SkTextEncoding));
+        fXPos.setCount(fGlyphs.count());
+
         fFont.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count());
+        fFont.getXPos(&fGlyphs[0], fGlyphs.count(), fXPos.begin());
     }
 
     sk_sp<SkTextBlob> makeBlob() {
         const SkTextBlobBuilder::RunBuffer& run =
             fBuilder.allocRunPosH(fFont, fGlyphs.count(), 10, nullptr);
         memcpy(run.glyphs, &fGlyphs[0], fGlyphs.count() * sizeof(uint16_t));
-        fFont.getXPos(&fGlyphs[0], fGlyphs.count(), run.pos);
+        memcpy(run.pos, &fXPos[0], fXPos.count() * sizeof(SkScalar));
         return fBuilder.make();
     }
 
@@ -49,6 +52,7 @@
     SkTextBlobBuilder   fBuilder;
     SkFont              fFont;
     SkTDArray<uint16_t> fGlyphs;
+    SkTDArray<SkScalar> fXPos;
 
     typedef Benchmark INHERITED;
 };
@@ -69,6 +73,7 @@
         }
     }
 };
+DEF_BENCH( return new TextBlobCachedBench(); )
 
 class TextBlobFirstTimeBench : public SkTextBlobBench {
     const char* onGetName() override {
@@ -84,6 +89,23 @@
         }
     }
 };
-
-DEF_BENCH( return new TextBlobCachedBench(); )
 DEF_BENCH( return new TextBlobFirstTimeBench(); )
+
+class TextBlobMakeBench : public SkTextBlobBench {
+    const char* onGetName() override {
+        return "TextBlobMakeBench";
+    }
+
+    bool isSuitableFor(Backend backend) override {
+        return backend == kNonRendering_Backend;
+    }
+
+    void onDraw(int loops, SkCanvas*) override {
+        for (int i = 0; i < loops; i++) {
+            for (int inner = 0; inner < 1000; ++inner) {
+                this->makeBlob();
+            }
+        }
+    }
+};
+DEF_BENCH( return new TextBlobMakeBench(); )