GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_1bpp_canvas_copy.c Lines: 33 33 100.0 %
Date: 2024-12-05 08:52:37 Branches: 12 12 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
#include "gx_utility.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_driver_1bpp_canvas_copy                 PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Canvas copy function for the 1bpp display driver.                   */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*   canvas                                 The canvas to copy from       */
48
/*   composite                              The canvas to copy to         */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_utility_rectangle_shift           Move the rectangle            */
57
/*    _gx_utility_rectangle_overlap_detect  Detect two rectangles being   */
58
/*                                            overlap to each other       */
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
16
VOID _gx_display_driver_1bpp_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite)
74
{
75
GX_RECTANGLE dirty;
76
GX_RECTANGLE overlap;
77
GX_UBYTE    *read;
78
GX_UBYTE    *write;
79
INT          row;
80
INT          column;
81
UINT         read_pos;
82
UINT         write_pos;
83
GX_UBYTE     read_mask;
84
GX_UBYTE     write_mask;
85
INT          readstride;
86
INT          writestride;
87
INT          offset;
88
89
16
    dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0;
90
16
    dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - (GX_VALUE)1);
91
16
    dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - (GX_VALUE)1);
92
16
    readstride = (canvas->gx_canvas_x_resolution + 7) >> 3;
93
16
    writestride = (composite->gx_canvas_x_resolution + 7) >> 3;
94
95
16
    _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y);
96
97
16
    if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap))
98
    {
99
15
        offset = overlap.gx_rectangle_left - dirty.gx_rectangle_left;
100
15
        read_pos = (UINT)((overlap.gx_rectangle_top - dirty.gx_rectangle_top) * readstride + (offset >> 3));
101
15
        write_pos = (UINT)(overlap.gx_rectangle_top * writestride + (overlap.gx_rectangle_left >> 3));
102
103
4340
        for (row = overlap.gx_rectangle_top; row <= overlap.gx_rectangle_bottom; row++)
104
        {
105
4325
            read = (GX_UBYTE *)canvas -> gx_canvas_memory;
106
4325
            write = (GX_UBYTE *)composite -> gx_canvas_memory;
107
4325
            read += read_pos;
108
4325
            write += write_pos;
109
4325
            read_mask = (GX_UBYTE)(((GX_UBYTE)0x80) >> (offset & 0x07));
110
4325
            write_mask = (GX_UBYTE)(0x80 >> (overlap.gx_rectangle_left & 0x07));
111
112
2436345
            for (column = overlap.gx_rectangle_left; column <= overlap.gx_rectangle_right; column++)
113
            {
114
2432020
                if (((*read) & read_mask) == read_mask)
115
                {
116
351508
                    *write |= write_mask;
117
                }
118
                else
119
                {
120
2080512
                    *write = (GX_UBYTE)((*write) & (~write_mask));
121
                }
122
2432020
                read_mask >>= 1;
123
2432020
                write_mask >>= 1;
124
2432020
                if (!read_mask)
125
                {
126
303269
                    read++;
127
303269
                    read_mask = 0x80;
128
                }
129
2432020
                if (!write_mask)
130
                {
131
303780
                    write++;
132
303780
                    write_mask = 0x80;
133
                }
134
            }
135
4325
            write_pos = (UINT)((INT)write_pos + writestride);
136
4325
            read_pos = (UINT)((INT)read_pos + readstride);
137
        }
138
    }
139
16
}
140