GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_generic_rotated_glyph_8bit_draw.c Lines: 45 45 100.0 %
Date: 2026-03-06 19:21:09 Branches: 24 24 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_rotated_glyph_8bit_draw  PORTABLE C      */
38
/*                                                           6.1.3        */
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_565rgb_pixel_blend Call display driver pixel     */
64
/*                                            blend function              */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    GUIX internal code                                                  */
69
/*                                                                        */
70
/**************************************************************************/
71
413918
VOID _gx_display_driver_generic_rotated_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
72
{
73
GX_UBYTE *glyph_row;
74
GX_UBYTE *glyph_data;
75
UINT      row;
76
UINT      col;
77
413918
UINT      pixel_width = 0;
78
GX_COLOR  text_color;
79
UINT      y_height;
80
GX_UBYTE  alpha1;
81
413918
GX_UBYTE  brush_alpha = 0xff;
82
GX_VALUE  rotated_map_offset_x;
83
GX_VALUE  rotated_map_offset_y;
84
GX_VALUE  rotated_left;
85
GX_VALUE  rotated_top;
86
VOID     (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
87
88
#if defined(GX_BRUSH_ALPHA_SUPPORT)
89
413918
    brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
90
413918
    if (brush_alpha == 0)
91
    {
92
97
        return;
93
    }
94
#endif
95
96

413821
    GX_SET_BLEND_FUNCTION(blend_func, context->gx_draw_context_display->gx_display_color_format)
97
98
405355
    text_color = context -> gx_draw_context_brush.gx_brush_line_color;
99
100
405355
    pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
101
405355
    y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
102
103
405355
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
104
    {
105
247361
        rotated_left = draw_area -> gx_rectangle_top;
106
247361
        rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1);
107
108
247361
        rotated_map_offset_x = map_offset -> gx_point_y;
109
247361
        rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height);
110
    }
111
    else
112
    {
113
157994
        rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1);
114
157994
        rotated_top = draw_area -> gx_rectangle_left;
115
116
157994
        rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width);
117
157994
        rotated_map_offset_y = map_offset -> gx_point_x;
118
    }
119
120
405355
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
121
122
405355
    if (rotated_map_offset_y)
123
    {
124
3971
        glyph_row = glyph_row + (glyph -> gx_glyph_height * rotated_map_offset_y);
125
    }
126
127
405355
    glyph_row += rotated_map_offset_x;
128
129
405355
    if (brush_alpha == 0xff)
130
    {
131
3715433
        for (row = 0; row < y_height; row++)
132
        {
133
3310521
            glyph_data = glyph_row;
134
135
41427421
            for (col = 0; col < pixel_width; col++)
136
            {
137
38116900
                alpha1 = *glyph_data;
138
139
38116900
                if (alpha1 > 0)
140
                {
141
25051715
                    blend_func(context,
142
25051715
                               rotated_left + (GX_VALUE)col,
143
25051715
                               rotated_top + (GX_VALUE)row,
144
                               text_color, (GX_UBYTE)alpha1);
145
                }
146
38116900
                glyph_data++;
147
            }
148
3310521
            glyph_row += glyph -> gx_glyph_height;
149
        }
150
    }
151
#if defined(GX_BRUSH_ALPHA_SUPPORT)
152
    else
153
    {
154
6853
        for (row = 0; row < y_height; row++)
155
        {
156
6410
            glyph_data = glyph_row;
157
158
123180
            for (col = 0; col < pixel_width; col++)
159
            {
160
116770
                alpha1 = *glyph_data;
161
116770
                alpha1 = (GX_UBYTE)(alpha1 * brush_alpha / 255);
162
163
116770
                if (alpha1 > 0)
164
                {
165
56506
                    blend_func(context,
166
56506
                               rotated_left + (GX_VALUE)col,
167
56506
                               rotated_top + (GX_VALUE)row,
168
                               text_color, (GX_UBYTE)alpha1);
169
                }
170
171
116770
                glyph_data++;
172
            }
173
6410
            glyph_row += glyph -> gx_glyph_height;
174
        }
175
    }
176
#endif
177
}
178