swaywm / swaybg

Wallpaper tool for Wayland compositors
MIT License
490 stars 31 forks source link

WIP: Rescale images as they are loaded #28

Closed mstoeckl closed 3 years ago

mstoeckl commented 3 years ago

Depends on #27.

This change uses GdkPixbufLoader to rescale images as they are being loaded, to the smallest size at which all the output surfaces can still be rendered with full resolution.

This change significantly speeds up the loading of oversized JPG backgrounds when the mode is in {fill,fit,stretch}; PNGs do not change by much. Regular image sizes should not be affected, although I still need to benchmark this.

mstoeckl commented 3 years ago

Closing this, because it doesn't seem to be worth the complexity and additional integration with GdkPixbuf. It would probably be better to print a mild warning the first time that swaybg scales an image that is much larger (>5x pixel count, say) than its destination surface, to guide people toward the best performing solution of scaling/cropping their wallpapers before sending them to swaybg.

I do not recommend having the code become more dependent on GdkPixbuf, because it is not an appropriate image loading library for recently made images, and probably never will be. There have been comments to this effect on the GTK mailing list and bug trackers over the last decade. Other libraries, like GEGL, already support >32K wide images, color spaces, various pixel formats, high bit depth, premultiplied alpha, etc.

emersion commented 3 years ago

Ah, I wasn't aware of GEGL. It's unfortunately still glib, but does look better than GdkPixbuf + cairo.