GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_rotated_horizontal_pattern_line_draw.c Lines: 23 23 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_display.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_driver_16bpp_rotated_horizontal_pattern_line_draw       */
36
/*                                                        PORTABLE C      */
37
/*                                                           6.1.3        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    Generic 16bpp color format rotated horizontal pattern line draw     */
45
/*    function.                                                           */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    context                               Drawing context               */
50
/*    xstart                                x-coord of left endpoint      */
51
/*    xend                                  x-coord of right endpoint     */
52
/*    ypos                                  y-coord of line top           */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    None                                                                */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/**************************************************************************/
67
2104
VOID _gx_display_driver_16bpp_rotated_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
68
{
69
INT     column;
70
USHORT *put;
71
USHORT *rowstart;
72
ULONG   pattern;
73
ULONG   mask;
74
USHORT  on_color;
75
USHORT  off_color;
76
2104
INT     len = xend - xstart + 1;
77
78
    /* Pick up start address of canvas memory.  */
79
2104
    rowstart = (USHORT *)context -> gx_draw_context_memory;
80
81
2104
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
82
    {
83
        /* Calculate start of row address.  */
84
1052
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xstart - 1) * context -> gx_draw_context_pitch;
85
86
        /* Calculate pixel address.  */
87
1052
        rowstart += ypos;
88
    }
89
    else
90
    {
91
        /* Calculate start of row address.  */
92
1052
        rowstart += xend * context -> gx_draw_context_pitch;
93
94
        /* Calculate pixel address.  */
95
1052
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - ypos - 1);
96
    }
97
98
    /* Draw 1-pixel hi lines to fill width.  */
99
100
    /* Pick up the requested pattern and mask.  */
101
2104
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
102
2104
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
103
2104
    on_color = (USHORT)context -> gx_draw_context_brush.gx_brush_line_color;
104
2104
    off_color = (USHORT)context -> gx_draw_context_brush.gx_brush_fill_color;
105
106
2104
    put = rowstart;
107
108
    /* Draw line from bottom to top.  */
109
648280
    for (column = 0; column < len; column++)
110
    {
111
646176
        if (pattern & mask)
112
        {
113
324130
            *put = on_color;
114
        }
115
        else
116
        {
117
322046
            *put = off_color;
118
        }
119
120
646176
        put -= context -> gx_draw_context_pitch;
121
646176
        mask >>= 1;
122
646176
        if (!mask)
123
        {
124
125
            /* Set most significant bit to repeat the pattern draw.  */
126
18756
            mask = 0x80000000;
127
        }
128
    }
129
130
    /* Save current masks value back to brush.  */
131
2104
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
132
2104
}
133