aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'render.c')
-rw-r--r--render.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/render.c b/render.c
index c17f7e9b..fcd07f56 100644
--- a/render.c
+++ b/render.c
@@ -638,6 +638,14 @@ draw_cursor:
}
static void
+render_row(struct terminal *term, pixman_image_t *pix, struct row *row,
+ int row_no, int cursor_col)
+{
+ for (int col = term->cols - 1; col >= 0; col--)
+ render_cell(term, pix, row, col, row_no, cursor_col == col);
+}
+
+static void
render_urgency(struct terminal *term, struct buffer *buf)
{
uint32_t red = term->colors.table[1];
@@ -924,7 +932,7 @@ render_sixel_chunk(struct terminal *term, pixman_image_t *pix, const struct sixe
//LOG_DBG("sixel chunk: %dx%d %dx%d", x, y, width, height);
pixman_image_composite32(
- PIXMAN_OP_SRC,
+ PIXMAN_OP_OVER,
sixel->pix,
NULL,
pix,
@@ -938,7 +946,7 @@ render_sixel_chunk(struct terminal *term, pixman_image_t *pix, const struct sixe
static void
render_sixel(struct terminal *term, pixman_image_t *pix,
- const struct sixel *sixel)
+ const struct coord *cursor, const struct sixel *sixel)
{
const int view_end = (term->grid->view + term->rows - 1) & (term->grid->num_rows - 1);
const bool last_row_needs_erase = sixel->height % term->cell_height != 0;
@@ -1010,29 +1018,44 @@ render_sixel(struct terminal *term, pixman_image_t *pix,
continue;
}
+ int cursor_col = cursor->row == term_row_no ? cursor->col : -1;
+
/*
- * Loop cells and set their 'clean' bit, to prevent the grid
- * rendered from overwriting the sixel
+ * If image contains transparent parts, render all (dirty)
+ * cells beneath it.
+ *
+ * If image is opaque, loop cells and set their 'clean' bit,
+ * to prevent the grid rendered from overwriting the sixel
*
* If the last sixel row only partially covers the cell row,
* 'erase' the cell by rendering them.
+ *
+ * In all cases, do *not* clear the ‘dirty’ bit on the row, to
+ * ensure the regular renderer includes them in the damage
+ * rect.
*/
- for (int col = sixel->pos.col;
- col < min(sixel->pos.col + sixel->cols, term->cols);
- col++)
- {
- struct cell *cell = &row->cells[col];
+ if (!sixel->opaque) {
+ /* TODO: multithreading */
+ int cursor_col = cursor->row == term_row_no ? cursor->col : -1;
+ render_row(term, pix, row, term_row_no, cursor_col);
+ } else {
+ for (int col = sixel->pos.col;
+ col < min(sixel->pos.col + sixel->cols, term->cols);
+ col++)
+ {
+ struct cell *cell = &row->cells[col];
- if (!cell->attrs.clean) {
- bool last_row = abs_row_no == sixel->pos.row + sixel->rows - 1;
- bool last_col = col == sixel->pos.col + sixel->cols - 1;
+ if (!cell->attrs.clean) {
+ bool last_row = abs_row_no == sixel->pos.row + sixel->rows - 1;
+ bool last_col = col == sixel->pos.col + sixel->cols - 1;
- if ((last_row_needs_erase && last_row) ||
- (last_col_needs_erase && last_col))
- {
- render_cell(term, pix, row, col, term_row_no, false);
- } else
- cell->attrs.clean = 1;
+ if ((last_row_needs_erase && last_row) ||
+ (last_col_needs_erase && last_col))
+ {
+ render_cell(term, pix, row, col, term_row_no, cursor_col == col);
+ } else
+ cell->attrs.clean = 1;
+ }
}
}
@@ -1050,7 +1073,8 @@ render_sixel(struct terminal *term, pixman_image_t *pix,
}
static void
-render_sixel_images(struct terminal *term, pixman_image_t *pix)
+render_sixel_images(struct terminal *term, pixman_image_t *pix,
+ const struct coord *cursor)
{
if (likely(tll_length(term->grid->sixel_images)) == 0)
return;
@@ -1086,7 +1110,7 @@ render_sixel_images(struct terminal *term, pixman_image_t *pix)
break;
}
- render_sixel(term, pix, &it->item);
+ render_sixel(term, pix, cursor, &it->item);
}
}
@@ -1250,14 +1274,6 @@ render_ime_preedit(struct terminal *term, struct buffer *buf)
#endif
}
-static void
-render_row(struct terminal *term, pixman_image_t *pix, struct row *row,
- int row_no, int cursor_col)
-{
- for (int col = term->cols - 1; col >= 0; col--)
- render_cell(term, pix, row, col, row_no, cursor_col == col);
-}
-
int
render_worker_thread(void *_ctx)
{
@@ -2063,8 +2079,6 @@ grid_render(struct terminal *term)
cursor.row &= term->grid->num_rows - 1;
}
- render_sixel_images(term, buf->pix[0]);
-
if (term->render.workers.count > 0) {
mtx_lock(&term->render.workers.lock);
term->render.workers.buf = buf;
@@ -2074,6 +2088,8 @@ grid_render(struct terminal *term)
xassert(tll_length(term->render.workers.queue) == 0);
}
+ render_sixel_images(term, buf->pix[0], &cursor);
+
int first_dirty_row = -1;
for (int r = 0; r < term->rows; r++) {
struct row *row = grid_row_in_view(term->grid, r);