diff options
author | Soren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com> | 2007-04-20 14:51:40 -0400 |
---|---|---|
committer | Soren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com> | 2007-04-21 17:10:54 -0400 |
commit | 41dd7ab067adde8f66cd9f74c5a6570c325518a5 (patch) | |
tree | e294df846a898ff3cc7166fa6764d2986e8df60f /fb | |
parent | c1b73f0f2acd56b423b91a04f1e1b3cdcad0069f (diff) |
Fix gradient walker to not reset needlessly
Previously the gradient walker was doing excessive resets, (such
as on every pixel in constant-colored regions or outside the
gradient with CAIRO_EXTEND_NONE). Don't do that.
Carl Worth, from pixman
Diffstat (limited to 'fb')
-rw-r--r-- | fb/fbcompose.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fb/fbcompose.c b/fb/fbcompose.c index 365a85fa0..6b366f793 100644 --- a/fb/fbcompose.c +++ b/fb/fbcompose.c @@ -2803,12 +2803,13 @@ typedef struct CARD32 right_rb; int32_t left_x; int32_t right_x; - int32_t width_x; int32_t stepper; PictGradientStopPtr stops; int num_stops; unsigned int spread; + + int need_reset; } GradientWalker; static void @@ -2820,13 +2821,14 @@ _gradient_walker_init (GradientWalker *walker, walker->stops = pGradient->gradient.stops; walker->left_x = 0; walker->right_x = 0x10000; - walker->width_x = 0; /* will force a reset */ walker->stepper = 0; walker->left_ag = 0; walker->left_rb = 0; walker->right_ag = 0; walker->right_rb = 0; walker->spread = spread; + + walker->need_reset = TRUE; } static void @@ -2958,27 +2960,29 @@ _gradient_walker_reset (GradientWalker *walker, walker->left_x = left_x; walker->right_x = right_x; - walker->width_x = right_x - left_x; walker->left_ag = ((left_c->alpha >> 8) << 16) | (left_c->green >> 8); walker->left_rb = ((left_c->red & 0xff00) << 8) | (left_c->blue >> 8); walker->right_ag = ((right_c->alpha >> 8) << 16) | (right_c->green >> 8); walker->right_rb = ((right_c->red & 0xff00) << 8) | (right_c->blue >> 8); - if ( walker->width_x == 0 || + if ( walker->left_x == walker->right_x || ( walker->left_ag == walker->right_ag && walker->left_rb == walker->right_rb ) ) { - walker->width_x = 1; walker->stepper = 0; } else { - walker->stepper = ((1 << 24) + walker->width_x/2)/walker->width_x; + int32_t width = right_x - left_x; + walker->stepper = ((1 << 24) + width/2)/width; } + + walker->need_reset = FALSE; } #define GRADIENT_WALKER_NEED_RESET(w,x) \ - ( (x) < (w)->left_x || (x) - (w)->left_x >= (w)->width_x ) + ( (w)->need_reset || (x) < (w)->left_x || (x) >= (w)->right_x) + /* the following assumes that GRADIENT_WALKER_NEED_RESET(w,x) is FALSE */ static CARD32 |