glyph-cache: generate at startup, never update while rendering

This commit is contained in:
Daniel Eklöf 2019-07-18 13:03:21 +02:00
parent 332f1c6a21
commit 6e69cf9562
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 38 additions and 20 deletions

View file

@ -190,8 +190,8 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
if (likely(entry != NULL && entry->glyphs != NULL)) {
/* Copy cached glyph(s) and upate position */
memcpy(gseq.g, entry->glyphs, entry->count * sizeof(gseq.g[0]));
for (size_t i = 0; i < entry->count; i++) {
gseq.g[i] = entry->glyphs[i];
gseq.g[i].x += x;
gseq.g[i].y += y;
}
@ -206,18 +206,6 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
if (status != CAIRO_STATUS_SUCCESS)
return;
if (entry != NULL) {
assert(entry->glyphs == NULL);
entry->glyphs = malloc(new_glyphs * sizeof(entry->glyphs[0]));
entry->count = new_glyphs;
for (size_t i = 0; i < new_glyphs; i++) {
entry->glyphs[i] = gseq.g[i];
entry->glyphs[i].x -= x;
entry->glyphs[i].y -= y;
}
}
}
gseq.g += new_glyphs;