gfx/cairo/libpixman/src/pixman-solid-fill.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/libpixman/src/pixman-solid-fill.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/*
     1.5 + * Copyright © 2000 SuSE, Inc.
     1.6 + * Copyright © 2007, 2009 Red Hat, Inc.
     1.7 + * Copyright © 2009 Soren Sandmann
     1.8 + *
     1.9 + * Permission to use, copy, modify, distribute, and sell this software and its
    1.10 + * documentation for any purpose is hereby granted without fee, provided that
    1.11 + * the above copyright notice appear in all copies and that both that
    1.12 + * copyright notice and this permission notice appear in supporting
    1.13 + * documentation, and that the name of SuSE not be used in advertising or
    1.14 + * publicity pertaining to distribution of the software without specific,
    1.15 + * written prior permission.  SuSE makes no representations about the
    1.16 + * suitability of this software for any purpose.  It is provided "as is"
    1.17 + * without express or implied warranty.
    1.18 + *
    1.19 + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
    1.20 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
    1.21 + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    1.22 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
    1.23 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
    1.24 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    1.25 + */
    1.26 +
    1.27 +#ifdef HAVE_CONFIG_H
    1.28 +#include <config.h>
    1.29 +#endif
    1.30 +#include "pixman-private.h"
    1.31 +
    1.32 +static uint32_t
    1.33 +color_to_uint32 (const pixman_color_t *color)
    1.34 +{
    1.35 +    return
    1.36 +        (color->alpha >> 8 << 24) |
    1.37 +        (color->red >> 8 << 16) |
    1.38 +        (color->green & 0xff00) |
    1.39 +        (color->blue >> 8);
    1.40 +}
    1.41 +
    1.42 +static argb_t
    1.43 +color_to_float (const pixman_color_t *color)
    1.44 +{
    1.45 +    argb_t result;
    1.46 +
    1.47 +    result.a = pixman_unorm_to_float (color->alpha, 16);
    1.48 +    result.r = pixman_unorm_to_float (color->red, 16);
    1.49 +    result.g = pixman_unorm_to_float (color->green, 16);
    1.50 +    result.b = pixman_unorm_to_float (color->blue, 16);
    1.51 +
    1.52 +    return result;
    1.53 +}
    1.54 +
    1.55 +PIXMAN_EXPORT pixman_image_t *
    1.56 +pixman_image_create_solid_fill (const pixman_color_t *color)
    1.57 +{
    1.58 +    pixman_image_t *img = _pixman_image_allocate ();
    1.59 +
    1.60 +    if (!img)
    1.61 +	return NULL;
    1.62 +
    1.63 +    img->type = SOLID;
    1.64 +    img->solid.color = *color;
    1.65 +    img->solid.color_32 = color_to_uint32 (color);
    1.66 +    img->solid.color_float = color_to_float (color);
    1.67 +
    1.68 +    return img;
    1.69 +}
    1.70 +

mercurial