pixman-access.c: Add floating point accessor functions
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 18 Aug 2012 17:22:15 +0000 (13:22 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Mon, 1 Oct 2012 16:56:09 +0000 (12:56 -0400)
commite75bacc5f9196c3980ce331c7d53de5b7e92d699
tree0eeac9a17139c3f3dbac7cbb9c8cb79ddf55dc21
parent23252393a2dcae4dc5a7d03727dd66cdd81286ba
pixman-access.c: Add floating point accessor functions

Three new function pointer fields are added to bits_image_t:

      fetch_scanline_float
      fetch_pixel_float
      store_scanline_float

similar to the existing 32 and 64 bit accessors. The fetcher_info_t
struct in pixman_access similarly gets a new get_scanline_float field.

For most formats, the new get_scanline_float field is set to a new
function fetch_scanline_generic_float() that first calls the 32 bit
fetcher uses the 32 bit scanline fetcher and then expands these pixels
to floating point.

For the 10 bpc formats, new floating point accessors are added that
use pixman_unorm_to_float() and pixman_float_to_unorm() to convert
back and forth.

The PIXMAN_a8r8g8b8_sRGB format is handled with a 256-entry table that
maps 8 bit sRGB channels to linear single precision floating point
numbers. The sRGB->linear direction can then be done with a simple
table lookup.

The other direction is currently done with 4096-entry table which
works fine for 16 bit integers, but not so great for floating
point. So instead this patch uses a binary search in the sRGB->linear
table. The existing 32 bit accessors for the sRGB format are also
converted to use this method.
pixman/pixman-access.c
pixman/pixman-bits-image.c
pixman/pixman-private.h