Index: bench/TextBench.cpp |
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp |
index 4ee0fd3d25b2494f62211732cce0ebd4e694c52c..0a6af34d8f6b8555fa5356c9cf3951c1727a0c2e 100644 |
--- a/bench/TextBench.cpp |
+++ b/bench/TextBench.cpp |
@@ -52,27 +52,33 @@ class TextBench : public Benchmark { |
SkPoint* fPos; |
public: |
TextBench(const char text[], int ps, |
- SkColor color, FontQuality fq, bool doColorEmoji = false, bool doPos = false) { |
- fPos = NULL; |
- fFQ = fq; |
- fDoPos = doPos; |
- fDoColorEmoji = doColorEmoji; |
- fText.set(text); |
- |
+ SkColor color, FontQuality fq, bool doColorEmoji = false, bool doPos = false) |
+ : fText(text) |
+ , fFQ(fq) |
+ , fDoPos(doPos) |
+ , fDoColorEmoji(doColorEmoji) |
+ , fPos(NULL) { |
fPaint.setAntiAlias(kBW != fq); |
fPaint.setLCDRenderText(kLCD == fq); |
fPaint.setTextSize(SkIntToScalar(ps)); |
fPaint.setColor(color); |
+ } |
- if (doColorEmoji) { |
+ virtual ~TextBench() { |
+ delete[] fPos; |
+ } |
+ |
+protected: |
+ void onPreDraw() override { |
+ if (fDoColorEmoji) { |
SkASSERT(kBW == fFQ); |
fColorEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); |
} |
- if (doPos) { |
- size_t len = strlen(text); |
+ if (fDoPos) { |
+ size_t len = fText.size(); |
SkScalar* adv = new SkScalar[len]; |
- fPaint.getTextWidths(text, len, adv); |
+ fPaint.getTextWidths(fText.c_str(), len, adv); |
fPos = new SkPoint[len]; |
SkScalar x = 0; |
for (size_t i = 0; i < len; ++i) { |
@@ -83,11 +89,7 @@ public: |
} |
} |
- virtual ~TextBench() { |
- delete[] fPos; |
- } |
-protected: |
virtual const char* onGetName() { |
fName.printf("text_%g", SkScalarToFloat(fPaint.getTextSize())); |
mtklein
2015/05/21 13:09:25
Kind of weird that this builds fName in place then
|
if (fDoPos) { |
@@ -100,7 +102,7 @@ protected: |
fName.append("_BK"); |
} |
- if (fDoColorEmoji && fColorEmojiTypeface) { |
+ if (fDoColorEmoji) { |
fName.append("_ColorEmoji"); |
} |