GTK4: how to display thousands of rows of 6 images in a row – efficiently?

What is the best way to display up to 5-10 thousand rows of 6 images interactively (= with good responsiveness to scrolling), if the images each take about 80-300 ms to calculate (so I don’t want to load them all). Each image is 640×480 pixels.Each image has some widgets around it to change processing parameters influencing display – changing those widgets has to recalculate the image and update the display. The user occasionally changes processing parameters on a few images or a few rows of images. When the user is not changing the processing parameters, the image does not change – which is my way of saying it should be cached somehow during scrolling and not recalculated for every redraw. Nothing needs to be drawn/painted onto of the image currently; although it might be a future requirement to draw some indicators on top.


I guess I am asking two things:

  1. how to only process images actually displayed

For this, I have created a GListModel for the image rows, and then created a ListView fed by that model.

This functions, but suboptimally: the ListView keeps asking for about 100-200 rows of images. So both initial display is not happening very soon, but also scrolling only updates about once every 3-15 seconds.

My guess is that I don’t provide enough information for optimal widget height calculation, and therefore the ListView ends up thinking my widgets are very short (=vertically small) – and then I guess it asks for as many widgets as it calculates is needed to fill the available area vertically. My widgets however are about 600-800 pixels tall, so about 2-3 are enough to fill the screen vertically. My widgets are laid out correctly on screen, there are no layout/display issues. Yet the ListView keeps asking for many more rows of widgets than the 2-3 necessary to fill the screen.

  1. how to make display of individual images as efficient as possible, including backing/caching

What is the best way to display an image that was dumped into a memory buffer, yet that can be updated occasionally (when the processing parameters changed)?

Currently:

  • when the processing parameters change, I (re)calculate the pixel values into memory (for example in 24 bit RGB or 32 bit RGBA format) and then keep that memory buffer
  • the image display widget is a Gtk::DrawingArea. In its draw_func: I wrap the memory buffer into a GdkPixbuf::Pixbuf with set_source_pixbuf(gdk_pixbuf, 0, 0) and then paint.

My apologies, and I am sure there is a better way.

Thank you kindly in advance for any insight you have.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.