GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_horizontal_line_draw.c Lines: 27 27 100.0 %
Date: 2026-03-06 19:21:09 Branches: 14 14 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
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
29
/**************************************************************************/
30
/*                                                                        */
31
/*  FUNCTION                                               RELEASE        */
32
/*                                                                        */
33
/*    _gx_display_driver_4bpp_horizontal_line_draw        PORTABLE C      */
34
/*                                                           6.1          */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    Horizontal line draw function for 4bpp display driver.              */
42
/*                                                                        */
43
/*  INPUT                                                                 */
44
/*                                                                        */
45
/*    context                               Drawing context               */
46
/*    xstart                                x-coord of left endpoint      */
47
/*    xend                                  x-coord of right endpoint     */
48
/*    ypos                                  y-coord of line top           */
49
/*    width                                 Width (height) of the line    */
50
/*    color                                 Color of line to write        */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    None                                                                */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/**************************************************************************/
65
209138
VOID _gx_display_driver_4bpp_horizontal_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos, INT width, GX_COLOR color)
66
{
67
INT       row;
68
INT       column;
69
GX_UBYTE *put;
70
GX_UBYTE *putrow;
71
GX_UBYTE  mask;
72
GX_UBYTE  pixel;
73
INT       stride;
74
75
    /* Get row pitch in bytes.  */
76
209138
    stride = (context -> gx_draw_context_pitch + 1) >> 1;
77
209138
    pixel = (GX_UBYTE)(color & 0x0f);
78
209138
    pixel |= (GX_UBYTE)(pixel << 4);
79
80
    /* pick up start address of canvas memory */
81
209138
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
82
209138
    putrow += ypos * stride;
83
209138
    putrow += (xstart >> 1);
84
85
3844833
    for (row = 0; row < width; row++)
86
    {
87
3635695
        put = putrow;
88
89
3635695
        if (xstart & 0x01)
90
        {
91
1903202
            mask = 0x0f;
92
        }
93
        else
94
        {
95
1732493
            mask = 0xf0;
96
        }
97
98
3635695
        column = xstart;
99
18979362
        while (column <= xend)
100
        {
101

15343667
            if ((mask == 0xf0) && (xend - column) > 2)
102
            {
103
877723868
                while ((xend - column) > 2)
104
                {
105
874148087
                    *put++ = pixel;
106
874148087
                    column += 2;
107
                }
108
            }
109
            else
110
            {
111
                /*Set bits first.*/
112
11767886
                *put &= (GX_UBYTE)(~mask);
113
11767886
                *put |= (GX_UBYTE)(pixel & mask);
114
11767886
                mask >>= 4;
115
116
11767886
                if (mask == 0)
117
                {
118
5532808
                    mask = 0xf0;
119
5532808
                    put++;
120
                }
121
11767886
                column++;
122
            }
123
        }
124
3635695
        putrow += stride;
125
    }
126
209138
}
127