GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_rotated_block_move.c Lines: 68 68 100.0 %
Date: 2026-03-06 19:21:09 Branches: 20 20 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_system.h"
30
#include "gx_utility.h"
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_driver_32bpp_rotated_block_move         PORTABLE C      */
36
/*                                                           6.1.4        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic rotated 32bpp color format display driver block moving      */
44
/*    function.                                                           */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Draw context                  */
49
/*    block                                 The rectangle to be moved     */
50
/*    xshift                                Amount to move on X-axis      */
51
/*    yshift                                Amount to move on Y-axis      */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    memmove                                Move memory content          */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
147
VOID _gx_display_driver_32bpp_rotated_block_move(GX_DRAW_CONTEXT *context,
67
                                                 GX_RECTANGLE *block, INT xshift, INT yshift)
68
{
69
GX_COLOR    *pGet;
70
GX_COLOR    *pPut;
71
int          width;
72
int          width_in_bytes;
73
int          y;
74
int          height;
75
GX_RECTANGLE rotated_block;
76
77
147
    GX_SWAP_VALS(xshift, yshift);
78
79
147
    if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
80
    {
81
109
        rotated_block.gx_rectangle_left = block -> gx_rectangle_top;
82
109
        rotated_block.gx_rectangle_right = block -> gx_rectangle_bottom;
83
109
        rotated_block.gx_rectangle_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_right - 1);
84
109
        rotated_block.gx_rectangle_bottom = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - block -> gx_rectangle_left - 1);
85
86
109
        yshift = -yshift;
87
    }
88
    else
89
    {
90
38
        rotated_block.gx_rectangle_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_bottom - 1);
91
38
        rotated_block.gx_rectangle_right = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_y_resolution - block -> gx_rectangle_top - 1);
92
38
        rotated_block.gx_rectangle_top = block -> gx_rectangle_left;
93
38
        rotated_block.gx_rectangle_bottom = block -> gx_rectangle_right;
94
95
38
        xshift = -xshift;
96
    }
97
98
147
    if (xshift)
99
    {
100
143
        if (xshift > 0)
101
        {
102
            /* Have to copy from left to right.  */
103
38
            pPut = context -> gx_draw_context_memory;
104
38
            pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch;
105
38
            pPut += rotated_block.gx_rectangle_left + xshift;
106
107
38
            pGet = context -> gx_draw_context_memory;
108
38
            pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch;
109
38
            pGet += rotated_block.gx_rectangle_left;
110
111
38
            width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 - xshift;
112
38
            width_in_bytes = width * (int)sizeof(GX_COLOR);
113
114
38
            if (width_in_bytes <= 0)
115
            {
116
2
                return;
117
            }
118
119
8368
            for (y = rotated_block.gx_rectangle_top; y <= rotated_block.gx_rectangle_bottom; y++)
120
            {
121
8331
                memmove(pPut, pGet, (size_t)width_in_bytes);
122
123
8331
                pPut += context -> gx_draw_context_pitch;
124
8331
                pGet += context -> gx_draw_context_pitch;
125
            }
126
        }
127
        else
128
        {
129
            /* Have to copy from right to left.  */
130
105
            pPut = context -> gx_draw_context_memory;
131
105
            pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch;
132
105
            pPut += rotated_block.gx_rectangle_left;
133
134
105
            pGet = context -> gx_draw_context_memory;
135
105
            pGet += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch;
136
105
            pGet += rotated_block.gx_rectangle_left - xshift;
137
138
105
            width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1 + xshift;
139
105
            width_in_bytes = width * (int)sizeof(GX_COLOR);
140
141
105
            if (width_in_bytes <= 0)
142
            {
143
1
                return;
144
            }
145
146
23352
            for (y = rotated_block.gx_rectangle_top; y <= rotated_block.gx_rectangle_bottom; y++)
147
            {
148
23248
                memmove(pPut, pGet, (size_t)width_in_bytes);
149
150
23248
                pPut += context -> gx_draw_context_pitch;
151
23248
                pGet += context -> gx_draw_context_pitch;
152
            }
153
        }
154
    }
155
    else
156
    {
157
4
        width = rotated_block.gx_rectangle_right - rotated_block.gx_rectangle_left + 1;
158
4
        width_in_bytes = width * (int)sizeof(GX_COLOR);
159
160
4
        if (yshift > 0)
161
        {
162
            /* Have to copy from top to bottom.  */
163
2
            pPut = context -> gx_draw_context_memory;
164
2
            pPut += rotated_block.gx_rectangle_bottom * context -> gx_draw_context_pitch;
165
2
            pPut += rotated_block.gx_rectangle_left;
166
167
2
            pGet = context -> gx_draw_context_memory;
168
2
            pGet += (rotated_block.gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch;
169
2
            pGet += rotated_block.gx_rectangle_left;
170
171
2
            height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 - yshift;
172
173
170
            for (y = 0; y < height; y++)
174
            {
175
168
                memmove(pPut, pGet, (size_t)width_in_bytes);
176
177
168
                pPut -= context -> gx_draw_context_pitch;
178
168
                pGet -= context -> gx_draw_context_pitch;
179
            }
180
        }
181
        else
182
        {
183
            /* Have to copy from bottom to top.  */
184
2
            pPut = context -> gx_draw_context_memory;
185
2
            pPut += rotated_block.gx_rectangle_top * context -> gx_draw_context_pitch;
186
2
            pPut += rotated_block.gx_rectangle_left;
187
188
2
            pGet = context -> gx_draw_context_memory;
189
2
            pGet += (rotated_block.gx_rectangle_top - yshift) * context -> gx_draw_context_pitch;
190
2
            pGet += rotated_block.gx_rectangle_left;
191
192
2
            height = rotated_block.gx_rectangle_bottom - rotated_block.gx_rectangle_top + 1 + yshift;
193
194
170
            for (y = 0; y < height; y++)
195
            {
196
168
                memmove(pPut, pGet, (size_t)width_in_bytes);
197
198
168
                pPut += context -> gx_draw_context_pitch;
199
168
                pGet += context -> gx_draw_context_pitch;
200
            }
201
        }
202
    }
203
}
204