GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_vertical_line_draw.c Lines: 25 25 100.0 %
Date: 2024-12-05 08:52:37 Branches: 12 12 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
/* Include necessary system files.  */
24
25
#include "gx_api.h"
26
#include "gx_display.h"
27
/**************************************************************************/
28
/*                                                                        */
29
/*  FUNCTION                                               RELEASE        */
30
/*                                                                        */
31
/*    _gx_display_driver_4bpp_vertical_line_draw          PORTABLE C      */
32
/*                                                           6.1          */
33
/*  AUTHOR                                                                */
34
/*                                                                        */
35
/*    Kenneth Maxwell, Microsoft Corporation                              */
36
/*                                                                        */
37
/*  DESCRIPTION                                                           */
38
/*                                                                        */
39
/*    Vertical line draw function for 4bpp display driver.                */
40
/*                                                                        */
41
/*  INPUT                                                                 */
42
/*                                                                        */
43
/*    context                               Drawing context               */
44
/*    ystart                                y-coord of top endpoint       */
45
/*    yend                                  y-coord of bottom endpoint    */
46
/*    xpos                                  x-coord of left edge          */
47
/*    width                                 width of the line             */
48
/*    color                                 Color of line to write        */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    GUIX Internal Code                                                  */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
67
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*                                                                        */
70
/**************************************************************************/
71
103424
VOID _gx_display_driver_4bpp_vertical_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos, INT width, GX_COLOR color)
72
{
73
INT       row;
74
INT       column;
75
GX_UBYTE *put;
76
GX_UBYTE *putrow;
77
GX_UBYTE  mask;
78
GX_UBYTE  pixel;
79
INT       stride;
80
81
    /* Get row pitch in bytes.  */
82
103424
    stride = (context -> gx_draw_context_pitch + 1) >> 1;
83
103424
    pixel = (GX_UBYTE)(color & 0x0f);
84
103424
    pixel |= (GX_UBYTE)(pixel << 4);
85
86
    /* pick up starting address of canvas memory */
87
103424
    putrow =  (GX_UBYTE *)context -> gx_draw_context_memory;
88
103424
    putrow += ystart * stride;
89
103424
    putrow += (xpos >> 1);
90
91
    /* draw line from top to bottom */
92
6926731
    for (row = ystart; row <= yend; row++)
93
    {
94
6823307
        put = putrow;
95
96
6823307
        if (xpos & 0x01)
97
        {
98
4097033
            mask = 0x0f;
99
        }
100
        else
101
        {
102
2726274
            mask = 0xf0;
103
        }
104
105
        /* draw line width from left to right */
106
14012118
        for (column = 0; column < width;)
107
        {
108

7188811
            if ((mask == 0xf0) && (width - column >= 2))
109
            {
110
364620
                *put++ = pixel;
111
364620
                column += 2;
112
            }
113
            else
114
            {
115
                /* Set bits first */
116
6824191
                *put &= (GX_UBYTE)(~mask);
117
6824191
                *put |= (pixel & mask);
118
6824191
                mask >>= 4;
119
120
6824191
                if (mask == 0)
121
                {
122
4097033
                    put++;
123
4097033
                    mask = 0xf0;
124
                }
125
6824191
                column++;
126
            }
127
        }
128
129
        /* advance to the next scaneline */
130
6823307
        putrow +=  stride;
131
    }
132
103424
}
133