GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_16bpp_canvas_copy.c Lines: 18 18 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 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_utility.h"
30
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_display_driver_16bpp_canvas_copy                PORTABLE C      */
38
/*                                                           6.3.0        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    Generic 16bpp canvas copy function.                                 */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*   canvas                                 The canvas to copy from       */
50
/*   composite                              The canvas to copy to         */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_utility_rectangle_shift           Move the rectangle            */
59
/*    _gx_utility_rectangle_overlap_detect  Detect two rectangles being   */
60
/*                                            overlap to each other       */
61
/*    memcpy                                Move canvas data              */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    GUIX Internal Code                                                  */
66
/*                                                                        */
67
/**************************************************************************/
68
1796
VOID _gx_display_driver_16bpp_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite)
69
{
70
GX_RECTANGLE dirty;
71
GX_RECTANGLE overlap;
72
USHORT      *read;
73
USHORT      *write;
74
INT          width;
75
INT          row;
76
77
#ifdef GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER
78
    if (canvas -> gx_canvas_status & GX_CANVAS_PARTIAL_FRAME_BUFFER)
79
    {
80
        /* Not supported. */
81
        return;
82
    }
83
#endif
84
85
1796
    dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0;
86
1796
    dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - (GX_VALUE)1);
87
1796
    dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - (GX_VALUE)1);
88
89
1796
    _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y);
90
91
1796
    if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap))
92
    {
93
1557
        width = overlap.gx_rectangle_right - overlap.gx_rectangle_left + 1;
94
1557
        read = (USHORT *)canvas -> gx_canvas_memory;
95
96
        /* index into starting row */
97
1557
        read += (overlap.gx_rectangle_top - dirty.gx_rectangle_top) * canvas -> gx_canvas_x_resolution;
98
99
        /* index into pixel */
100
101
1557
        read += overlap.gx_rectangle_left - dirty.gx_rectangle_left;
102
103
        /* calculate the write pointer */
104
1557
        write = (USHORT *)composite -> gx_canvas_memory;
105
1557
        write += overlap.gx_rectangle_top * composite -> gx_canvas_x_resolution;
106
1557
        write += overlap.gx_rectangle_left;
107
108
513733
        for (row = overlap.gx_rectangle_top; row <= overlap.gx_rectangle_bottom; row++)
109
        {
110
512176
            memcpy(write, read, (size_t)(width * 2)); /* Use case of memcpy is verified. */
111
112
512176
            write += composite -> gx_canvas_x_resolution;
113
512176
            read += canvas -> gx_canvas_x_resolution;
114
        }
115
    }
116
1796
}
117