GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_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
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_display_driver_16bpp_block_move                 PORTABLE C      */
37
/*                                                           6.3.0        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    Generic 16bpp color format display driver block moving 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 a block of data          */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
308
VOID _gx_display_driver_16bpp_block_move(GX_DRAW_CONTEXT *context,
67
                                         GX_RECTANGLE *block, INT xshift, INT yshift)
68
{
69
USHORT *pGet;
70
USHORT *pPut;
71
INT     width;
72
INT     width_in_bytes;
73
INT     y;
74
INT     height;
75
76
#ifdef GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER
77
    if (context -> gx_draw_context_canvas -> gx_canvas_status & GX_CANVAS_PARTIAL_FRAME_BUFFER)
78
    {
79
        /* Not supported. */
80
        return;
81
    }
82
#endif
83
84
308
    if (xshift)
85
    {
86
215
        if (xshift > 0)
87
        {
88
            /* have to copy from left to right. */
89
110
            pPut = (USHORT *)context -> gx_draw_context_memory;
90
110
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
91
110
            pPut += block -> gx_rectangle_left + xshift;
92
93
110
            pGet = (USHORT *)context -> gx_draw_context_memory;
94
110
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
95
110
            pGet += block -> gx_rectangle_left;
96
97
110
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 - xshift;
98
110
            width_in_bytes = width * (int)sizeof(USHORT);
99
100
110
            if (width_in_bytes <= 0)
101
            {
102
1
                return;
103
            }
104
105
12451
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
106
            {
107
12342
                memmove(pPut, pGet, (size_t)width_in_bytes);
108
109
12342
                pPut += context -> gx_draw_context_pitch;
110
12342
                pGet += context -> gx_draw_context_pitch;
111
            }
112
        }
113
        else
114
        {
115
            /* have to copy from right to left */
116
105
            pPut = (USHORT *)context -> gx_draw_context_memory;
117
105
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
118
105
            pPut += block -> gx_rectangle_left;
119
120
105
            pGet = (USHORT *)context -> gx_draw_context_memory;
121
105
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
122
105
            pGet += block -> gx_rectangle_left - xshift;
123
124
105
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 + xshift;
125
105
            width_in_bytes = width * (int)sizeof(USHORT);
126
127
105
            if (width_in_bytes <= 0)
128
            {
129
1
                return;
130
            }
131
132
11876
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
133
            {
134
11772
                memmove(pPut, pGet, (size_t)width_in_bytes);
135
136
11772
                pPut += context -> gx_draw_context_pitch;
137
11772
                pGet += context -> gx_draw_context_pitch;
138
            }
139
        }
140
    }
141
    else
142
    {
143
93
        width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1;
144
93
        width_in_bytes = width * (int)sizeof(USHORT);
145
146
93
        if (yshift > 0)
147
        {
148
            /* have to copy from top to bottom */
149
48
            pPut = (USHORT *)context -> gx_draw_context_memory;
150
48
            pPut += block -> gx_rectangle_bottom * context -> gx_draw_context_pitch;
151
48
            pPut += block -> gx_rectangle_left;
152
153
48
            pGet = (USHORT *)context -> gx_draw_context_memory;
154
48
            pGet += (block -> gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch;
155
48
            pGet += block -> gx_rectangle_left;
156
157
48
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 - yshift;
158
159
5681
            for (y = 0; y < height; y++)
160
            {
161
5633
                memmove(pPut, pGet, (size_t)width_in_bytes);
162
163
5633
                pPut -= context -> gx_draw_context_pitch;
164
5633
                pGet -= context -> gx_draw_context_pitch;
165
            }
166
        }
167
        else
168
        {
169
            /* have to copy from bottom to top */
170
45
            pPut = (USHORT *)context -> gx_draw_context_memory;
171
45
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
172
45
            pPut += block -> gx_rectangle_left;
173
174
45
            pGet = (USHORT *)context -> gx_draw_context_memory;
175
45
            pGet += (block -> gx_rectangle_top - yshift) * context -> gx_draw_context_pitch;
176
45
            pGet += block -> gx_rectangle_left;
177
178
45
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 + yshift;
179
180
5225
            for (y = 0; y < height; y++)
181
            {
182
5180
                memmove(pPut, pGet, (size_t)width_in_bytes);
183
184
5180
                pPut += context -> gx_draw_context_pitch;
185
5180
                pGet += context -> gx_draw_context_pitch;
186
            }
187
        }
188
    }
189
}
190