GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_24xrgb_rotated_pixel_blend.c Lines: 23 23 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
#define GX_SOURCE_CODE
22
23
/* Include necessary system files.  */
24
25
#include "gx_api.h"
26
#include "gx_display.h"
27
28
/**************************************************************************/
29
/*                                                                        */
30
/*  FUNCTION                                               RELEASE        */
31
/*                                                                        */
32
/*    _gx_display_driver_24xrgb_rotated_pixel_blend       PORTABLE C      */
33
/*                                                           6.1.4        */
34
/*  AUTHOR                                                                */
35
/*                                                                        */
36
/*    Kenneth Maxwell, Microsoft Corporation                              */
37
/*                                                                        */
38
/*  DESCRIPTION                                                           */
39
/*                                                                        */
40
/*    Rotated pixel blend function for 24xrgb color format.               */
41
/*                                                                        */
42
/*  INPUT                                                                 */
43
/*                                                                        */
44
/*    context                               Drawing context               */
45
/*    x                                     X coordinate                  */
46
/*    y                                     Y coordinate                  */
47
/*    color                                 Color of line to write        */
48
/*    alpha                                 Alpha value                   */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    REDVAL_24BPP                          Extract the red component     */
57
/*    GREENVAL_24BPP                        Extract the green component   */
58
/*    BLUEVAL_24BPP                         Extract the blue component    */
59
/*    ASSEMBLECOLOR_24BPP                   Assemble color components     */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
1609540
VOID _gx_display_driver_24xrgb_rotated_pixel_blend(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR fcolor, GX_UBYTE alpha)
67
{
68
GX_UBYTE fred, fgreen, fblue;
69
GX_UBYTE bred, bgreen, bblue;
70
GX_UBYTE balpha;
71
ULONG    bcolor;
72
ULONG   *put;
73
74
75
    /* Is the pixel non-transparent?  */
76
1609540
    if (alpha > 0)
77
    {
78
        /* Calculate address of pixel.  */
79
1604084
        put = (ULONG *)context -> gx_draw_context_memory;
80
81
1604084
        if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
82
        {
83
712965
            put += context -> gx_draw_context_pitch * (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - x - 1);
84
712965
            put += y;
85
        }
86
        else
87
        {
88
891119
            put += context -> gx_draw_context_pitch * x;
89
891119
            put += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - y - 1);
90
        }
91
92
        /* No need to blend if alpha value is 255.  */
93
1604084
        if (alpha == 255)
94
        {
95
5834
            *put = (ULONG)(fcolor | 0xff000000);
96
97
5834
            return;
98
        }
99
100
        /* Split foreground into red, green, and blue components.  */
101
1598250
        fred = REDVAL_24BPP(fcolor);
102
1598250
        fgreen = GREENVAL_24BPP(fcolor);
103
1598250
        fblue = BLUEVAL_24BPP(fcolor);
104
105
        /* Read background color.  */
106
1598250
        bcolor = *put;
107
108
        /* Split background color into red, green, and blue components.  */
109
1598250
        bred = REDVAL_24BPP(bcolor);
110
1598250
        bgreen = GREENVAL_24BPP(bcolor);
111
1598250
        bblue = BLUEVAL_24BPP(bcolor);
112
113
        /* Background alpha is inverse of foreground alpha.  */
114
1598250
        balpha = (GX_UBYTE)(256 - alpha);
115
116
        /* Blend foreground and background, each color channel.  */
117
1598250
        fred = (GX_UBYTE)(((bred * balpha) + (fred * alpha)) >> 8);
118
1598250
        fgreen = (GX_UBYTE)(((bgreen * balpha) + (fgreen * alpha)) >> 8);
119
1598250
        fblue = (GX_UBYTE)(((bblue * balpha) + (fblue * alpha)) >> 8);
120
121
        /* Re-assemble into 32-bit color and write it out.  */
122
1598250
        *put = (ULONG)(ASSEMBLECOLOR_32ARGB(0xff, fred, fgreen, fblue));
123
    }
124
}
125