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