GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_canvas_copy.c Lines: 23 23 100.0 %
Date: 2024-12-05 08:52:37 Branches: 6 6 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
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_32bpp_rotated_canvas_copy        PORTABLE C      */
37
/*                                                           6.1.4        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    Generic rotated 32bpp canvas copy function.                         */
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
/*    memcpy                                Move canvas data              */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
71
/*                                                                        */
72
/**************************************************************************/
73
1104
VOID _gx_display_driver_32bpp_rotated_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite)
74
{
75
GX_RECTANGLE dirty;
76
GX_RECTANGLE overlap;
77
ULONG       *read;
78
ULONG       *write;
79
INT          width;
80
INT          row;
81
82
1104
    dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0;
83
1104
    dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1);
84
1104
    dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1);
85
86
1104
    _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y);
87
88
1104
    if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap))
89
    {
90
968
        width = overlap.gx_rectangle_bottom - overlap.gx_rectangle_top + 1;
91
968
        read = (ULONG *)canvas -> gx_canvas_memory;
92
968
        write = (ULONG *)composite -> gx_canvas_memory;
93
94
968
        if (canvas -> gx_canvas_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
95
        {
96
            /* Index into starting row.  */
97
654
            read += (dirty.gx_rectangle_right - overlap.gx_rectangle_right) * canvas -> gx_canvas_y_resolution;
98
99
            /* Index into pixel.  */
100
654
            read += overlap.gx_rectangle_top - dirty.gx_rectangle_top;
101
102
            /* Calculate the write pointer.  */
103
654
            write += (composite -> gx_canvas_x_resolution - overlap.gx_rectangle_right - 1) * composite -> gx_canvas_y_resolution;
104
654
            write += overlap.gx_rectangle_top;
105
        }
106
        else
107
        {
108
            /* Index into starting row.  */
109
314
            read += (overlap.gx_rectangle_left - dirty.gx_rectangle_left) * canvas -> gx_canvas_y_resolution;
110
111
            /* Index into pixel.  */
112
314
            read += dirty.gx_rectangle_bottom - overlap.gx_rectangle_bottom;
113
114
            /* Calculate the write pointer.  */
115
314
            write += overlap.gx_rectangle_left * composite -> gx_canvas_y_resolution;
116
314
            write += (composite -> gx_canvas_y_resolution - overlap.gx_rectangle_bottom - 1);
117
        }
118
119
391574
        for (row = overlap.gx_rectangle_left; row <= overlap.gx_rectangle_right; row++)
120
        {
121
390606
            memcpy(write, read, (size_t)width * 4); /* Use case of memcpy is verified. */
122
123
390606
            write += composite -> gx_canvas_y_resolution;
124
390606
            read += canvas -> gx_canvas_y_resolution;
125
        }
126
    }
127
1104
}
128