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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SkPaint p; | 71 SkPaint p; |
72 p.setTypeface(fTypeface); | 72 p.setTypeface(fTypeface); |
73 size_t txtLen = strlen(txt); | 73 size_t txtLen = strlen(txt); |
74 int glyphCount = p.textToGlyphs(txt, txtLen, NULL); | 74 int glyphCount = p.textToGlyphs(txt, txtLen, NULL); |
75 | 75 |
76 fGlyphs.append(glyphCount); | 76 fGlyphs.append(glyphCount); |
77 p.textToGlyphs(txt, txtLen, fGlyphs.begin()); | 77 p.textToGlyphs(txt, txtLen, fGlyphs.begin()); |
78 } | 78 } |
79 | 79 |
80 protected: | 80 protected: |
81 virtual SkString onShortName() SK_OVERRIDE { | 81 SkString onShortName() SK_OVERRIDE { |
82 return SkString("textblob"); | 82 return SkString("textblob"); |
83 } | 83 } |
84 | 84 |
85 virtual SkISize onISize() SK_OVERRIDE { | 85 SkISize onISize() SK_OVERRIDE { |
86 return SkISize::Make(640, 480); | 86 return SkISize::Make(640, 480); |
87 } | 87 } |
88 | 88 |
89 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 89 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
90 for (unsigned b = 0; b < SK_ARRAY_COUNT(blobConfigs); ++b) { | 90 for (unsigned b = 0; b < SK_ARRAY_COUNT(blobConfigs); ++b) { |
91 SkAutoTUnref<const SkTextBlob> blob(this->makeBlob(b)); | 91 SkAutoTUnref<const SkTextBlob> blob(this->makeBlob(b)); |
92 | 92 |
93 SkPaint p; | 93 SkPaint p; |
94 SkPoint offset = SkPoint::Make(SkIntToScalar(10 + 300 * (b % 2)), | 94 SkPoint offset = SkPoint::Make(SkIntToScalar(10 + 300 * (b % 2)), |
95 SkIntToScalar(20 + 150 * (b / 2))); | 95 SkIntToScalar(20 + 150 * (b / 2))); |
96 | 96 |
97 canvas->drawTextBlob(blob, offset.x(), offset.y(), p); | 97 canvas->drawTextBlob(blob, offset.x(), offset.y(), p); |
98 | 98 |
99 p.setColor(SK_ColorBLUE); | 99 p.setColor(SK_ColorBLUE); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return builder.build(); | 176 return builder.build(); |
177 } | 177 } |
178 | 178 |
179 SkTDArray<uint16_t> fGlyphs; | 179 SkTDArray<uint16_t> fGlyphs; |
180 SkAutoTUnref<SkTypeface> fTypeface; | 180 SkAutoTUnref<SkTypeface> fTypeface; |
181 | 181 |
182 typedef skiagm::GM INHERITED; | 182 typedef skiagm::GM INHERITED; |
183 }; | 183 }; |
184 | 184 |
185 DEF_GM( return SkNEW_ARGS(TextBlobGM, ("hamburgefons")); ) | 185 DEF_GM( return SkNEW_ARGS(TextBlobGM, ("hamburgefons")); ) |
OLD | NEW |