aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-05-01 10:06:09 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-05-01 10:06:09 +0000
commit99172e7f8e0a7caa1356a9beebf7d22288e5f7a1 (patch)
tree92af8f394e1124952cf69652bdb340376765f730 /render.c
parentterm: don't enable ptmx FDM callback until Wayland window has been configured (diff)
parentunicode-combining: completely remove unicode combining characters when feature is disabled (diff)
Merge branch 'unicode-combining-for-real'
Diffstat (limited to 'render.c')
-rw-r--r--render.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/render.c b/render.c
index 36d93be6..41b5c5b7 100644
--- a/render.c
+++ b/render.c
@@ -21,14 +21,11 @@
#include "quirks.h"
#include "selection.h"
#include "shm.h"
+#include "util.h"
#define TIME_FRAME_RENDERING 0
#define TIME_SCROLL_DAMAGE 0
-#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
struct renderer {
struct fdm *fdm;
struct wayland *wayl;
@@ -359,8 +356,9 @@ draw_cursor(const struct terminal *term, const struct cell *cell,
static int
render_cell(struct terminal *term, pixman_image_t *pix,
- struct cell *cell, int col, int row, bool has_cursor)
+ struct row *row, int col, int row_no, bool has_cursor)
{
+ struct cell *cell = &row->cells[col];
if (cell->attrs.clean)
return 0;
@@ -369,7 +367,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
int width = term->cell_width;
int height = term->cell_height;
int x = term->margins.left + col * width;
- int y = term->margins.top + row * height;
+ int y = term->margins.top + row_no * height;
assert(cell->attrs.selected == 0 || cell->attrs.selected == 1);
bool is_selected = cell->attrs.selected;
@@ -444,6 +442,28 @@ render_cell(struct terminal *term, pixman_image_t *pix,
}
}
+ #if FOOT_UNICODE_COMBINING
+ /* Combining characters */
+ const struct combining_chars *comb_chars = &row->comb_chars[col];
+ for (size_t i = 0; i < comb_chars->count; i++) {
+ const struct fcft_glyph *g = fcft_glyph_rasterize(
+ font, comb_chars->chars[i], term->font_subpixel);
+
+ if (g == NULL)
+ continue;
+
+ pixman_image_t *src = pixman_image_create_solid_fill(&fg);
+ pixman_image_composite32(
+ PIXMAN_OP_OVER, src, g->pix, pix, 0, 0, 0, 0,
+ /* Some fonts use a negative offset, while others use a
+ * "normal" offset */
+ x + (g->x < 0 ? term->cell_width : 0) + g->x,
+ y + font_baseline(term) - g->y,
+ g->width, g->height);
+ pixman_image_unref(src);
+ }
+#endif
+
/* Underline */
if (cell->attrs.underline) {
draw_underline(term, pix, attrs_to_font(term, &cell->attrs),
@@ -763,7 +783,7 @@ static void
render_row(struct terminal *term, pixman_image_t *pix, struct row *row, int row_no)
{
for (int col = term->cols - 1; col >= 0; col--)
- render_cell(term, pix, &row->cells[col], col, row_no, false);
+ render_cell(term, pix, row, col, row_no, false);
}
int
@@ -1274,16 +1294,18 @@ grid_render(struct terminal *term)
pixman_image_set_clip_region(buf->pix, &clip);
/* Erase old cursor (if we rendered a cursor last time) */
- if (term->render.last_cursor.cell != NULL) {
+ if (term->render.last_cursor.row != NULL) {
- struct cell *cell = term->render.last_cursor.cell;
+ struct row *row = term->render.last_cursor.row;
struct coord at = term->render.last_cursor.in_view;
- term->render.last_cursor.cell = NULL;
+ term->render.last_cursor.row = NULL;
+
+ struct cell *cell = &row->cells[at.col];
/* If cell is already dirty, it will be rendered anyway */
if (cell->attrs.clean) {
cell->attrs.clean = 0;
- int cols = render_cell(term, buf->pix, cell, at.col, at.row, false);
+ int cols = render_cell(term, buf->pix, row, at.col, at.row, false);
wl_surface_damage_buffer(
term->window->surface,
@@ -1411,9 +1433,9 @@ grid_render(struct terminal *term)
struct cell *cell = &row->cells[term->grid->cursor.point.col];
cell->attrs.clean = 0;
- term->render.last_cursor.cell = cell;
+ term->render.last_cursor.row = row;
int cols_updated = render_cell(
- term, buf->pix, cell, term->grid->cursor.point.col, view_aligned_row, true);
+ term, buf->pix, row, term->grid->cursor.point.col, view_aligned_row, true);
wl_surface_damage_buffer(
term->window->surface,
@@ -1807,7 +1829,7 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
if (term->scroll_region.end >= old_rows)
term->scroll_region.end = term->rows;
- term->render.last_cursor.cell = NULL;
+ term->render.last_cursor.row = NULL;
damage_view:
if (!term->window->is_maximized && !term->window->is_fullscreen) {