From d3074636fff0fbcd5fd9b71c0c3b1c1f5c0c1285 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 13 Nov 2026 15:07:42 -0300 Subject: host: add optional Tracy profiling and reduce upload allocation stalls --- vendor/text.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'vendor/text.c') diff --git a/vendor/text.c b/vendor/text.c index 8b2a54e..a453067 100644 --- a/vendor/text.c +++ b/vendor/text.c @@ -277,7 +277,11 @@ bool sk_text_draw_scaled(SDL_Renderer *renderer, int face, float x, float y, flo const int size = font_size(raster, dpi); /* How much larger than rasterized it is drawn: 1 when it is drawn as it is. */ const float k = scale / raster; - const Uint32 color = ((Uint32)r << 16) | ((Uint32)g << 8) | b; + /* ASCII uses a reusable coverage mask; animated ink never rerasterizes it. + Keep the existing painted path for Unicode, including color emoji. */ + bool mask = true; + for (size_t i = 0; i < len; ++i) if ((unsigned char)utf8[i] >= 128) { mask = false; break; } + const Uint32 color = mask ? 0xffffff : ((Uint32)r << 16) | ((Uint32)g << 8) | b; const uint64_t hash = hash_text(utf8, len); Text *entry = NULL; for (size_t i = 0; i < CACHE_ENTRIES; ++i) { @@ -309,7 +313,7 @@ bool sk_text_draw_scaled(SDL_Renderer *renderer, int face, float x, float y, flo entry->used = c->frame; /* Cairo pixels are premultiplied; modulate RGB and alpha together. Color glyphs retain their intrinsic paint, while ordinary text uses its ink. */ - SDL_SetTextureColorMod(entry->texture, a, a, a); + SDL_SetTextureColorMod(entry->texture, mask ? r * a / 255 : a, mask ? g * a / 255 : a, mask ? b * a / 255 : a); SDL_SetTextureAlphaMod(entry->texture, a); SDL_FRect dest = {.x=(roundf(x*dpi)+entry->left)/dpi,.y=(roundf(y*dpi)+entry->top)/dpi, .w=entry->width/dpi,.h=entry->height/dpi}; -- cgit v1.3