GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_glyph_3bit_draw.c Lines: 45 45 100.0 %
Date: 2024-12-05 08:52:37 Branches: 10 10 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_glyph_3bit_draw             PORTABLE C      */
37
/*                                                           6.1          */
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
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74
/*                                            resulting in version 6.1    */
75
/*                                                                        */
76
/**************************************************************************/
77
109339
VOID _gx_display_driver_8bpp_glyph_3bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
78
{
79
GX_UBYTE *glyph_row;
80
GX_UBYTE *glyph_data;
81
UINT      row;
82
109339
UINT      pixel_width = 0;
83
UINT      leading_pixel;
84
UINT      trailing_pixel;
85
GX_UBYTE  text_color;
86
UINT      y_height;
87
GX_UBYTE  alpha;
88
UINT      pitch;
89
UINT      index;
90
GX_UBYTE *put;
91
GX_UBYTE *draw_start;
92
93
109339
    text_color = (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 7);
94
109339
    pixel_width = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
95
96
    /* Find the width of the glyph */
97
109339
    pitch = glyph -> gx_glyph_width;
98
    /* Make it byte-aligned. */
99
109339
    pitch = (pitch + 1) >> 1;
100
101
109339
    glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
102
103
109339
    if (map_offset -> gx_point_y)
104
    {
105
1284
        glyph_row = glyph_row + ((INT)pitch * map_offset -> gx_point_y);
106
    }
107
108
109339
    glyph_row += (map_offset -> gx_point_x >> 1);
109
110
109339
    y_height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
111
112
109339
    leading_pixel = (map_offset -> gx_point_x & 1);
113
114
109339
    pixel_width -= leading_pixel;
115
116
109339
    trailing_pixel = pixel_width & 1;
117
118
109339
    pixel_width = pixel_width >> 1;
119
120
109339
    draw_start = (GX_UBYTE *)context -> gx_draw_context_memory;
121
109339
    draw_start += context -> gx_draw_context_pitch * draw_area -> gx_rectangle_top;
122
109339
    draw_start += draw_area -> gx_rectangle_left;
123
124
1338023
    for (row = 0; row < y_height; row++)
125
    {
126
1228684
        glyph_data = glyph_row;
127
128
1228684
        put = draw_start;
129
130
1228684
        if (leading_pixel)
131
        {
132
6120
            alpha = (*glyph_data) & 0x0f;
133
134
            /* use 3bit color gradient instead of 4 bit */
135
6120
            alpha >>= 1;
136
137
6120
            *put = (GX_UBYTE)(text_color - alpha);
138
6120
            put++;
139
140
6120
            glyph_data++;
141
        }
142
5713100
        for (index = 0; index < pixel_width; index++)
143
        {
144
4484416
            alpha = (*glyph_data) & 0xf0;
145
146
            /* use 3bit color gradient instead of 4 bit */
147
4484416
            alpha >>= 1;
148
149
4484416
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
150
4484416
            put++;
151
152
4484416
            alpha = (*glyph_data) & 0x0f;
153
154
            /* use 3bit color gradient instead of 4 bit */
155
4484416
            alpha >>= 1;
156
157
4484416
            *put = (GX_UBYTE)(text_color - alpha);
158
4484416
            put++;
159
4484416
            glyph_data++;
160
        }
161
162
1228684
        if (trailing_pixel)
163
        {
164
711851
            alpha = (*glyph_data) & 0xf0;
165
166
            /* use 3bit color gradient instead of 4 bit */
167
711851
            alpha >>= 1;
168
169
711851
            *put = (GX_UBYTE)(text_color - (alpha >> 4));
170
711851
            put++;
171
        }
172
173
1228684
        glyph_row += pitch;
174
1228684
        draw_start += context -> gx_draw_context_pitch;
175
    }
176
109339
}
177