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

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