GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_rotated_glyph_4bit_draw.c Lines: 50 50 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 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_rotated_glyph_4bit_draw     PORTABLE C      */
38
/*                                                           6.1.4        */
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
675
VOID _gx_display_driver_8bpp_rotated_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
675
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
GX_VALUE  rotated_map_offset_x;
86
GX_VALUE  rotated_map_offset_y;
87
GX_VALUE  rotated_left;
88
GX_VALUE  rotated_top;
89
90
675
    text_color = (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 15);
91
675
    pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
92
93
675
    y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
94
95
675
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
96
    {
97
485
        rotated_left = draw_area -> gx_rectangle_top;
98
485
        rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1);
99
100
485
        rotated_map_offset_x = map_offset -> gx_point_y;
101
485
        rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height);
102
    }
103
    else
104
    {
105
190
        rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1);
106
190
        rotated_top = draw_area -> gx_rectangle_left;
107
108
190
        rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width);
109
190
        rotated_map_offset_y = map_offset -> gx_point_x;
110
    }
111
112
675
    leading_pixel = (rotated_map_offset_x & 1);
113
114
675
    pixel_width -= leading_pixel;
115
116
675
    trailing_pixel = pixel_width & 1;
117
118
675
    pixel_width = pixel_width >> 1;
119
120
    /* Find the width of the glyph.  */
121
675
    pitch = glyph -> gx_glyph_height;
122
123
    /* Make it byte-aligned.  */
124
675
    pitch = (pitch + 1) >> 1;
125
126
675
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
127
128
675
    if (rotated_map_offset_y)
129
    {
130
17
        glyph_row = glyph_row + ((INT)pitch * rotated_map_offset_y);
131
    }
132
133
675
    glyph_row += (rotated_map_offset_x >> 1);
134
135
675
    draw_start = (GX_UBYTE *)context -> gx_draw_context_memory;
136
675
    draw_start += context -> gx_draw_context_pitch * rotated_top;
137
675
    draw_start += rotated_left;
138
139
8068
    for (row = 0; row < y_height; row++)
140
    {
141
7393
        glyph_data = glyph_row;
142
143
7393
        put = draw_start;
144
145
7393
        if (leading_pixel)
146
        {
147
78
            alpha = (*glyph_data) & 0x0f;
148
149
78
            *put = (GX_UBYTE)(text_color - alpha);
150
78
            put++;
151
152
78
            glyph_data++;
153
        }
154
46761
        for (index = 0; index < pixel_width; index++)
155
        {
156
39368
            alpha = (*glyph_data) & 0xf0;
157
158
39368
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
159
39368
            put++;
160
161
39368
            alpha = (*glyph_data) & 0x0f;
162
39368
            *put = (GX_UBYTE)(text_color - alpha);
163
39368
            put++;
164
39368
            glyph_data++;
165
        }
166
167
7393
        if (trailing_pixel)
168
        {
169
5989
            alpha = (*glyph_data) & 0xf0;
170
5989
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
171
5989
            put++;
172
        }
173
174
7393
        glyph_row += pitch;
175
7393
        draw_start += context -> gx_draw_context_pitch;
176
    }
177
675
}
178