GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_block_move.c Lines: 56 56 100.0 %
Date: 2024-12-05 08:52:37 Branches: 18 18 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_system.h"
29
#include "gx_utility.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_driver_16bpp_block_move                 PORTABLE C      */
36
/*                                                           6.3.0        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Generic 16bpp 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 a block of data          */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*  10-31-2023     Ting Zhu                 Modified comment(s),          */
72
/*                                            added canvas status check,  */
73
/*                                            resulting in version 6.3.0  */
74
/*                                                                        */
75
/**************************************************************************/
76
308
VOID _gx_display_driver_16bpp_block_move(GX_DRAW_CONTEXT *context,
77
                                         GX_RECTANGLE *block, INT xshift, INT yshift)
78
{
79
USHORT *pGet;
80
USHORT *pPut;
81
INT     width;
82
INT     width_in_bytes;
83
INT     y;
84
INT     height;
85
86
#ifdef GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER
87
    if (context -> gx_draw_context_canvas -> gx_canvas_status & GX_CANVAS_PARTIAL_FRAME_BUFFER)
88
    {
89
        /* Not supported. */
90
        return;
91
    }
92
#endif
93
94
308
    if (xshift)
95
    {
96
215
        if (xshift > 0)
97
        {
98
            /* have to copy from left to right. */
99
110
            pPut = (USHORT *)context -> gx_draw_context_memory;
100
110
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
101
110
            pPut += block -> gx_rectangle_left + xshift;
102
103
110
            pGet = (USHORT *)context -> gx_draw_context_memory;
104
110
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
105
110
            pGet += block -> gx_rectangle_left;
106
107
110
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 - xshift;
108
110
            width_in_bytes = width * (int)sizeof(USHORT);
109
110
110
            if (width_in_bytes <= 0)
111
            {
112
1
                return;
113
            }
114
115
12451
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
116
            {
117
12342
                memmove(pPut, pGet, (size_t)width_in_bytes);
118
119
12342
                pPut += context -> gx_draw_context_pitch;
120
12342
                pGet += context -> gx_draw_context_pitch;
121
            }
122
        }
123
        else
124
        {
125
            /* have to copy from right to left */
126
105
            pPut = (USHORT *)context -> gx_draw_context_memory;
127
105
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
128
105
            pPut += block -> gx_rectangle_left;
129
130
105
            pGet = (USHORT *)context -> gx_draw_context_memory;
131
105
            pGet += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
132
105
            pGet += block -> gx_rectangle_left - xshift;
133
134
105
            width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1 + xshift;
135
105
            width_in_bytes = width * (int)sizeof(USHORT);
136
137
105
            if (width_in_bytes <= 0)
138
            {
139
1
                return;
140
            }
141
142
11876
            for (y = block -> gx_rectangle_top; y <= block -> gx_rectangle_bottom; y++)
143
            {
144
11772
                memmove(pPut, pGet, (size_t)width_in_bytes);
145
146
11772
                pPut += context -> gx_draw_context_pitch;
147
11772
                pGet += context -> gx_draw_context_pitch;
148
            }
149
        }
150
    }
151
    else
152
    {
153
93
        width = block -> gx_rectangle_right - block -> gx_rectangle_left + 1;
154
93
        width_in_bytes = width * (int)sizeof(USHORT);
155
156
93
        if (yshift > 0)
157
        {
158
            /* have to copy from top to bottom */
159
48
            pPut = (USHORT *)context -> gx_draw_context_memory;
160
48
            pPut += block -> gx_rectangle_bottom * context -> gx_draw_context_pitch;
161
48
            pPut += block -> gx_rectangle_left;
162
163
48
            pGet = (USHORT *)context -> gx_draw_context_memory;
164
48
            pGet += (block -> gx_rectangle_bottom - yshift) * context -> gx_draw_context_pitch;
165
48
            pGet += block -> gx_rectangle_left;
166
167
48
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 - yshift;
168
169
5681
            for (y = 0; y < height; y++)
170
            {
171
5633
                memmove(pPut, pGet, (size_t)width_in_bytes);
172
173
5633
                pPut -= context -> gx_draw_context_pitch;
174
5633
                pGet -= context -> gx_draw_context_pitch;
175
            }
176
        }
177
        else
178
        {
179
            /* have to copy from bottom to top */
180
45
            pPut = (USHORT *)context -> gx_draw_context_memory;
181
45
            pPut += block -> gx_rectangle_top * context -> gx_draw_context_pitch;
182
45
            pPut += block -> gx_rectangle_left;
183
184
45
            pGet = (USHORT *)context -> gx_draw_context_memory;
185
45
            pGet += (block -> gx_rectangle_top - yshift) * context -> gx_draw_context_pitch;
186
45
            pGet += block -> gx_rectangle_left;
187
188
45
            height = block -> gx_rectangle_bottom - block -> gx_rectangle_top + 1 + yshift;
189
190
5225
            for (y = 0; y < height; y++)
191
            {
192
5180
                memmove(pPut, pGet, (size_t)width_in_bytes);
193
194
5180
                pPut += context -> gx_draw_context_pitch;
195
5180
                pGet += context -> gx_draw_context_pitch;
196
            }
197
        }
198
    }
199
}
200