[PATCH xserver 1/3] xfree86/modes: Move gamma initialization to xf86RandR12Init12 v2

walter harms wharms at bfs.de
Thu Jul 28 07:33:12 UTC 2016


>>>              output->crtc = NULL;
>>> diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
>>> index 9f93270..5b24ebb 100644
>>> --- a/hw/xfree86/modes/xf86RandR12.c
>>> +++ b/hw/xfree86/modes/xf86RandR12.c
>>> @@ -1313,6 +1313,116 @@ xf86RandR12CrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc)
>>>      return TRUE;
>>>  }
>>>
>>> +static void
>>> +init_one_component(CARD16 *comp, unsigned size, unsigned shift, float gamma)
>>> +{
>>> +    int i;
>>> +
>>> +    if (gamma == 1.0) {
>>> +        for (i = 0; i < size; i++)
>>> +            comp[i] = i << shift;
>>> +    } else {
>>> +        for (i = 0; i < size; i++)
>> I know it was not the the original source but to have a change to read this ...
>>
>>           double a=(double) i / (double) (size - 1);
>>           double b=(double) (size - 1) * (1 << shift)    //const
>>           double c= 1.0 / (double) gamma;                //const
>>
>>           comp[i] = (CARD16) (pow(a,c)*b);
>>
>> feel free to move the lines marked const out of the loop to be faster
> 
> I feel confident the compiler is already doing that transformation.
> _______________________________________________

1. I do not want to start an argument here.

but i seems i need to explain what i wanted to say:
"b and c do not change inside the loop"

that does *not* mean I have to say: const double or so.

In my experience just moving that outside the loop give the
compiler enought insight.

2. Opinion: it is important that a user can read/understand
            the code, perhaps some can come up with a less
            hungry formula.


re,
 wh






More information about the xorg-devel mailing list