GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_rotated_vertical_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
#define GX_SOURCE_CODE
21
22
23
/* Include necessary system files.  */
24
25
#include "gx_api.h"
26
#include "gx_display.h"
27
28
/**************************************************************************/
29
/*                                                                        */
30
/*  FUNCTION                                               RELEASE        */
31
/*                                                                        */
32
/*    _gx_display_driver_16bpp_rotated_vertical_pattern_line_draw         */
33
/*                                                        PORTABLE C      */
34
/*                                                           6.1.3        */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    Generic 16bpp color format rotated vertical pattern line draw       */
42
/*    function.                                                           */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    context                               Drawing context               */
47
/*    ystart                                y-coord of top endpoint       */
48
/*    yend                                  y-coord of bottom endpoint    */
49
/*    xpos                                  x-coord of left edge          */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    None                                                                */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    GUIX Internal Code                                                  */
62
/*                                                                        */
63
/*  RELEASE HISTORY                                                       */
64
/*                                                                        */
65
/*    DATE              NAME                      DESCRIPTION             */
66
/*                                                                        */
67
/*  12-31-2020     Kenneth Maxwell          Initial Version 6.1.3         */
68
/*                                                                        */
69
/**************************************************************************/
70
2100
VOID _gx_display_driver_16bpp_rotated_vertical_pattern_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos)
71
{
72
INT     row;
73
USHORT *put;
74
USHORT *rowstart;
75
ULONG   pattern;
76
ULONG   mask;
77
USHORT  on_color;
78
USHORT  off_color;
79
80
2100
INT     len = yend - ystart + 1;
81
82
    /* pick up starting address of canvas memory */
83
2100
    rowstart = (USHORT *)context -> gx_draw_context_memory;
84
85
2100
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
86
    {
87
        /* calculate start of scanline */
88
1050
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - xpos - 1) * context -> gx_draw_context_pitch;
89
90
        /* offset into starting pixel */
91
1050
        rowstart += ystart;
92
    }
93
    else
94
    {
95
        /* calculate start of scanline */
96
1050
        rowstart += xpos * context -> gx_draw_context_pitch;
97
98
        /* offset into starting pixel */
99
1050
        rowstart += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - yend - 1);
100
    }
101
102
    /* pick up the requested pattern and mask */
103
2100
    pattern = context -> gx_draw_context_brush.gx_brush_line_pattern;
104
2100
    mask = context -> gx_draw_context_brush.gx_brush_pattern_mask;
105
2100
    on_color = (USHORT)context -> gx_draw_context_brush.gx_brush_line_color;
106
2100
    off_color = (USHORT)context -> gx_draw_context_brush.gx_brush_fill_color;
107
108
2100
    put = rowstart;
109
110
    /* draw line from left to right */
111
648404
    for (row = 0; row < len; row++)
112
    {
113
646304
        if (pattern & mask)
114
        {
115
422142
            *put = on_color;
116
        }
117
        else
118
        {
119
224162
            *put = off_color;
120
        }
121
122
646304
        mask >>= 1;
123
646304
        if (!mask)
124
        {
125
18764
            mask = 0x80000000;
126
        }
127
128
        /* advance to the right */
129
646304
        put++;
130
    }
131
132
    /* save current masks value back to brush */
133
2100
    context -> gx_draw_context_brush.gx_brush_pattern_mask = mask;
134
2100
}
135