[PATCH] input: drop FP16161 macro

Søren Sandmann sandmann at cs.au.dk
Tue Nov 6 12:23:01 PST 2012


Peter Hutterer <peter.hutterer at who-t.net> writes:

> The double_to_f1616() functions do the same thing, and they're tested.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Turns out we already have these functions and the macro was just a leftover
> from earlier, happier times.

Is there any reason to not just use the pixman_double_to_fixed() macro:

    #define pixman_double_to_fixed(d)  ((pixman_fixed_t) ((d) * 65536.0))

The double_to_fp1616() function looks rather complicated and slow:

    FP1616
    double_to_fp1616(double in)
    {
        FP1616 ret;
        int32_t integral;
        double tmp;
        uint32_t frac_d;
    
        tmp = floor(in);
        integral = (int32_t) tmp;
    
        tmp = (in - integral) * (1UL << 16);        /* Optimized: ldexp(in - integral, 16) */
        frac_d = (uint16_t) tmp;
    
        ret = integral << 16;
        ret |= frac_d & 0xffff;
        return ret;
    }


Søren



More information about the xorg-devel mailing list