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: 2024-12-05 08:52:37 Branches: 8 8 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_rotated_horizontal_pattern_line_draw       */
35
/*                                                        PORTABLE C      */
36
/*                                                           6.1.3        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic 16bpp color format rotated horizontal pattern line draw     */
44
/*    function.                                                           */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Drawing context               */
49
/*    xstart                                x-coord of left endpoint      */
50
/*    xend                                  x-coord of right endpoint     */
51
/*    ypos                                  y-coord of line top           */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    None                                                                */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/*  RELEASE HISTORY                                                       */
66
/*                                                                        */
67
/*    DATE              NAME                      DESCRIPTION             */
68
/*                                                                        */
69
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
70
/*                                                                        */
71
/**************************************************************************/
72
2104
VOID _gx_display_driver_16bpp_rotated_horizontal_pattern_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos)
73
{
74
INT     column;
75
USHORT *put;
76
USHORT *rowstart;
77
ULONG   pattern;
78
ULONG   mask;
79
USHORT  on_color;
80
USHORT  off_color;
81
2104
INT     len = xend - xstart + 1;
82
83
    /* Pick up start address of canvas memory.  */
84
2104
    rowstart = (USHORT *)context -> gx_draw_context_memory;
85
86
2104
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
87
    {
88
        /* Calculate start of row address.  */
89
1052
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xstart - 1) * context -> gx_draw_context_pitch;
90
91
        /* Calculate pixel address.  */
92
1052
        rowstart += ypos;
93
    }
94
    else
95
    {
96
        /* Calculate start of row address.  */
97
1052
        rowstart += xend * context -> gx_draw_context_pitch;
98
99
        /* Calculate pixel address.  */
100
1052
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - ypos - 1);
101
    }
102
103
    /* Draw 1-pixel hi lines to fill width.  */
104
105
    /* Pick up the requested pattern and mask.  */
106
2104
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
107
2104
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
108
2104
    on_color = (USHORT)context -> gx_draw_context_brush.gx_brush_line_color;
109
2104
    off_color = (USHORT)context -> gx_draw_context_brush.gx_brush_fill_color;
110
111
2104
    put = rowstart;
112
113
    /* Draw line from bottom to top.  */
114
648280
    for (column = 0; column < len; column++)
115
    {
116
646176
        if (pattern & mask)
117
        {
118
324130
            *put = on_color;
119
        }
120
        else
121
        {
122
322046
            *put = off_color;
123
        }
124
125
646176
        put -= context -> gx_draw_context_pitch;
126
646176
        mask >>= 1;
127
646176
        if (!mask)
128
        {
129
130
            /* Set most significant bit to repeat the pattern draw.  */
131
18756
            mask = 0x80000000;
132
        }
133
    }
134
135
    /* Save current masks value back to brush.  */
136
2104
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
137
2104
}
138