aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/TextBench.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-02-11 06:56:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-11 06:56:30 -0800
commit02b05015b55d1900a9e34039942101da189053ce (patch)
treee7162807a7a960539d3fe40796594654a528570c /bench/TextBench.cpp
parent9e33d1dbccee9b13ac001dfc3094a503f9e84e9d (diff)
Small change to use a GrGeometryProcessor for all BitmapText draw calls
Diffstat (limited to 'bench/TextBench.cpp')
-rw-r--r--bench/TextBench.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 6c3bab13d9..39484a2e04 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -5,17 +5,21 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "Benchmark.h"
+#include "Resources.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
+#include "SkStream.h"
#include "SkString.h"
#include "SkTemplates.h"
+#include "SkTypeface.h"
enum FontQuality {
kBW,
kAA,
- kLCD
+ kLCD,
};
static const char* fontQualityName(const SkPaint& paint) {
@@ -43,13 +47,16 @@ class TextBench : public Benchmark {
SkString fName;
FontQuality fFQ;
bool fDoPos;
+ bool fDoColorEmoji;
+ SkAutoTUnref<SkTypeface> fColorEmojiTypeface;
SkPoint* fPos;
public:
TextBench(const char text[], int ps,
- SkColor color, FontQuality fq, bool doPos = false) {
+ SkColor color, FontQuality fq, bool doColorEmoji = false, bool doPos = false) {
fPos = NULL;
fFQ = fq;
fDoPos = doPos;
+ fDoColorEmoji = doColorEmoji;
fText.set(text);
fPaint.setAntiAlias(kBW != fq);
@@ -57,6 +64,17 @@ public:
fPaint.setTextSize(SkIntToScalar(ps));
fPaint.setColor(color);
+ if (doColorEmoji) {
+ SkASSERT(kBW == fFQ);
+ SkString filename = GetResourcePath("/Funkster.ttf");
+ SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(filename.c_str()));
+ if (stream->isValid()) {
+ fColorEmojiTypeface.reset(SkTypeface::CreateFromStream(stream.detach()));
+ } else {
+ SkDebugf("Could not find Funkster.ttf, please set --resourcePath correctly.\n");
+ }
+ }
+
if (doPos) {
size_t len = strlen(text);
SkScalar* adv = new SkScalar[len];
@@ -87,6 +105,11 @@ protected:
} else {
fName.append("_BK");
}
+
+ if (fDoColorEmoji && fColorEmojiTypeface) {
+ fName.append("_ColorEmoji");
+ }
+
return fName.c_str();
}
@@ -101,6 +124,10 @@ protected:
paint.setAntiAlias(kBW != fFQ);
paint.setLCDRenderText(kLCD == fFQ);
+ if (fDoColorEmoji && fColorEmojiTypeface) {
+ paint.setTypeface(fColorEmojiTypeface);
+ }
+
const SkScalar x0 = SkIntToScalar(-10);
const SkScalar y0 = SkIntToScalar(-10);
@@ -141,4 +168,9 @@ DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kLCD); )
DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); )
DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); )
-DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, true); )
+DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true); )
+DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kBW, true); )
+DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kBW, true); )
+
+DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true, true); )
+DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, false, true); )