GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_rotated_glyph_3bit_draw.c Lines: 54 54 100.0 %
Date: 2024-12-05 08:52:37 Branches: 12 12 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_utility.h"
29
#include "gx_display.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_8bpp_rotated_glyph_3bit_draw     PORTABLE C      */
37
/*                                                           6.1.4        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This draws the specified 3bit glyph using the current context,      */
45
/*    clipped to one viewport                                             */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    context                               Draw context                  */
50
/*    draw_position                         The X and Y coordinate where  */
51
/*                                            the glyph is drawn to       */
52
/*    string                                String to draw                */
53
/*    count                                 Count of string characters    */
54
/*    view                                  view to clip drawing within   */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    None                                                                */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    None                                                                */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    _gx_canvas_text_draw                                                */
67
/*                                                                        */
68
/*  RELEASE HISTORY                                                       */
69
/*                                                                        */
70
/*    DATE              NAME                      DESCRIPTION             */
71
/*                                                                        */
72
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
73
/*                                                                        */
74
/**************************************************************************/
75
4285
VOID _gx_display_driver_8bpp_rotated_glyph_3bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
76
{
77
GX_UBYTE *glyph_row;
78
GX_UBYTE *glyph_data;
79
UINT      row;
80
4285
UINT      pixel_width = 0;
81
UINT      leading_pixel;
82
UINT      trailing_pixel;
83
GX_UBYTE  text_color;
84
UINT      y_height;
85
GX_UBYTE  alpha;
86
UINT      pitch;
87
UINT      index;
88
GX_UBYTE *put;
89
GX_UBYTE *draw_start;
90
GX_VALUE  rotated_map_offset_x;
91
GX_VALUE  rotated_map_offset_y;
92
GX_VALUE  rotated_left;
93
GX_VALUE  rotated_top;
94
95
4285
    text_color = (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 7);
96
4285
    pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
97
98
4285
    y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
99
100
4285
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
101
    {
102
2385
        rotated_left = draw_area -> gx_rectangle_top;
103
2385
        rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1);
104
105
2385
        rotated_map_offset_x = map_offset -> gx_point_y;
106
2385
        rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height);
107
    }
108
    else
109
    {
110
1900
        rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1);
111
1900
        rotated_top = draw_area -> gx_rectangle_left;
112
113
1900
        rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width);
114
1900
        rotated_map_offset_y = map_offset -> gx_point_x;
115
    }
116
117
4285
    leading_pixel = (rotated_map_offset_x & 1);
118
119
4285
    pixel_width -= leading_pixel;
120
121
4285
    trailing_pixel = pixel_width & 1;
122
123
4285
    pixel_width = pixel_width >> 1;
124
125
    /* Find the width of the glyph.  */
126
4285
    pitch = glyph -> gx_glyph_height;
127
128
    /* Make it byte-aligned.  */
129
4285
    pitch = (pitch + 1) >> 1;
130
131
4285
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
132
133
4285
    if (rotated_map_offset_y)
134
    {
135
37
        glyph_row = glyph_row + ((INT)pitch * rotated_map_offset_y);
136
    }
137
138
4285
    glyph_row += (rotated_map_offset_x >> 1);
139
140
4285
    draw_start = (GX_UBYTE *)context -> gx_draw_context_memory;
141
4285
    draw_start += context -> gx_draw_context_pitch * rotated_top;
142
4285
    draw_start += rotated_left;
143
144
51768
    for (row = 0; row < y_height; row++)
145
    {
146
47483
        glyph_data = glyph_row;
147
148
47483
        put = draw_start;
149
150
47483
        if (leading_pixel)
151
        {
152
78
            alpha = (*glyph_data) & 0x0f;
153
154
            /* use 3bit color gradient instead of 4 bit */
155
78
            alpha >>= 1;
156
157
78
            *put = (GX_UBYTE)(text_color - alpha);
158
78
            put++;
159
160
78
            glyph_data++;
161
        }
162
302995
        for (index = 0; index < pixel_width; index++)
163
        {
164
255512
            alpha = (*glyph_data) & 0xf0;
165
166
            /* use 3bit color gradient instead of 4 bit */
167
255512
            alpha >>= 1;
168
169
255512
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
170
255512
            put++;
171
172
255512
            alpha = (*glyph_data) & 0x0f;
173
174
            /* use 3bit color gradient instead of 4 bit */
175
255512
            alpha >>= 1;
176
177
255512
            *put = (GX_UBYTE)(text_color - alpha);
178
255512
            put++;
179
255512
            glyph_data++;
180
        }
181
182
47483
        if (trailing_pixel)
183
        {
184
40075
            alpha = (*glyph_data) & 0xf0;
185
186
            /* use 3bit color gradient instead of 4 bit */
187
40075
            alpha >>= 1;
188
189
40075
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
190
40075
            put++;
191
        }
192
193
47483
        glyph_row += pitch;
194
47483
        draw_start += context -> gx_draw_context_pitch;
195
    }
196
4285
}
197