Don't render rows needlessly

This commit is contained in:
Přemysl Eric Janouch 2021-11-09 04:13:37 +01:00
parent 4361fdd1be
commit a0408abdf2
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -328,9 +328,19 @@ fastiv_browser_draw(GtkWidget *widget, cairo_t *cr)
gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0, gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
allocation.width, allocation.height); allocation.width, allocation.height);
GdkRectangle clip = {};
gboolean have_clip = gdk_cairo_get_clip_rectangle(cr, &clip);
for (guint i = 0; i < self->layouted_rows->len; i++) { for (guint i = 0; i < self->layouted_rows->len; i++) {
// TODO(p): Test whether we need to render the row first. const Row *row = &g_array_index(self->layouted_rows, Row, i);
draw_row(self, cr, &g_array_index(self->layouted_rows, Row, i)); GdkRectangle extents = {
.x = 0,
.y = row->y_offset,
.width = allocation.width,
.height = g_row_height + 2 * g_item_border,
};
if (!have_clip || gdk_rectangle_intersect(&clip, &extents, NULL))
draw_row(self, cr, row);
} }
return TRUE; return TRUE;
} }