OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 class TextBlobGM : public skiagm::GM { | 67 class TextBlobGM : public skiagm::GM { |
68 public: | 68 public: |
69 TextBlobGM(const char* txt) | 69 TextBlobGM(const char* txt) |
70 : fText(txt) { | 70 : fText(txt) { |
71 } | 71 } |
72 | 72 |
73 protected: | 73 protected: |
74 void onOnceBeforeDraw() override { | 74 void onOnceBeforeDraw() override { |
75 fTypeface = sk_tool_utils::create_portable_typeface("serif", SkTypeface:
:kNormal); | 75 fTypeface.reset(sk_tool_utils::create_portable_typeface("serif", SkTypef
ace::kNormal)); |
76 SkPaint p; | 76 SkPaint p; |
77 p.setTypeface(fTypeface); | 77 p.setTypeface(fTypeface); |
78 size_t txtLen = strlen(fText); | 78 size_t txtLen = strlen(fText); |
79 int glyphCount = p.textToGlyphs(fText, txtLen, nullptr); | 79 int glyphCount = p.textToGlyphs(fText, txtLen, nullptr); |
80 | 80 |
81 fGlyphs.append(glyphCount); | 81 fGlyphs.append(glyphCount); |
82 p.textToGlyphs(fText, txtLen, fGlyphs.begin()); | 82 p.textToGlyphs(fText, txtLen, fGlyphs.begin()); |
83 } | 83 } |
84 | 84 |
85 SkString onShortName() override { | 85 SkString onShortName() override { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 SK_ABORT("unhandled pos value"); | 173 SK_ABORT("unhandled pos value"); |
174 } | 174 } |
175 | 175 |
176 currentGlyph += count; | 176 currentGlyph += count; |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 return builder.build(); | 180 return builder.build(); |
181 } | 181 } |
182 | 182 |
183 SkTDArray<uint16_t> fGlyphs; | 183 SkTDArray<uint16_t> fGlyphs; |
184 sk_sp<SkTypeface> fTypeface; | 184 SkAutoTUnref<SkTypeface> fTypeface; |
185 const char* fText; | 185 const char* fText; |
186 typedef skiagm::GM INHERITED; | 186 typedef skiagm::GM INHERITED; |
187 }; | 187 }; |
188 | 188 |
189 DEF_GM(return new TextBlobGM("hamburgefons");) | 189 DEF_GM(return new TextBlobGM("hamburgefons");) |
OLD | NEW |