GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_horizontal_pattern_line_draw.c Lines: 18 18 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_16bpp_horizontal_pattern_line_draw               */
35
/*                                                        PORTABLE C      */
36
/*                                                           6.3.0        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic 16bpp 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
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
72
/*                                            added partial canvas buffer */
73
/*                                            support,                    */
74
/*                                            resulting in version 6.3.0  */
75
/*                                                                        */
76
/**************************************************************************/
77
2527
VOID _gx_display_driver_16bpp_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
78
{
79
INT     column;
80
USHORT *put;
81
USHORT *rowstart;
82
ULONG   pattern;
83
ULONG   mask;
84
USHORT  on_color;
85
USHORT  off_color;
86
87
2527
INT     len = xend - xstart + 1;
88
89
    /* pick up start address of canvas memory */
90
2527
    rowstart = (USHORT *)context -> gx_draw_context_memory;
91
92
2527
    GX_CALCULATE_PUTROW(rowstart, xstart, ypos, context);
93
94
    /* draw 1-pixel hi lines to fill width */
95
96
    /* pick up the requested pattern and mask */
97
2527
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
98
2527
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
99
2527
    on_color = (USHORT)context -> gx_draw_context_brush.gx_brush_line_color;
100
2527
    off_color = (USHORT)context -> gx_draw_context_brush.gx_brush_fill_color;
101
102
2527
    put = rowstart;
103
104
    /* draw one line, left to right */
105
471493
    for (column = 0; column < len; column++)
106
    {
107
468966
        if (pattern & mask)
108
        {
109
237109
            *put++ = on_color;
110
        }
111
        else
112
        {
113
231857
            *put++ = off_color;
114
        }
115
468966
        mask >>= 1;
116
468966
        if (!mask)
117
        {
118
13533
            mask = 0x80000000;
119
        }
120
    }
121
122
    /* save current masks value back to brush */
123
2527
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
124
2527
}
125