[PATCH weston] cairo-util: fix shadows for small clients
mchqwerty at gmail.com
Wed Oct 29 03:09:05 PDT 2014
thanks for review!
On 27 October 2014 18:50, Bill Spitzak <spitzak at gmail.com> wrote:
> On 10/15/2014 01:16 AM, Marek Chalupa wrote:
>> + shadow_height = height / 2;
>> + /* when the height is odd, we need some part of
>> + * shadow to be one pixel higher. Let's choose the
>> + * upper one */
>> + if (height % 2 != 0 && !fy)
>> + ++shadow_height;
> This does the same thing:
> shadow_height = (height + (fy ? 0 : 1)) / 2;
Thinking about that, fy is always 0 or 1, so it will work even without the
ternary operator. And if we want to be really sure that fy is 0 or 1 (even
somebody will change its values range) we can do:
shadow_height = (height + !fy) / 2;
It definitely looks better than the former code.
> If there is any chance height is negative you want to use >>1 rather than
> /2. This is because it always rounds in the same direction (down rather
> than toward zero). I don't think negative height happens here, however.
Good point. Hypothetically, the height can be negative, because its given
from the client - but then the mistake is on the client's side and it would
break much more things than one-pixel error in shadow. Maybe we should add
a check for negative values, but that belongs in another patch. I gonna go
for /2 because it does the same thing (assuming correct input) and it is
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wayland-devel