Skip to content

Commit 5f72b95

Browse files
committed
Change the way Cairo buffer is cleared
1 parent 682f115 commit 5f72b95

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/osd.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ void modeset_paint_buffer(struct modeset_buf *buf) {
3939
char msg[80];
4040
memset(msg, 0x00, sizeof(msg));
4141

42-
// TODO(gehee) This takes forever.
43-
for (j = 0; j < buf->height; ++j) {
44-
for (k = 0; k < buf->width; ++k) {
45-
off = buf->stride * j + k * 4;
46-
*(uint32_t*)&buf->map[off] = (0 << 24) | (0 << 16) | (0 << 8) | 0;
47-
}
48-
}
49-
5042
int osd_x = buf->width - 300;
5143
surface = cairo_image_surface_create_for_data(buf->map, CAIRO_FORMAT_ARGB32, buf->width, buf->height, buf->stride);
5244
cr = cairo_create (surface);
5345

46+
// https://www.cairographics.org/FAQ/#clear_a_surface
47+
cairo_save(cr);
48+
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
49+
cairo_paint(cr);
50+
cairo_restore(cr);
51+
5452
cairo_select_font_face (cr, "Roboto", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
5553
cairo_set_font_size (cr, 20);
5654

0 commit comments

Comments
 (0)