GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_32bpp_block_move.c Lines: 56 56 100.0 %
Date: 2026-03-06 19:21:09 Branches: 18 18 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_block_move                 PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic 32bpp color format display driver block moving function.    */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    context                               Draw context                  */
48
/*    block                                 The rectangle to be moved     */
49
/*    xshift                                Amount to move on X-axis      */
50
/*    yshift                                Amount to move on Y-axis      */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    memmove                                Move memory content          */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/**************************************************************************/
65
1848
VOID _gx_display_driver_32bpp_block_move(GX_DRAW_CONTEXT *context,
66
                                         GX_RECTANGLE *block, INT xshift, INT yshift)
67
{
68
GX_COLOR *pGet;
69
GX_COLOR *pPut;
70
int       width;
71
int       width_in_bytes;
72
int       y;
73
int       height;
74
75
1848
    if (xshift)
76
    {
77
1235
        if (xshift > 0)
78
        {
79
            /* have to copy from left to right. */
80
577
            pPut = context -> gx_draw_context_memory;
81
577
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
82
577
            pPut += block -> gx_rectangle_left + xshift;
83
84
577
            pGet = context -> gx_draw_context_memory;
85
577
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
86
577
            pGet += block -> gx_rectangle_left;
87
88
577
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 - xshift;
89
577
            width_in_bytes = width * (int)sizeof(GX_COLOR);
90
91
577
            if (width_in_bytes <= 0)
92
            {
93
2
                return;
94
            }
95
96
63387
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
97
            {
98
62812
                memmove(pPut, pGet, (size_t)width_in_bytes);
99
100
62812
                pPut += context -> gx_draw_context_pitch;
101
62812
                pGet += context -> gx_draw_context_pitch;
102
            }
103
        }
104
        else
105
        {
106
            /* have to copy from right to left */
107
658
            pPut = context -> gx_draw_context_memory;
108
658
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
109
658
            pPut += block -> gx_rectangle_left;
110
111
658
            pGet = context -> gx_draw_context_memory;
112
658
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
113
658
            pGet += block -> gx_rectangle_left - xshift;
114
115
658
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 + xshift;
116
658
            width_in_bytes = width * (int)sizeof(GX_COLOR);
117
118
658
            if (width_in_bytes <= 0)
119
            {
120
1
                return;
121
            }
122
123
71287
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
124
            {
125
70630
                memmove(pPut, pGet, (size_t)width_in_bytes);
126
127
70630
                pPut += context -> gx_draw_context_pitch;
128
70630
                pGet += context -> gx_draw_context_pitch;
129
            }
130
        }
131
    }
132
    else
133
    {
134
613
        width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1;
135
613
        width_in_bytes = width * (int)sizeof(GX_COLOR);
136
137
613
        if (yshift > 0)
138
        {
139
            /* have to copy from top to bottom */
140
162
            pPut = context -> gx_draw_context_memory;
141
162
            pPut += block -> gx_rectangle_bottom * context -> gx_draw_context_pitch;
142
162
            pPut += block -> gx_rectangle_left;
143
144
162
            pGet = context -> gx_draw_context_memory;
145
162
            pGet += (block -> gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch;
146
162
            pGet += block -> gx_rectangle_left;
147
148
162
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 - yshift;
149
150
27254
            for (y = 0; y < height; y++)
151
            {
152
27092
                memmove(pPut, pGet, (size_t)width_in_bytes);
153
154
27092
                pPut -= context -> gx_draw_context_pitch;
155
27092
                pGet -= context -> gx_draw_context_pitch;
156
            }
157
        }
158
        else
159
        {
160
            /* have to copy from bottom to top */
161
451
            pPut = context -> gx_draw_context_memory;
162
451
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
163
451
            pPut += block -> gx_rectangle_left;
164
165
451
            pGet = context -> gx_draw_context_memory;
166
451
            pGet += (block -> gx_rectangle_top - yshift) * context -> gx_draw_context_pitch;
167
451
            pGet += block -> gx_rectangle_left;
168
169
451
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 + yshift;
170
171
65230
            for (y = 0; y < height; y++)
172
            {
173
64779
                memmove(pPut, pGet, (size_t)width_in_bytes);
174
175
64779
                pPut += context -> gx_draw_context_pitch;
176
64779
                pGet += context -> gx_draw_context_pitch;
177
            }
178
        }
179
    }
180
}
181