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