summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-13 15:07:42 -0300
committerGabriel Schneider <[email protected]>2026-11-13 15:07:42 -0300
commitd3074636fff0fbcd5fd9b71c0c3b1c1f5c0c1285 (patch)
tree918d67acc8f00f72cc4ae1ba444e41238a689c2b /vendor
parent409c1accefeb7a775c0914c888b469a1e78fc69a (diff)
downloadsketchbook-main.tar.gz
sketchbook-main.zip
host: add optional Tracy profiling and reduce upload allocation stallsHEADmain
Diffstat (limited to 'vendor')
-rw-r--r--vendor/fonts/README.md4
-rw-r--r--vendor/text.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/vendor/fonts/README.md b/vendor/fonts/README.md
index 41a51fc..b02fd51 100644
--- a/vendor/fonts/README.md
+++ b/vendor/fonts/README.md
@@ -46,7 +46,9 @@ environment, names an installed family to put before Go Mono.
Text is rasterized at the renderer's physical pixel density (including logical
presentation scale), and texture origins snap to physical pixels. Whole-run
textures retain antialiasing and shaping; no scaled 8×8 bitmap text is involved.
-The renderer-owned cache retains at most 512 strings / 16 MiB of pixel data.
+The renderer-owned cache retains at most 4096 strings / 128 MiB of pixel data.
+ASCII runs cache white coverage masks and tint at draw time, so animated ink
+reuses the same pixels. Unicode retains painted glyphs, including color emoji.
Only prior-frame textures can be evicted; exceptionally dense frames flush and
release temporary textures rather than growing the cache. Renderer destruction
releases the font map, descriptors and keys after SDL releases its textures.
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};