GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_horizontal_pattern_line_draw.c Lines: 19 19 100.0 %
Date: 2024-12-05 08:52:37 Branches: 6 6 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
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_display_driver_8bpp_horizontal_pattern_line_draw                */
35
/*                                                        PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic 8bpp color format horizontal pattern line draw function.    */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    context                               Drawing context               */
48
/*    xstart                                x-coord of left endpoint      */
49
/*    xend                                  x-coord of right endpoint     */
50
/*    ypos                                  y-coord of line top           */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    None                                                                */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*                                                                        */
72
/**************************************************************************/
73
18
VOID _gx_display_driver_8bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
74
{
75
INT       column;
76
GX_UBYTE *put;
77
GX_UBYTE *rowstart;
78
ULONG     pattern;
79
ULONG     mask;
80
GX_UBYTE  on_color;
81
GX_UBYTE  off_color;
82
83
18
INT       len = xend - xstart + 1;
84
85
    /* pick up start address of canvas memory */
86
18
    rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
87
88
    /* calculate start of row address */
89
18
    rowstart +=  context -> gx_draw_context_pitch * ypos;
90
91
    /* calculate pixel address */
92
18
    rowstart +=  xstart;
93
    /* draw 1-pixel hi lines to fill width */
94
95
    /* pick up the requested pattern and mask */
96
18
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
97
18
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
98
18
    on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color;
99
18
    off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color;
100
101
18
    put = rowstart;
102
103
    /* draw one line, left to right */
104
2924
    for (column = 0; column < len; column++)
105
    {
106
2906
        if (pattern & mask)
107
        {
108
1440
            *put++ = on_color;
109
        }
110
        else
111
        {
112
1466
            *put++ = off_color;
113
        }
114
2906
        mask >>= 1;
115
2906
        if (!mask)
116
        {
117
102
            mask = 0x80000000;
118
        }
119
    }
120
121
    /* save current masks value back to brush */
122
18
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
123
18
}
124