GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_horizontal_pattern_line_draw.c Lines: 29 29 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 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_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 4bpp 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
11
VOID _gx_display_driver_4bpp_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
11
INT       len = xend - xstart + 1;
75
GX_UBYTE  start_mask;
76
77
    /* pick up start address of canvas memory */
78
11
    rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
79
80
11
    pos = context -> gx_draw_context_pitch * ypos + xstart;
81
82
    /* pick up the requested pattern and mask */
83
11
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
84
11
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
85
11
    on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x0f;
86
11
    on_color |= (GX_UBYTE)(on_color << 4);
87
11
    off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x0f;
88
11
    off_color |= (GX_UBYTE)(off_color << 4);
89
90
11
    put = rowstart;
91
11
    put +=  pos >> 1;
92
11
    if (pos & 0x01)
93
    {
94
10
        start_mask = 0x0f;
95
    }
96
    else
97
    {
98
1
        start_mask = 0xf0;
99
    }
100
101
1882
    for (column = 0; column < len; column++)
102
    {
103
        /* Set bits to 0 first */
104
1871
        *put &= (GX_UBYTE)(~start_mask);
105
        /* Set bits color */
106
1871
        if (pattern & mask)
107
        {
108
932
            *put |= (on_color & start_mask);
109
        }
110
        else
111
        {
112
939
            *put |= (off_color & start_mask);
113
        }
114
115
1871
        start_mask >>= 4;
116
1871
        if (start_mask == 0)
117
        {
118
940
            put++;
119
940
            start_mask = 0xf0;
120
        }
121
122
1871
        mask >>= 1;
123
1871
        if (!mask)
124
        {
125
68
            mask = 0x80000000;
126
        }
127
    }
128
129
    /* save current masks value back to brush */
130
11
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
131
11
}
132