[cairo] Re: [cairo-commit] src/cairo-color.c

Behdad Esfahbod behdad at behdad.org
Sat May 5 11:22:06 PDT 2007


On Sat, 2007-05-05 at 07:35 -0400, Chris Wilson wrote:
>  src/cairo-color.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletion(-)
> 
> New commits:
> diff-tree d81907734e18fb9302e78eccb1e25a838223b726 (from 966a39396eb75d9d4ecc9997bb21d62fba176f78)
> Author: Chris Wilson <chris at chris-wilson.co.uk>
> Date:   Sat May 5 12:33:29 2007 +0100
> 
>     [cairo-color] Only compare the shorts for equality.
>     
>     By only checking the premultiplied shorts inside the cairo_color_t we
>     only have to compare at most 8 bytes instead of the full 24 bytes.

Humm, but the doubles may be different.  That's because we clamp when
converting to short, but keep the originals.

Not sure how relevant this is.

behdad


> diff --git a/src/cairo-color.c b/src/cairo-color.c
> index 257f8d2..50a9a1c 100644
> --- a/src/cairo-color.c
> +++ b/src/cairo-color.c
> @@ -165,5 +165,8 @@ cairo_bool_t
>  _cairo_color_equal (const cairo_color_t *color_a,
>  	            const cairo_color_t *color_b)
>  {
> -    return memcmp (color_a, color_b, sizeof (cairo_color_t)) == 0;
> +    return color_a->red_short   == color_b->red_short   &&
> +           color_a->green_short == color_b->green_short &&
> +           color_a->blue_short  == color_b->blue_short  &&
> +           color_a->alpha_short == color_b->alpha_short;
>  }
> _______________________________________________
> cairo-commit mailing list
> cairo-commit at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo-commit
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list