michael@0: /* michael@0: * Copyright © 2000 SuSE, Inc. michael@0: * Copyright © 2007, 2009 Red Hat, Inc. michael@0: * Copyright © 2009 Soren Sandmann michael@0: * michael@0: * Permission to use, copy, modify, distribute, and sell this software and its michael@0: * documentation for any purpose is hereby granted without fee, provided that michael@0: * the above copyright notice appear in all copies and that both that michael@0: * copyright notice and this permission notice appear in supporting michael@0: * documentation, and that the name of SuSE not be used in advertising or michael@0: * publicity pertaining to distribution of the software without specific, michael@0: * written prior permission. SuSE makes no representations about the michael@0: * suitability of this software for any purpose. It is provided "as is" michael@0: * without express or implied warranty. michael@0: * michael@0: * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE michael@0: * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES michael@0: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION michael@0: * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN michael@0: * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. michael@0: */ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: #include "pixman-private.h" michael@0: michael@0: static uint32_t michael@0: color_to_uint32 (const pixman_color_t *color) michael@0: { michael@0: return michael@0: (color->alpha >> 8 << 24) | michael@0: (color->red >> 8 << 16) | michael@0: (color->green & 0xff00) | michael@0: (color->blue >> 8); michael@0: } michael@0: michael@0: static argb_t michael@0: color_to_float (const pixman_color_t *color) michael@0: { michael@0: argb_t result; michael@0: michael@0: result.a = pixman_unorm_to_float (color->alpha, 16); michael@0: result.r = pixman_unorm_to_float (color->red, 16); michael@0: result.g = pixman_unorm_to_float (color->green, 16); michael@0: result.b = pixman_unorm_to_float (color->blue, 16); michael@0: michael@0: return result; michael@0: } michael@0: michael@0: PIXMAN_EXPORT pixman_image_t * michael@0: pixman_image_create_solid_fill (const pixman_color_t *color) michael@0: { michael@0: pixman_image_t *img = _pixman_image_allocate (); michael@0: michael@0: if (!img) michael@0: return NULL; michael@0: michael@0: img->type = SOLID; michael@0: img->solid.color = *color; michael@0: img->solid.color_32 = color_to_uint32 (color); michael@0: img->solid.color_float = color_to_float (color); michael@0: michael@0: return img; michael@0: } michael@0: