background: Improve background preview and refactor
This MR is quite big, but each commit is atomic and should hopefully be explained well enough. The general idea is:
- Make CcBackgroundPaintable reusable. There is a lot of drawing specific properties in the
bg-source.c
file, which makes it a) hard to change and b) specific to the chooser. By refactoring this out, we can make CcBackgroundPaintable more generic and self-contained. This also solves a bug that was not reported so far; moving the Settings window between monitors with different scale factors was broken for the chooser thumbnails. - Now that CcBackgroundPaintable is reusable, we can use it inside the preview in a GtkPicture. This allows us to again remove a lot of drawing code from the preview. The preview used to be blurry at scale factors > 1 because the scale factor was not applied properly in the thumbnail generator for CcBackgroundItem. Now that CcBackgroundPaintable is more self-contained, we can fix this too, making previews at higher scale factors sharper.
- We let the GtkPicture in the preview do the resampling of the underlying paintable texture. This means we always grab the maximum available
gnome_bg
thumbnail resolution, which is 256 for some reason. This also means that resizing is now even faster than with !2057 (merged), because the thumbnail is retrieved only once. Thegnome_bg
code was resizing based on the 256 thumbnail anyways. - Making the preview even sharper is possible, but that would require a full size load and draw again, which is terribly slow. This was precisely why !2057 (merged) got rid of that.
- We remove the unused BgColorsSource, and refactor some more.
Fixes #704 (closed)
Sharpness at scale factor 2 before
Sharpness at scale factor 2 after
Happy reviewing!
Edited by Matthijs Velsink