Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright © 2000 SuSE, Inc. |
michael@0 | 3 | * Copyright © 2007, 2009 Red Hat, Inc. |
michael@0 | 4 | * Copyright © 2009 Soren Sandmann |
michael@0 | 5 | * |
michael@0 | 6 | * Permission to use, copy, modify, distribute, and sell this software and its |
michael@0 | 7 | * documentation for any purpose is hereby granted without fee, provided that |
michael@0 | 8 | * the above copyright notice appear in all copies and that both that |
michael@0 | 9 | * copyright notice and this permission notice appear in supporting |
michael@0 | 10 | * documentation, and that the name of SuSE not be used in advertising or |
michael@0 | 11 | * publicity pertaining to distribution of the software without specific, |
michael@0 | 12 | * written prior permission. SuSE makes no representations about the |
michael@0 | 13 | * suitability of this software for any purpose. It is provided "as is" |
michael@0 | 14 | * without express or implied warranty. |
michael@0 | 15 | * |
michael@0 | 16 | * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL |
michael@0 | 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE |
michael@0 | 18 | * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
michael@0 | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
michael@0 | 20 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
michael@0 | 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | #ifdef HAVE_CONFIG_H |
michael@0 | 25 | #include <config.h> |
michael@0 | 26 | #endif |
michael@0 | 27 | #include "pixman-private.h" |
michael@0 | 28 | |
michael@0 | 29 | static uint32_t |
michael@0 | 30 | color_to_uint32 (const pixman_color_t *color) |
michael@0 | 31 | { |
michael@0 | 32 | return |
michael@0 | 33 | (color->alpha >> 8 << 24) | |
michael@0 | 34 | (color->red >> 8 << 16) | |
michael@0 | 35 | (color->green & 0xff00) | |
michael@0 | 36 | (color->blue >> 8); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | static argb_t |
michael@0 | 40 | color_to_float (const pixman_color_t *color) |
michael@0 | 41 | { |
michael@0 | 42 | argb_t result; |
michael@0 | 43 | |
michael@0 | 44 | result.a = pixman_unorm_to_float (color->alpha, 16); |
michael@0 | 45 | result.r = pixman_unorm_to_float (color->red, 16); |
michael@0 | 46 | result.g = pixman_unorm_to_float (color->green, 16); |
michael@0 | 47 | result.b = pixman_unorm_to_float (color->blue, 16); |
michael@0 | 48 | |
michael@0 | 49 | return result; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | PIXMAN_EXPORT pixman_image_t * |
michael@0 | 53 | pixman_image_create_solid_fill (const pixman_color_t *color) |
michael@0 | 54 | { |
michael@0 | 55 | pixman_image_t *img = _pixman_image_allocate (); |
michael@0 | 56 | |
michael@0 | 57 | if (!img) |
michael@0 | 58 | return NULL; |
michael@0 | 59 | |
michael@0 | 60 | img->type = SOLID; |
michael@0 | 61 | img->solid.color = *color; |
michael@0 | 62 | img->solid.color_32 = color_to_uint32 (color); |
michael@0 | 63 | img->solid.color_float = color_to_float (color); |
michael@0 | 64 | |
michael@0 | 65 | return img; |
michael@0 | 66 | } |
michael@0 | 67 |