Coverage Report

Created: 2025-07-23 08:13

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