Instead, rely on people passing fallbacks explicitly.
Alternatively, GThemedIcon provides the functionality to create
fallbacks, which is what GtkImage and the testsuite now use.
That method is slightly better, too, so the expected test results
have been updated accordingly.
Most users were just forgetting to set the proper flags.
And flags aren't the right way to set this anyway, it was just
acceptable as a workaround during GTK3 to not break API.
We look at whether a widget will be mapped (the actual state is not
yet set, so we can't rely on that at css validation time) and use
that to set the i/o priority of the async task.
This means that its likely that widgets that will be displayed soon
are loaded before those that are not yet going to be needed.
This limits the amount of preloading we to, which can for instance
avoid trashing if the icon cache is full, and in general do less work
when its likely to be wasted such as when e.g. background-color for an
icon helper changes.
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.
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
We want to differentiate what requires recreating the
texture and what doesn't. In particular, the current
flags are not handling symbolic icons right.
This is happening for me when snapshotting small thumbnails in the file
chooser. The GtkScaler will scale the 1px height/width by 2, resulting
in nothing being drawn at all.
Instead of fiddling around with scale in the iconhelper (and getting it
wrong), create a GtkScaler around the paintable that takes care of the
scaling.
That's kinda weird but allows us to delete the texture case from
GtkIconHelper and GTK_IMAGE_TEXTURE from the GtkImageType enum.
And it doesn't cause any other problems because the cell renderer
can't deal with paintables - otherwise it would mirror GtkImage and have
a "paintable" property instead.
If set, the image will draw its contents while keeping their aspect
ratio. That means empty areas show up on the top/bottom or left/right.
Also move the special-case snapshotting code for icons to
GtkIconHelper. That's where it belongs.
This only implements the vfuncs, but does not actually emit signals
yet.
It's also not useed for anything other than snapshot() so far, this
will come in later commits.
Instead of loading them into surfaces (which we want to get rid of), we
load into textures.
In fact, we introduce a new paintable subclass called a GtkScaler that
takes care of tracking scaling.
This also ideally gets rid of an extra conversion once renderers learn
to render textures directly.
This is in preparation for accepting the image type paintable.
It's a bit incovenient because we need more code to track width/height
ourselves (as the paintable no longer does it for us), but it's not too
hard.
GtkIconHelper does not track invalidations on the paintable.
Instead of looking at the icon size, look at the CSS value for
-gtk-icon-size. Set style classes depending on icon size instead.
Trivially change Adwaita and HighContrast to report the same values as
before.
Instead, add a function gtk_image_set_icon_size() for the cases where
overriding the icon size is necessary.
Treat icon sizes the same way as pixel sizes, too. So gtk_image_clear()
no longer unsets the icon size.