GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_vertical_pattern_line_draw.c Lines: 26 26 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 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_display.h"
29
/**************************************************************************/
30
/*                                                                        */
31
/*  FUNCTION                                               RELEASE        */
32
/*                                                                        */
33
/*    _gx_display_driver_4bpp_vertical_pattern_line_draw  PORTABLE C      */
34
/*                                                           6.1.7        */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    Vertical line draw function for 4bpp display driver.                */
42
/*                                                                        */
43
/*  INPUT                                                                 */
44
/*                                                                        */
45
/*    context                               Drawing context               */
46
/*    ystart                                y-coord of top endpoint       */
47
/*    yend                                  y-coord of bottom endpoint    */
48
/*    xpos                                  x-coord of left edge          */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    GUIX Internal Code                                                  */
61
/*                                                                        */
62
/**************************************************************************/
63
11
VOID _gx_display_driver_4bpp_vertical_pattern_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos)
64
{
65
INT       row;
66
GX_UBYTE *put;
67
GX_UBYTE *putrow;
68
ULONG     pattern;
69
ULONG     pattern_mask;
70
GX_UBYTE  on_color;
71
GX_UBYTE  off_color;
72
GX_UBYTE  draw_mask;
73
INT       stride;
74
75
    /* pick up row pitch in bytes.  */
76
11
    stride = (context -> gx_draw_context_pitch + 1) >> 1;
77
78
    /* pick up starting address of canvas memory */
79
11
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
80
11
    putrow += ystart * stride;
81
11
    putrow += (xpos >> 1);
82
83
    /* pick up the requested pattern and mask */
84
11
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
85
11
    pattern_mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
86
87
11
    on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x0f;
88
11
    on_color |= (GX_UBYTE)(on_color << 4);
89
11
    off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x0f;
90
11
    off_color |= (GX_UBYTE)(off_color << 4);
91
92
    /* draw line from top to bottom */
93
1850
    for (row = ystart; row <= yend; row++)
94
    {
95
1839
        put = putrow;
96
1839
        if (xpos & 0x01)
97
        {
98
1610
            draw_mask = 0x0f;
99
        }
100
        else
101
        {
102
229
            draw_mask = 0xf0;
103
        }
104
105
        /* Set bits to 0 first */
106
1839
        *put &= (GX_UBYTE)(~draw_mask);
107
108
        /* Set bits color */
109
1839
        if (pattern & pattern_mask)
110
        {
111
914
            *put |= (on_color & draw_mask);
112
        }
113
        else
114
        {
115
925
            *put |= (off_color & draw_mask);
116
        }
117
118
1839
        pattern_mask >>= 1;
119
1839
        if (!pattern_mask)
120
        {
121
67
            pattern_mask = 0x80000000;
122
        }
123
124
        /* advance to the next scaneline */
125
1839
        putrow += stride;
126
    }
127
128
    /* save current masks value back to brush */
129
11
    context -> gx_draw_context_brush.gx_brush_pattern_mask = pattern_mask;
130
11
}
131