1317c648bSmrg/*
2317c648bSmrg * Copyright © 2000 SuSE, Inc.
3317c648bSmrg * Copyright © 2007, 2009 Red Hat, Inc.
4317c648bSmrg * Copyright © 2009 Soren Sandmann
5317c648bSmrg *
6317c648bSmrg * Permission to use, copy, modify, distribute, and sell this software and its
7317c648bSmrg * documentation for any purpose is hereby granted without fee, provided that
8317c648bSmrg * the above copyright notice appear in all copies and that both that
9317c648bSmrg * copyright notice and this permission notice appear in supporting
10317c648bSmrg * documentation, and that the name of SuSE not be used in advertising or
11317c648bSmrg * publicity pertaining to distribution of the software without specific,
12317c648bSmrg * written prior permission.  SuSE makes no representations about the
13317c648bSmrg * suitability of this software for any purpose.  It is provided "as is"
14317c648bSmrg * without express or implied warranty.
15317c648bSmrg *
16317c648bSmrg * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17317c648bSmrg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
18317c648bSmrg * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19317c648bSmrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20317c648bSmrg * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21317c648bSmrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22317c648bSmrg */
23317c648bSmrg
24a450e446Smrg#ifdef HAVE_CONFIG_H
2514b11b2bSmrg#include <pixman-config.h>
26a450e446Smrg#endif
27317c648bSmrg#include "pixman-private.h"
28317c648bSmrg
29317c648bSmrgstatic uint32_t
30317c648bSmrgcolor_to_uint32 (const pixman_color_t *color)
31317c648bSmrg{
32317c648bSmrg    return
334f2886e8Smrg        ((unsigned int) color->alpha >> 8 << 24) |
344f2886e8Smrg        ((unsigned int) color->red >> 8 << 16) |
354f2886e8Smrg        ((unsigned int) color->green & 0xff00) |
364f2886e8Smrg        ((unsigned int) color->blue >> 8);
37317c648bSmrg}
38317c648bSmrg
399ad247e8Sjmcneillstatic argb_t
409ad247e8Sjmcneillcolor_to_float (const pixman_color_t *color)
41952204abSmrg{
429ad247e8Sjmcneill    argb_t result;
439ad247e8Sjmcneill
449ad247e8Sjmcneill    result.a = pixman_unorm_to_float (color->alpha, 16);
459ad247e8Sjmcneill    result.r = pixman_unorm_to_float (color->red, 16);
469ad247e8Sjmcneill    result.g = pixman_unorm_to_float (color->green, 16);
479ad247e8Sjmcneill    result.b = pixman_unorm_to_float (color->blue, 16);
489ad247e8Sjmcneill
499ad247e8Sjmcneill    return result;
50952204abSmrg}
51952204abSmrg
52317c648bSmrgPIXMAN_EXPORT pixman_image_t *
539ad247e8Sjmcneillpixman_image_create_solid_fill (const pixman_color_t *color)
54317c648bSmrg{
55d0321353Smrg    pixman_image_t *img = _pixman_image_allocate ();
56d0321353Smrg
57317c648bSmrg    if (!img)
58317c648bSmrg	return NULL;
59317c648bSmrg
60317c648bSmrg    img->type = SOLID;
61952204abSmrg    img->solid.color = *color;
62952204abSmrg    img->solid.color_32 = color_to_uint32 (color);
639ad247e8Sjmcneill    img->solid.color_float = color_to_float (color);
64317c648bSmrg
65317c648bSmrg    return img;
66317c648bSmrg}
67d0321353Smrg
68