OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "Resources.h" | 10 #include "Resources.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 paint.measureText(text, strlen(text), &bounds); | 87 paint.measureText(text, strlen(text), &bounds); |
88 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bou
nds.width() * 0.3f, | 88 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bou
nds.width() * 0.3f, |
89 yOffset); | 89 yOffset); |
90 } | 90 } |
91 | 91 |
92 // Corrupted font | 92 // Corrupted font |
93 paint.setTextSize(12); | 93 paint.setTextSize(12); |
94 text = "aA"; | 94 text = "aA"; |
95 paint.setTypeface(fReallyBigATypeface); | 95 paint.setTypeface(fReallyBigATypeface); |
96 sk_tool_utils::add_to_text_blob(&builder, text, paint, corruptedAx, corr
uptedAy); | 96 sk_tool_utils::add_to_text_blob(&builder, text, paint, corruptedAx, corr
uptedAy); |
97 fBlob.reset(builder.build()); | 97 fBlob = builder.make(); |
98 } | 98 } |
99 | 99 |
100 SkString onShortName() override { | 100 SkString onShortName() override { |
101 SkString name("mixedtextblobs"); | 101 SkString name("mixedtextblobs"); |
102 name.append(sk_tool_utils::platform_os_emoji()); | 102 name.append(sk_tool_utils::platform_os_emoji()); |
103 return name; | 103 return name; |
104 } | 104 } |
105 | 105 |
106 SkISize onISize() override { | 106 SkISize onISize() override { |
107 return SkISize::Make(kWidth, kHeight); | 107 return SkISize::Make(kWidth, kHeight); |
(...skipping 23 matching lines...) Expand all Loading... |
131 boundsHalfWidth, boundsHalfHeigh
t); | 131 boundsHalfWidth, boundsHalfHeigh
t); |
132 SkRect lowerRightClip = SkRect::MakeXYWH(bounds.centerX(), bounds.center
Y(), | 132 SkRect lowerRightClip = SkRect::MakeXYWH(bounds.centerX(), bounds.center
Y(), |
133 boundsHalfWidth, boundsHalfHeig
ht); | 133 boundsHalfWidth, boundsHalfHeig
ht); |
134 SkRect interiorClip = bounds; | 134 SkRect interiorClip = bounds; |
135 interiorClip.inset(boundsQuarterWidth, boundsQuarterHeight); | 135 interiorClip.inset(boundsQuarterWidth, boundsQuarterHeight); |
136 | 136 |
137 const SkRect clipRects[] = { bounds, upperLeftClip, lowerRightClip, inte
riorClip}; | 137 const SkRect clipRects[] = { bounds, upperLeftClip, lowerRightClip, inte
riorClip}; |
138 | 138 |
139 size_t count = sizeof(clipRects) / sizeof(SkRect); | 139 size_t count = sizeof(clipRects) / sizeof(SkRect); |
140 for (size_t x = 0; x < count; ++x) { | 140 for (size_t x = 0; x < count; ++x) { |
141 draw_blob(canvas, fBlob, paint, clipRects[x]); | 141 draw_blob(canvas, fBlob.get(), paint, clipRects[x]); |
142 if (x == (count >> 1) - 1) { | 142 if (x == (count >> 1) - 1) { |
143 canvas->translate(SkScalarFloorToScalar(bounds.width() + SkIntTo
Scalar(25)), | 143 canvas->translate(SkScalarFloorToScalar(bounds.width() + SkIntTo
Scalar(25)), |
144 -(x * SkScalarFloorToScalar(bounds.height() + | 144 -(x * SkScalarFloorToScalar(bounds.height() + |
145 SkIntToScalar(25)))); | 145 SkIntToScalar(25)))); |
146 } else { | 146 } else { |
147 canvas->translate(0, SkScalarFloorToScalar(bounds.height() + SkI
ntToScalar(25))); | 147 canvas->translate(0, SkScalarFloorToScalar(bounds.height() + SkI
ntToScalar(25))); |
148 } | 148 } |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 private: | 152 private: |
153 sk_sp<SkTypeface> fEmojiTypeface; | 153 sk_sp<SkTypeface> fEmojiTypeface; |
154 sk_sp<SkTypeface> fReallyBigATypeface; | 154 sk_sp<SkTypeface> fReallyBigATypeface; |
155 const char* fEmojiText; | 155 const char* fEmojiText; |
156 SkAutoTUnref<const SkTextBlob> fBlob; | 156 sk_sp<SkTextBlob> fBlob; |
157 | 157 |
158 static constexpr int kWidth = 1250; | 158 static constexpr int kWidth = 1250; |
159 static constexpr int kHeight = 700; | 159 static constexpr int kHeight = 700; |
160 | 160 |
161 typedef GM INHERITED; | 161 typedef GM INHERITED; |
162 }; | 162 }; |
163 | 163 |
164 ////////////////////////////////////////////////////////////////////////////// | 164 ////////////////////////////////////////////////////////////////////////////// |
165 | 165 |
166 DEF_GM(return new MixedTextBlobsGM;) | 166 DEF_GM(return new MixedTextBlobsGM;) |
167 } | 167 } |
OLD | NEW |