From a0408abdf29127a057cd61ee7106b633ba2aaf12 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Tue, 9 Nov 2021 04:13:37 +0100 Subject: Don't render rows needlessly --- fastiv-browser.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fastiv-browser.c b/fastiv-browser.c index 8a8c7d1..5d1dcff 100644 --- a/fastiv-browser.c +++ b/fastiv-browser.c @@ -328,9 +328,19 @@ fastiv_browser_draw(GtkWidget *widget, cairo_t *cr) gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0, 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++) { - // TODO(p): Test whether we need to render the row first. - draw_row(self, cr, &g_array_index(self->layouted_rows, Row, i)); + const Row *row = &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; } -- cgit v1.2.3-70-g09d2