GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_generic_glyph_8bpp_draw.c Lines: 38 38 100.0 %
Date: 2026-03-06 19:21:09 Branches: 20 20 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
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
#include "gx_display.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_display_driver_generic_glyph_8bit_draw          PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function draws the specified text using the current context,   */
46
/*    clipped to one viewport                                             */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    context                               Draw context                  */
51
/*    draw_position                         The X and Y coordinate where  */
52
/*                                            the glyph is drawn to       */
53
/*    string                                String to draw                */
54
/*    count                                 Count of string characters    */
55
/*    view                                  view to clip drawing within   */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    None                                                                */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    [gx_display_driver_pixel_blend]       Call display driver pixel     */
64
/*                                            blend function              */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    GUIX internal code                                                  */
69
/*                                                                        */
70
/**************************************************************************/
71
4668470
VOID _gx_display_driver_generic_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
72
{
73
GX_DISPLAY *display;
74
GX_UBYTE   *glyph_row;
75
GX_UBYTE   *glyph_data;
76
UINT        row;
77
UINT        col;
78
4668470
UINT        pixel_width = 0;
79
GX_COLOR    text_color;
80
UINT        y_height;
81
GX_UBYTE    alpha1;
82
4668470
GX_UBYTE    brush_alpha = 0xff;
83
84
#if defined (GX_BRUSH_ALPHA_SUPPORT)
85
4668470
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
86
4668470
    if (brush_alpha == 0)
87
    {
88
1876
        return;
89
    }
90
#endif
91
92
4666594
    text_color =  context -> gx_draw_context_brush.gx_brush_line_color;
93
4666594
    pixel_width = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
94
95
    /* pickup pointer to current display driver */
96
4666594
    display = context -> gx_draw_context_display;
97
98
4666594
    if (display -> gx_display_driver_pixel_blend == GX_NULL)
99
    {
100
8953
        return;
101
    }
102
103
4657641
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
104
105
4657641
    if (map_offset -> gx_point_y)
106
    {
107
16034
        glyph_row = glyph_row + (glyph -> gx_glyph_width * map_offset -> gx_point_y);
108
    }
109
110
4657641
    glyph_row += map_offset -> gx_point_x;
111
112
4657641
    y_height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
113
114
4657641
    if (brush_alpha == 0xff)
115
    {
116
50786456
        for (row = 0; row < y_height; row++)
117
        {
118
46558140
            glyph_data = glyph_row;
119
120
404973557
            for (col = 0; col < pixel_width; col++)
121
            {
122
358415417
                alpha1 = *glyph_data;
123
124
358415417
                if (alpha1 > 0)
125
                {
126
213772112
                    display -> gx_display_driver_pixel_blend(context,
127
213772112
                                                           draw_area -> gx_rectangle_left + (GX_VALUE)col,
128
213772112
                                                           draw_area -> gx_rectangle_top + (GX_VALUE)row,
129
                                                           text_color, (GX_UBYTE)alpha1);
130
                }
131
358415417
                glyph_data++;
132
            }
133
46558140
            glyph_row += glyph -> gx_glyph_width;
134
        }
135
    }
136
#if defined (GX_BRUSH_ALPHA_SUPPORT)
137
    else
138
    {
139
5210071
        for (row = 0; row < y_height; row++)
140
        {
141
4780746
            glyph_data = glyph_row;
142
143
41989827
            for (col = 0; col < pixel_width; col++)
144
            {
145
37209081
                alpha1 = *glyph_data;
146
37209081
                alpha1 = (GX_UBYTE)(alpha1 * brush_alpha / 255);
147
148
37209081
                if (alpha1 > 0)
149
                {
150
21315988
                    display -> gx_display_driver_pixel_blend(context,
151
21315988
                                                           draw_area -> gx_rectangle_left + (GX_VALUE)col,
152
21315988
                                                           draw_area -> gx_rectangle_top + (GX_VALUE)row,
153
                                                           text_color, (GX_UBYTE)alpha1);
154
                }
155
156
37209081
                glyph_data++;
157
            }
158
4780746
            glyph_row += glyph -> gx_glyph_width;
159
        }
160
    }
161
#endif
162
}
163