GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_1bpp_horizontal_pattern_line_draw.c Lines: 30 30 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
/* 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_1bpp_horizontal_pattern_line_draw                */
34
/*                                                        PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    Horizontal pattern line draw function for 1bpp display driver.      */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    context                               Drawing context               */
47
/*    xstart                                x-coord of left endpoint      */
48
/*    xend                                  x-coord of right endpoint     */
49
/*    ypos                                  y-coord of line top           */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    GUIX Internal Code                                                  */
62
/*                                                                        */
63
/**************************************************************************/
64
21
VOID _gx_display_driver_1bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
65
{
66
INT       column;
67
GX_UBYTE *put;
68
GX_UBYTE *rowstart;
69
ULONG     pattern;
70
ULONG     mask;
71
GX_UBYTE  on_color;
72
GX_UBYTE  off_color;
73
INT       pos;
74
21
INT       len = xend - xstart + 1;
75
21
INT       start_in_byte = 0;
76
GX_UBYTE  start_mask;
77
78
    /* pick up start address of canvas memory */
79
21
    rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
80
81
21
    pos = context -> gx_draw_context_pitch * ypos + xstart;
82
83
    /* pick up the requested pattern and mask */
84
21
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
85
21
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
86
21
    on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x01;
87
21
    off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x01;
88
89
21
    put = rowstart;
90
21
    put +=  pos >> 3;
91
21
    start_in_byte = pos & 0x07;
92
21
    start_mask = (GX_UBYTE)(((GX_UBYTE)0x80) >> start_in_byte);
93
94
3622
    for (column = 0; column < len; column++)
95
    {
96
3601
        if (pattern & mask)
97
        {
98
1789
            if (on_color == 0x00)
99
            {
100
989
                *put = (GX_UBYTE)((*put) & (~start_mask));
101
            }
102
            else
103
            {
104
800
                *put |= start_mask;
105
            }
106
        }
107
        else
108
        {
109
1812
            if (off_color == 0x00)
110
            {
111
810
                *put &= (GX_UBYTE)((*put) & (~start_mask));
112
            }
113
            else
114
            {
115
1002
                *put |= start_mask;
116
            }
117
        }
118
3601
        start_mask >>= 1;
119
3601
        if (start_mask == 0)
120
        {
121
448
            put++;
122
448
            start_mask = 0x80;
123
        }
124
125
3601
        mask >>= 1;
126
3601
        if (!mask)
127
        {
128
132
            mask = 0x80000000;
129
        }
130
    }
131
132
    /* save current masks value back to brush */
133
21
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
134
21
}
135