mirror of
https://salsa.debian.org/xorg-team/lib/pixman
synced 2025-09-02 03:38:55 +00:00
Simplify gradient_walker_reset()
The code that searches for the closest color stop to the given position is duplicated across the various repeat modes. Replace the switch with two if/else constructions, and put the search code between them.
This commit is contained in:
parent
2d0da8ab8d
commit
ec7c9c2b68
@ -56,44 +56,20 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
|
|||||||
int n, count = walker->num_stops;
|
int n, count = walker->num_stops;
|
||||||
pixman_gradient_stop_t *stops = walker->stops;
|
pixman_gradient_stop_t *stops = walker->stops;
|
||||||
|
|
||||||
switch (walker->repeat)
|
if (walker->repeat == PIXMAN_REPEAT_NORMAL)
|
||||||
{
|
{
|
||||||
case PIXMAN_REPEAT_NORMAL:
|
x = (int32_t)pos & 0xffff;
|
||||||
x = (int32_t)pos & 0xFFFF;
|
|
||||||
for (n = 0; n < count; n++)
|
|
||||||
{
|
|
||||||
if (x < stops[n].x)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (walker->repeat == PIXMAN_REPEAT_REFLECT)
|
||||||
left_x = stops[n - 1].x;
|
|
||||||
left_c = &stops[n - 1].color;
|
|
||||||
|
|
||||||
right_x = stops[n].x;
|
|
||||||
right_c = &stops[n].color;
|
|
||||||
|
|
||||||
left_x += (pos - x);
|
|
||||||
right_x += (pos - x);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PIXMAN_REPEAT_PAD:
|
|
||||||
for (n = 0; n < count; n++)
|
|
||||||
{
|
{
|
||||||
if (pos < stops[n].x)
|
x = (int32_t)pos & 0xffff;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
left_x = stops[n - 1].x;
|
|
||||||
left_c = &stops[n - 1].color;
|
|
||||||
|
|
||||||
right_x = stops[n].x;
|
|
||||||
right_c = &stops[n].color;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PIXMAN_REPEAT_REFLECT:
|
|
||||||
x = (int32_t)pos & 0xFFFF;
|
|
||||||
if ((int32_t)pos & 0x10000)
|
if ((int32_t)pos & 0x10000)
|
||||||
x = 0x10000 - x;
|
x = 0x10000 - x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = pos;
|
||||||
|
}
|
||||||
|
|
||||||
for (n = 0; n < count; n++)
|
for (n = 0; n < count; n++)
|
||||||
{
|
{
|
||||||
@ -107,6 +83,13 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
|
|||||||
right_x = stops[n].x;
|
right_x = stops[n].x;
|
||||||
right_c = &stops[n].color;
|
right_c = &stops[n].color;
|
||||||
|
|
||||||
|
if (walker->repeat == PIXMAN_REPEAT_NORMAL)
|
||||||
|
{
|
||||||
|
left_x += (pos - x);
|
||||||
|
right_x += (pos - x);
|
||||||
|
}
|
||||||
|
else if (walker->repeat == PIXMAN_REPEAT_REFLECT)
|
||||||
|
{
|
||||||
if ((int32_t)pos & 0x10000)
|
if ((int32_t)pos & 0x10000)
|
||||||
{
|
{
|
||||||
pixman_color_t *tmp_c;
|
pixman_color_t *tmp_c;
|
||||||
@ -124,20 +107,6 @@ gradient_walker_reset (pixman_gradient_walker_t *walker,
|
|||||||
}
|
}
|
||||||
left_x += (pos - x);
|
left_x += (pos - x);
|
||||||
right_x += (pos - x);
|
right_x += (pos - x);
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* REPEAT_NONE */
|
|
||||||
for (n = 0; n < count; n++)
|
|
||||||
{
|
|
||||||
if (pos < stops[n].x)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
left_x = stops[n - 1].x;
|
|
||||||
left_c = &stops[n - 1].color;
|
|
||||||
|
|
||||||
right_x = stops[n].x;
|
|
||||||
right_c = &stops[n].color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
walker->left_x = left_x;
|
walker->left_x = left_x;
|
||||||
|
Loading…
Reference in New Issue
Block a user