GtkImage: Preload icons during css validation
authorAlexander Larsson <alexl@redhat.com>
Wed, 29 Jan 2020 17:10:13 +0000 (18:10 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 09:53:43 +0000 (10:53 +0100)
commitd1c6d78ebb1de39d448b0e8afab13ad495bcadb6
treeabd5cd315faadfac12e042188677f601dbbf331f
parent6a8001fe7d2818d50fbf133b27c823726c28d97d
GtkImage: Preload icons during css validation

At the end of GtkImage css validation (during style-updated) when the
css properties (like the icon size) are valid we call _gtk_icon_helper_preload
which does an async icon theme lookup and load. This will happen on a thread
in parallel with the rest of the css machinery, and hopefully by the
time we need the icon it will be ready. If not we will block when we need
it, but during that blocking all the other icons will be loaded.

Testing widget-factory this changes the time of snapshot() from 31 to
25 msec, but on the other hand we also load a few more icons that we
didn't before causing the css validation phase to be about 8 msec slower.
This is because we're preloading all the images in the window, not only
the ones that are visible.

Unfortunately we still load a bunch of icons in snapshot(), from
GtkCssImageIconTheme, and ideally we should try to preload those also.
gtk/gtkiconhelper.c
gtk/gtkiconhelperprivate.h
gtk/gtkimage.c