diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-09 04:13:37 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-09 04:14:19 +0100 |
commit | a0408abdf29127a057cd61ee7106b633ba2aaf12 (patch) | |
tree | 4ad9853b897dc4dd3d51d983bcf038c075324d0b | |
parent | 4361fdd1beda53a73a86f4bad649a60268b0359d (diff) | |
download | fiv-a0408abdf29127a057cd61ee7106b633ba2aaf12.tar.gz fiv-a0408abdf29127a057cd61ee7106b633ba2aaf12.tar.xz fiv-a0408abdf29127a057cd61ee7106b633ba2aaf12.zip |
Don't render rows needlessly
-rw-r--r-- | fastiv-browser.c | 14 |
1 files 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; } |