GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_horizontal_line_draw.c Lines: 18 18 100.0 %
Date: 2024-12-05 08:52:37 Branches: 10 10 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
#define GX_SOURCE_CODE
21
/* Include necessary system files.  */
22
23
#include "gx_api.h"
24
#include "gx_display.h"
25
26
/**************************************************************************/
27
/*                                                                        */
28
/*  FUNCTION                                               RELEASE        */
29
/*                                                                        */
30
/*    _gx_display_driver_8bpp_horizontal_line_draw        PORTABLE C      */
31
/*                                                           6.1          */
32
/*  AUTHOR                                                                */
33
/*                                                                        */
34
/*    Kenneth Maxwell, Microsoft Corporation                              */
35
/*                                                                        */
36
/*  DESCRIPTION                                                           */
37
/*                                                                        */
38
/*    Generic 8bpp color format horizontal line draw function.            */
39
/*                                                                        */
40
/*  INPUT                                                                 */
41
/*                                                                        */
42
/*    context                               Drawing context               */
43
/*    xstart                                x-coord of left endpoint      */
44
/*    xend                                  x-coord of right endpoint     */
45
/*    ypos                                  y-coord of line top           */
46
/*    width                                 Width (height) of the line    */
47
/*    color                                 Color of line to write        */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    NOne                                                                */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    _gx_display_driver_horizontal_line_alpha_draw                       */
56
/*                                          Basic display driver          */
57
/*                                            horizontal line alpha draw  */
58
/*                                            function.                   */
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
1312108
VOID _gx_display_driver_8bpp_horizontal_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos, INT width, GX_COLOR color)
74
{
75
INT       row;
76
INT       column;
77
GX_UBYTE *put;
78
GX_UBYTE *rowstart;
79
1312108
INT       len = xend - xstart + 1;
80
81
#if defined GX_BRUSH_ALPHA_SUPPORT
82
GX_UBYTE alpha;
83
84
1312108
    alpha = context -> gx_draw_context_brush.gx_brush_alpha;
85
1312108
    if (alpha == 0)
86
    {
87
        /* Nothing to drawn. Just return. */
88
6235
        return;
89
    }
90
91
1305873
    if (alpha != 0xff)
92
    {
93
6307
        if (context -> gx_draw_context_display -> gx_display_color_format != GX_COLOR_FORMAT_8BIT_PACKED_PIXEL)
94
        {
95
            /* Alpha blend is not supported for palette driver. */
96
6
            return;
97
        }
98
99
6301
        _gx_display_driver_horizontal_line_alpha_draw(context, xstart, xend, ypos, width, color, alpha);
100
6301
        return;
101
    }
102
#endif
103
104
    /* pick up start address of canvas memory */
105
1299566
    rowstart = (GX_UBYTE *)context -> gx_draw_context_memory;
106
107
    /* calculate start of row address */
108
1299566
    rowstart += context -> gx_draw_context_pitch * ypos;
109
110
    /* calculate pixel address */
111
1299566
    rowstart += xstart;
112
    /* draw 1-pixel hi lines to fill width */
113
17329971
    for (row = 0; row < width; row++)
114
    {
115
16030405
        put = rowstart;
116
117
        /* draw one line, left to right */
118
5269729242
        for (column = 0; column < len; column++)
119
        {
120
5253698837
            *put++ = (GX_UBYTE)color;
121
        }
122
16030405
        rowstart += context -> gx_draw_context_pitch;
123
    }
124
}