render: regression: don't let cell background overflow into the margins

This used to work before because we had a "global" clip region on the
text area, excluding the margins.

When we introduced per-cell clipping, this global clip region was
removed, and the background drawing code could now overflow into the
margins.

This fixes it by setting the cell clip region not just when rendering
a glyph, but before we render the cell background.
This commit is contained in:
Daniel Eklöf 2020-06-05 08:10:38 +02:00
parent 8b320ed296
commit d8a83b500f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -418,7 +418,14 @@ render_cell(struct terminal *term, pixman_image_t *pix,
glyph = fcft_glyph_rasterize(font, base, term->font_subpixel);
}
int cell_cols = glyph != NULL ? max(1, glyph->cols) : 1;
const int cols_left = term->cols - col;
int cell_cols = glyph != NULL ? max(1, min(glyph->cols, cols_left)) : 1;
pixman_region32_t clip;
pixman_region32_init_rect(
&clip, x, y,
cell_cols * term->cell_width, term->cell_height);
pixman_image_set_clip_region32(pix, &clip);
/* Background */
pixman_image_fill_rectangles(
@ -438,11 +445,6 @@ render_cell(struct terminal *term, pixman_image_t *pix,
if (glyph != NULL) {
/* Clip to cell */
pixman_region32_t clip;
pixman_region32_init_rect(
&clip, x, y, glyph->cols * term->cell_width, term->cell_height);
pixman_image_set_clip_region32(pix, &clip);
if (unlikely(pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8)) {
/* Glyph surface is a pre-rendered image (typically a color emoji...) */
if (!(cell->attrs.blink && term->blink.state == BLINK_OFF)) {