The Wayland shm formats (almost equivalently, DRM fourcc pixel format
codes) are specified as being little endian, but Pixman's format codes
are generally native-endian. The existing conversions all assume
native=little; this commit introduces format conversions for when
native=big.
Not all DRM/wayland fourcc formats have a big endian pixman_format_code
equivalent, but the most popular (A|X)(RGB|BGR)8888 formats all do.
According to the spec, XDG_PICTURES_DIR is an entry in $XDG_CONFIG_HOME/user-dirs.dirs.
This file can be sourced which will set the env var, however it may not always be.
Hence we should read the path from the file rather than trying to get it from the env.
spec: https://www.freedesktop.org/wiki/Software/xdg-user-dirs/
Because cairo_surface_write_to_png does not have a way to configure
the compression level, this change adds code which directly uses
libpng to save images in 'write_png.c'.
This fixes a regression from the earlier commit switching from Cairo
to Pixman, where downscaling images inaccurately computed pixel values
in the result.
Now the code uses a convolution filter when downscaling, to get a more
accurate combined color for a downscaled pixel. The 2-lobe Lanczos
filter now used is very close to the Catmull-Rom filter applied by the
CAIRO_FILTER_BEST setting. Downscaling images now runs roughly as
slowly as the Cairo implementation did.
Bilinear filtering is still used for upscaling; while it may not give
results as nice as what Cairo had, rendering quickly becomes even more
important which the screenshot being produced is large.
The previous code using Cairo ultimately used Pixman to draw the
transformed output buffers onto a common image; switching to use
Pixman directly makes it easier to remove the Cairo dependency in the
future, and increases the number of buffer formats which the
rendering code can directly use.
This change also sometimes speeds up the image rendering, by using
Pixman's OP_SRC composition instead of the slower OP_OVER when we
are guaranteed that an output image will not share pixels with another
output's image when drawn on the common image. Cairo sometimes did
this, but not always.
The rendered images may change very slightly due to the new way of
computing transforms, which has slightly different rounding artifacts.
This is a documentation tweak to say that if no filename is given, and no
relevant environment variables are set, grim will write to the current working
directory.
This fixes grim to treat the rotations as counterclockwise and applied
to the surface. This became necessary because wlroots recently corrected
its rotation similarly in https://github.com/swaywm/wlroots/pull/2023.