From d495da03e1d87f25e88a0d9edc8c39ba2b74e411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 5 May 2021 16:34:57 +0200 Subject: [PATCH] =?UTF-8?q?box-drawing:=20temporary=20=E2=80=9Cfix?= =?UTF-8?q?=E2=80=9D=20for=20LIGHT=20ARCs=20with=20a8=20buffers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t have a method to draw the arcs using pixman yet. Work around this by replacing the a8 buffer with an a1 buffer, and render the arcs using our old, non-antialiased, way. --- box-drawing.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/box-drawing.c b/box-drawing.c index ff1ccf22..188aafc0 100644 --- a/box-drawing.c +++ b/box-drawing.c @@ -1225,6 +1225,27 @@ draw_box_drawings_double_vertical_and_horizontal(struct buf *buf) static void draw_box_drawings_light_arc(wchar_t wc, struct buf *buf) { + if (pixman_image_get_format(buf->pix) == PIXMAN_a8) { + /* + * Hack until we’ve implemented ARCs with pixman + * + * Replace the a8 buffer with a a1 buffer, and use our “old” + * non-antialiased technique to draw arcs. + */ + + int stride = stride_for_format_and_width(PIXMAN_a1, buf->width); + uint8_t *new_data = xcalloc(buf->height * stride, 1); + pixman_image_t *new_pix = pixman_image_create_bits_no_clear( + PIXMAN_a1, buf->width, buf->height, (uint32_t *)new_data, stride); + + pixman_image_unref(buf->pix); + free(buf->data); + + buf->data = new_data; + buf->pix = new_pix; + buf->stride = stride; + } + int thick = thickness(LIGHT); double a = (buf->width - thick) / 2; @@ -2359,7 +2380,7 @@ box_drawing(const struct terminal *term, wchar_t wc) *glyph = (struct fcft_glyph){ .wc = wc, .cols = 1, - .pix = pix, + .pix = buf.pix, .x = -term->font_x_ofs, .y = term->font_y_ofs + term->fonts[0]->ascent, .width = width,