OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 textencoding? | 40 textencoding? |
41 text -vs- postext - pathtext | 41 text -vs- postext - pathtext |
42 */ | 42 */ |
43 class TextBench : public Benchmark { | 43 class TextBench : public Benchmark { |
44 SkPaint fPaint; | 44 SkPaint fPaint; |
45 SkString fText; | 45 SkString fText; |
46 SkString fName; | 46 SkString fName; |
47 FontQuality fFQ; | 47 FontQuality fFQ; |
48 bool fDoPos; | 48 bool fDoPos; |
49 bool fDoColorEmoji; | 49 bool fDoColorEmoji; |
50 SkAutoTUnref<SkTypeface> fColorEmojiTypeface; | 50 sk_sp<SkTypeface> fColorEmojiTypeface; |
51 SkPoint* fPos; | 51 SkPoint* fPos; |
52 public: | 52 public: |
53 TextBench(const char text[], int ps, | 53 TextBench(const char text[], int ps, |
54 SkColor color, FontQuality fq, bool doColorEmoji = false, bool doP
os = false) | 54 SkColor color, FontQuality fq, bool doColorEmoji = false, bool doP
os = false) |
55 : fText(text) | 55 : fText(text) |
56 , fFQ(fq) | 56 , fFQ(fq) |
57 , fDoPos(doPos) | 57 , fDoPos(doPos) |
58 , fDoColorEmoji(doColorEmoji) | 58 , fDoColorEmoji(doColorEmoji) |
59 , fPos(nullptr) { | 59 , fPos(nullptr) { |
60 fPaint.setAntiAlias(kBW != fq); | 60 fPaint.setAntiAlias(kBW != fq); |
61 fPaint.setLCDRenderText(kLCD == fq); | 61 fPaint.setLCDRenderText(kLCD == fq); |
62 fPaint.setTextSize(SkIntToScalar(ps)); | 62 fPaint.setTextSize(SkIntToScalar(ps)); |
63 fPaint.setColor(color); | 63 fPaint.setColor(color); |
64 } | 64 } |
65 | 65 |
66 virtual ~TextBench() { | 66 virtual ~TextBench() { |
67 delete[] fPos; | 67 delete[] fPos; |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
71 void onDelayedSetup() override { | 71 void onDelayedSetup() override { |
72 if (fDoColorEmoji) { | 72 if (fDoColorEmoji) { |
73 SkASSERT(kBW == fFQ); | 73 SkASSERT(kBW == fFQ); |
74 fColorEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf
")); | 74 fColorEmojiTypeface = MakeResourceAsTypeface("/fonts/Funkster.ttf"); |
75 } | 75 } |
76 | 76 |
77 if (fDoPos) { | 77 if (fDoPos) { |
78 size_t len = fText.size(); | 78 size_t len = fText.size(); |
79 SkScalar* adv = new SkScalar[len]; | 79 SkScalar* adv = new SkScalar[len]; |
80 fPaint.getTextWidths(fText.c_str(), len, adv); | 80 fPaint.getTextWidths(fText.c_str(), len, adv); |
81 fPos = new SkPoint[len]; | 81 fPos = new SkPoint[len]; |
82 SkScalar x = 0; | 82 SkScalar x = 0; |
83 for (size_t i = 0; i < len; ++i) { | 83 for (size_t i = 0; i < len; ++i) { |
84 fPos[i].set(x, SkIntToScalar(50)); | 84 fPos[i].set(x, SkIntToScalar(50)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); ) | 168 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); ) |
169 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); ) | 169 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); ) |
170 | 170 |
171 DEF_BENCH( return new TextBench(STR, 16, 0xFFFFFFFF, kBW, true); ) | 171 DEF_BENCH( return new TextBench(STR, 16, 0xFFFFFFFF, kBW, true); ) |
172 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true); ) | 172 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true); ) |
173 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kBW, true); ) | 173 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kBW, true); ) |
174 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kBW, true); ) | 174 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kBW, true); ) |
175 | 175 |
176 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true, true); ) | 176 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kBW, true, true); ) |
177 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, false, true); ) | 177 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, false, true); ) |
OLD | NEW |