From 02b05015b55d1900a9e34039942101da189053ce Mon Sep 17 00:00:00 2001 From: joshualitt Date: Wed, 11 Feb 2015 06:56:30 -0800 Subject: Small change to use a GrGeometryProcessor for all BitmapText draw calls BUG=skia: Review URL: https://codereview.chromium.org/914723002 --- bench/TextBench.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'bench/TextBench.cpp') 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 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 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); ) -- cgit v1.2.3