@@ -201,6 +201,40 @@ TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) {
201
201
ASSERT_EQ (old_packer, new_packer);
202
202
}
203
203
204
+ TEST_P (TypographerTest, GlyphAtlasTextureIsRecreatedIfTypeChanges) {
205
+ auto context = TextRenderContext::Create (GetContext ());
206
+ auto atlas_context = std::make_shared<GlyphAtlasContext>();
207
+ ASSERT_TRUE (context && context->IsValid ());
208
+ SkFont sk_font;
209
+ auto blob = SkTextBlob::MakeFromString (" spooky 1" , sk_font);
210
+ ASSERT_TRUE (blob);
211
+ auto atlas =
212
+ context->CreateGlyphAtlas (GlyphAtlas::Type::kAlphaBitmap , atlas_context,
213
+ TextFrameFromTextBlob (blob));
214
+ auto old_packer = atlas_context->GetRectPacker ();
215
+
216
+ ASSERT_NE (atlas, nullptr );
217
+ ASSERT_NE (atlas->GetTexture (), nullptr );
218
+ ASSERT_EQ (atlas, atlas_context->GetGlyphAtlas ());
219
+
220
+ auto * first_texture = atlas->GetTexture ().get ();
221
+
222
+ // now create a new glyph atlas with an identical blob,
223
+ // but change the type.
224
+
225
+ auto blob2 = SkTextBlob::MakeFromString (" spooky 1" , sk_font);
226
+ auto next_atlas =
227
+ context->CreateGlyphAtlas (GlyphAtlas::Type::kColorBitmap , atlas_context,
228
+ TextFrameFromTextBlob (blob2));
229
+ ASSERT_NE (atlas, next_atlas);
230
+ auto * second_texture = next_atlas->GetTexture ().get ();
231
+
232
+ auto new_packer = atlas_context->GetRectPacker ();
233
+
234
+ ASSERT_NE (second_texture, first_texture);
235
+ ASSERT_NE (old_packer, new_packer);
236
+ }
237
+
204
238
TEST_P (TypographerTest, FontGlyphPairTypeChangesHashAndEquals) {
205
239
Font font = Font (nullptr , {});
206
240
FontGlyphPair pair_1 = {
0 commit comments