GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_8bpp_block_move.c Lines: 53 53 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_8bpp_block_move                  PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    8-bit 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
242
VOID _gx_display_driver_8bpp_block_move(GX_DRAW_CONTEXT *context,
67
                                        GX_RECTANGLE *block, INT xshift, INT yshift)
68
{
69
GX_UBYTE *pGet;
70
GX_UBYTE *pPut;
71
int       width;
72
int       y;
73
int       height;
74
75
242
    if (xshift)
76
    {
77
218
        if (xshift > 0)
78
        {
79
110
            pPut = (GX_UBYTE *)context -> gx_draw_context_memory;
80
110
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
81
110
            pPut += block -> gx_rectangle_left + xshift;
82
83
110
            pGet = (GX_UBYTE *)context -> gx_draw_context_memory;
84
110
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
85
110
            pGet += block -> gx_rectangle_left;
86
87
110
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 - xshift;
88
89
110
            if (width <= 0)
90
            {
91
                /* Shift distance is bigger than block with. */
92
1
                return;
93
            }
94
95
12473
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
96
            {
97
12364
                memmove(pPut, pGet, (size_t)width);
98
99
12364
                pPut += context -> gx_draw_context_pitch;
100
12364
                pGet += context -> gx_draw_context_pitch;
101
            }
102
        }
103
        else
104
        {
105
            /* have to copy from left to right */
106
108
            pPut = (GX_UBYTE *)context -> gx_draw_context_memory;
107
108
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
108
108
            pPut += block -> gx_rectangle_left;
109
110
108
            pGet = (GX_UBYTE *)context -> gx_draw_context_memory;
111
108
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
112
108
            pGet += block -> gx_rectangle_left - xshift;
113
114
108
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 + xshift;
115
116
108
            if (width <= 0)
117
            {
118
1
                return;
119
            }
120
121
12211
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
122
            {
123
12104
                memmove(pPut, pGet, (size_t)width);
124
125
12104
                pPut += context -> gx_draw_context_pitch;
126
12104
                pGet += context -> gx_draw_context_pitch;
127
            }
128
        }
129
    }
130
    else
131
    {
132
24
        width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1;
133
134
24
        if (yshift > 0)
135
        {
136
            /* have to copy from bottom to top */
137
12
            pPut = (GX_UBYTE *)context -> gx_draw_context_memory;
138
12
            pPut += block -> gx_rectangle_bottom * context -> gx_draw_context_pitch;
139
12
            pPut += block -> gx_rectangle_left;
140
141
12
            pGet = (GX_UBYTE *)context -> gx_draw_context_memory;
142
12
            pGet += (block -> gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch;
143
12
            pGet += block -> gx_rectangle_left;
144
145
12
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 - yshift;
146
147
1068
            for (y = 0; y < height; y++)
148
            {
149
1056
                memmove(pPut, pGet, (size_t)width);
150
151
1056
                pPut -= context -> gx_draw_context_pitch;
152
1056
                pGet -= context -> gx_draw_context_pitch;
153
            }
154
        }
155
        else
156
        {
157
            /* have to copy from top to bottom */
158
12
            pPut = (GX_UBYTE *)context -> gx_draw_context_memory;
159
12
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
160
12
            pPut += block -> gx_rectangle_left;
161
162
12
            pGet = (GX_UBYTE *)context -> gx_draw_context_memory;
163
12
            pGet += (block -> gx_rectangle_top - yshift) * context -> gx_draw_context_pitch;
164
12
            pGet += block -> gx_rectangle_left;
165
166
12
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 + yshift;
167
168
812
            for (y = 0; y < height; y++)
169
            {
170
800
                memmove(pPut, pGet, (size_t)width);
171
172
800
                pPut += context -> gx_draw_context_pitch;
173
800
                pGet += context -> gx_draw_context_pitch;
174
            }
175
        }
176
    }
177
}
178