Some GdkPaintables like icons may be expensive to render often.
In GtkSourceView, they’re first converted to a GdkTexture (by rendering the paintable icons on it with cairo), which is cached and used later for snapshots.
That looks a bit cumbersome… are there other ways to cache paintables, not requiring cairo?
I don’t understand what “render often” means, in the context: paintables have to rendered whenever GTK needs to render them. An icon is usually a bunch of texture data, so “rendering” is just an upload to the GPU, and that happens regardless of using Cairo or not.
Even if you’re using SVG for your assets, you have to re-render them at the size given to the GdkPaintable::snapshot(), otherwise you’ll get blurry results.
“render often” here means “rendering the exact same icon multiple times in the same widget”.
(more concretely: that’s bookmark icons in a GtkSourceView gutter)
Ah… actually that’s exactly because I get blurry icons that I started to look at that specific code
That’s why you either use the same paintable instance, or you cache the result into an intermediate texture—for instance, using a separate GtkSnapshot and gtk_snapshot_free_to_paintable(); but if you cache the result you will need to invalidate the cache every time the size of the paintable changes; or whenever the scale factor of the widget changes; or the icon theme changes; etc.