GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_glyph_4bit_draw.c Lines: 41 41 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 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_8bpp_glyph_4bit_draw             PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This 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
/*    None                                                                */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    _gx_canvas_text_draw                                                */
68
/*                                                                        */
69
/**************************************************************************/
70
109080
VOID _gx_display_driver_8bpp_glyph_4bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
71
{
72
GX_UBYTE *glyph_row;
73
GX_UBYTE *glyph_data;
74
UINT      row;
75
109080
UINT      pixel_width = 0;
76
UINT      leading_pixel;
77
UINT      trailing_pixel;
78
GX_UBYTE  text_color;
79
UINT      y_height;
80
GX_UBYTE  alpha;
81
UINT      pitch;
82
UINT      index;
83
GX_UBYTE *put;
84
GX_UBYTE *draw_start;
85
86
109080
    text_color =  (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 15);
87
109080
    pixel_width = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
88
89
    /* Find the width of the glyph */
90
109080
    pitch = glyph -> gx_glyph_width;
91
    /* Make it byte-aligned. */
92
109080
    pitch = (pitch + 1) >> 1;
93
94
109080
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
95
96
109080
    if (map_offset -> gx_point_y)
97
    {
98
1284
        glyph_row = glyph_row + ((INT)pitch * map_offset -> gx_point_y);
99
    }
100
101
109080
    glyph_row += (map_offset -> gx_point_x >> 1);
102
103
109080
    y_height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
104
105
109080
    leading_pixel = (map_offset -> gx_point_x & 1);
106
107
109080
    pixel_width -= leading_pixel;
108
109
109080
    trailing_pixel = pixel_width & 1;
110
111
109080
    pixel_width = pixel_width >> 1;
112
113
114
109080
    draw_start = (GX_UBYTE *)context -> gx_draw_context_memory;
115
109080
    draw_start += context -> gx_draw_context_pitch * draw_area -> gx_rectangle_top;
116
109080
    draw_start += draw_area -> gx_rectangle_left;
117
118
1334784
    for (row = 0; row < y_height; row++)
119
    {
120
1225704
        glyph_data = glyph_row;
121
122
1225704
        put = draw_start;
123
124
1225704
        if (leading_pixel)
125
        {
126
6120
            alpha = (*glyph_data) & 0x0f;
127
128
6120
            *put = (GX_UBYTE)(text_color - alpha);
129
6120
            put++;
130
131
6120
            glyph_data++;
132
        }
133
5698296
        for (index = 0; index < pixel_width; index++)
134
        {
135
4472592
            alpha = (*glyph_data) & 0xf0;
136
137
4472592
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
138
4472592
            put++;
139
140
4472592
            alpha = (*glyph_data) & 0x0f;
141
4472592
            *put = (GX_UBYTE)(text_color - alpha);
142
4472592
            put++;
143
4472592
            glyph_data++;
144
        }
145
146
1225704
        if (trailing_pixel)
147
        {
148
710652
            alpha = (*glyph_data) & 0xf0;
149
710652
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
150
710652
            put++;
151
        }
152
153
1225704
        glyph_row += pitch;
154
1225704
        draw_start += context -> gx_draw_context_pitch;
155
    }
156
109080
}
157