Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1524)

Unified Diff: bench/TextBench.cpp

Issue 914723002: Small change to use a GrGeometryProcessor for all BitmapText draw calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adding bench Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrBitmapTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/TextBench.cpp
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 6c3bab13d9145ac4125edd7d678c2abff478494b..39484a2e044ca6a5a358add6a9e8a063b09b4482 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); )
« no previous file with comments | « no previous file | src/gpu/GrBitmapTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698