GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_canvas_copy.c Lines: 23 23 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_display_driver_32bpp_rotated_canvas_copy        PORTABLE C      */
38
/*                                                           6.1.4        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    Generic rotated 32bpp canvas copy function.                         */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*   canvas                                 The canvas to copy from       */
50
/*   composite                              The canvas to copy to         */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_utility_rectangle_shift           Move the rectangle            */
59
/*    _gx_utility_rectangle_overlap_detect  Detect two rectangles being   */
60
/*                                            overlap to each other       */
61
/*    memcpy                                Move canvas data              */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    GUIX Internal Code                                                  */
66
/*                                                                        */
67
/**************************************************************************/
68
1104
VOID _gx_display_driver_32bpp_rotated_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite)
69
{
70
GX_RECTANGLE dirty;
71
GX_RECTANGLE overlap;
72
ULONG       *read;
73
ULONG       *write;
74
INT          width;
75
INT          row;
76
77
1104
    dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0;
78
1104
    dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1);
79
1104
    dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1);
80
81
1104
    _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y);
82
83
1104
    if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap))
84
    {
85
968
        width = overlap.gx_rectangle_bottom - overlap.gx_rectangle_top + 1;
86
968
        read = (ULONG *)canvas -> gx_canvas_memory;
87
968
        write = (ULONG *)composite -> gx_canvas_memory;
88
89
968
        if (canvas -> gx_canvas_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
90
        {
91
            /* Index into starting row.  */
92
654
            read += (dirty.gx_rectangle_right - overlap.gx_rectangle_right) * canvas -> gx_canvas_y_resolution;
93
94
            /* Index into pixel.  */
95
654
            read += overlap.gx_rectangle_top - dirty.gx_rectangle_top;
96
97
            /* Calculate the write pointer.  */
98
654
            write += (composite -> gx_canvas_x_resolution - overlap.gx_rectangle_right - 1) * composite -> gx_canvas_y_resolution;
99
654
            write += overlap.gx_rectangle_top;
100
        }
101
        else
102
        {
103
            /* Index into starting row.  */
104
314
            read += (overlap.gx_rectangle_left - dirty.gx_rectangle_left) * canvas -> gx_canvas_y_resolution;
105
106
            /* Index into pixel.  */
107
314
            read += dirty.gx_rectangle_bottom - overlap.gx_rectangle_bottom;
108
109
            /* Calculate the write pointer.  */
110
314
            write += overlap.gx_rectangle_left * composite -> gx_canvas_y_resolution;
111
314
            write += (composite -> gx_canvas_y_resolution - overlap.gx_rectangle_bottom - 1);
112
        }
113
114
391574
        for (row = overlap.gx_rectangle_left; row <= overlap.gx_rectangle_right; row++)
115
        {
116
390606
            memcpy(write, read, (size_t)width * 4); /* Use case of memcpy is verified. */
117
118
390606
            write += composite -> gx_canvas_y_resolution;
119
390606
            read += canvas -> gx_canvas_y_resolution;
120
        }
121
    }
122
1104
}
123