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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 run->pos[i] = p.getTextSize() * i * .75f; | 49 run->pos[i] = p.getTextSize() * i * .75f; |
50 } | 50 } |
51 | 51 |
52 run = &builder.allocRunPos(p, glyphCount, nullptr); | 52 run = &builder.allocRunPos(p, glyphCount, nullptr); |
53 memcpy(run->glyphs, fGlyphs.begin(), glyphCount * sizeof(uint16_t)); | 53 memcpy(run->glyphs, fGlyphs.begin(), glyphCount * sizeof(uint16_t)); |
54 for (int i = 0; i < glyphCount; ++i) { | 54 for (int i = 0; i < glyphCount; ++i) { |
55 run->pos[i * 2] = p.getTextSize() * i * .75f; | 55 run->pos[i * 2] = p.getTextSize() * i * .75f; |
56 run->pos[i * 2 + 1] = 150 + 5 * sinf((float)i * 8 / glyphCount); | 56 run->pos[i * 2 + 1] = 150 + 5 * sinf((float)i * 8 / glyphCount); |
57 } | 57 } |
58 | 58 |
59 fBlob.reset(builder.build()); | 59 fBlob = builder.make(); |
60 | 60 |
61 SkColor colors[2]; | 61 SkColor colors[2]; |
62 colors[0] = SK_ColorRED; | 62 colors[0] = SK_ColorRED; |
63 colors[1] = SK_ColorGREEN; | 63 colors[1] = SK_ColorGREEN; |
64 | 64 |
65 SkScalar pos[SK_ARRAY_COUNT(colors)]; | 65 SkScalar pos[SK_ARRAY_COUNT(colors)]; |
66 for (unsigned i = 0; i < SK_ARRAY_COUNT(pos); ++i) { | 66 for (unsigned i = 0; i < SK_ARRAY_COUNT(pos); ++i) { |
67 pos[i] = (float)i / (SK_ARRAY_COUNT(pos) - 1); | 67 pos[i] = (float)i / (SK_ARRAY_COUNT(pos) - 1); |
68 } | 68 } |
69 | 69 |
(...skipping 25 matching lines...) Expand all Loading... |
95 for (int j = 0; j < kYCount; ++j) { | 95 for (int j = 0; j < kYCount; ++j) { |
96 canvas->drawTextBlob(fBlob, | 96 canvas->drawTextBlob(fBlob, |
97 SkIntToScalar(i * sz.width() / kXCount), | 97 SkIntToScalar(i * sz.width() / kXCount), |
98 SkIntToScalar(j * sz.height() / kYCount), | 98 SkIntToScalar(j * sz.height() / kYCount), |
99 p); | 99 p); |
100 } | 100 } |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 private: | 104 private: |
105 SkTDArray<uint16_t> fGlyphs; | 105 SkTDArray<uint16_t> fGlyphs; |
106 SkAutoTUnref<const SkTextBlob> fBlob; | 106 sk_sp<SkTextBlob> fBlob; |
107 sk_sp<SkShader> fShader; | 107 sk_sp<SkShader> fShader; |
108 | 108 |
109 typedef skiagm::GM INHERITED; | 109 typedef skiagm::GM INHERITED; |
110 }; | 110 }; |
111 | 111 |
112 DEF_GM(return new TextBlobShaderGM("Blobber");) | 112 DEF_GM(return new TextBlobShaderGM("Blobber");) |
OLD | NEW |