[cairo] [PATCH]: pixman: New functions for converting format to/from masks
Soeren Sandmann
sandmann at daimi.au.dk
Tue Mar 25 12:24:03 PDT 2008
Carl Worth <cworth at redhat.com> writes:
> Here is a small (two commit) patch series that adds this little bit of
> new API to pixman:
>
> typedef struct _pixman_format_masks {
> int bpp;
> unsigned long alpha_mask;
> unsigned long red_mask;
> unsigned long green_mask;
> unsigned long blue_mask;
> } pixman_format_masks_t;
>
> /* Format conversion */
> PIXMAN_EXPORT
> pixman_bool_t pixman_format_code_to_masks (pixman_format_code_t code,
> pixman_format_masks_t *masks);
>
> PIXMAN_EXPORT
> pixman_bool_t pixman_format_masks_to_code (pixman_format_masks_t *masks,
> pixman_format_code_t *code_ret);
>
> See the patch itself for complete documentation of these functions.
>
> This functionality currently lives within cairo itself, but really
> needs to live in pixman. As can be seen in the patch series, the cairo
> versions are already very incomplete with respect to what formats
> pixman provides.
The main issue I see with this is that a pixman format can't really be
fully described by that struct. For example formats with 16 bits per
channel or floating point formats will not be describable.
What does describe a pixman format is the format code itself,
though.
The functions above do not really produce anything information that a
pixman user doesn't already have. Because of this, and because the
main use of these functions would be to convert to and from XImage
formats, I don't see it as all that bad if they live in cairo.
As far as I can tell, the pixman_format_code_to_masks() in your patch
is already as general as the pixman version could be, given that only
32 bit or less fixpoint formats are possible for XImage.
The _from_masks() function could be written with
PIXMAN_FORMAT(t,bpp,a,r,g,b) macro to construct a format by
itself.
The issue with that is that there is no guarantee that the format
would be supported by pixman, so we would need a couple of new
functions:
pixman_format_supported_destination ()
pixman_format_supported_source()
Both functions would simply return TRUE for all supported formats,
except that the destination one would return FALSE for YUV formats.
(Also, I'd prefer that the code goes into pixman-utils.c instead of
the new pixman-format.c).
Soren
More information about the cairo
mailing list