GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_block_move.c Lines: 26 28 92.9 %
Date: 2026-08-28 02:37:13 Branches: 15 18 83.3 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026 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
// Some portions generated by Copilot (Claude Sonnet 4.6).
12
13
14
/**************************************************************************/
15
/**************************************************************************/
16
/**                                                                       */
17
/** GUIX Component                                                        */
18
/**                                                                       */
19
/**   Widget Management (Widget)                                          */
20
/**                                                                       */
21
/**************************************************************************/
22
23
#define GX_SOURCE_CODE
24
25
26
/* Include necessary system files.  */
27
28
#include "gx_api.h"
29
#include "gx_system.h"
30
#include "gx_widget.h"
31
#include "gx_canvas.h"
32
#include "gx_utility.h"
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_widget_block_move                               PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This service move a rectangular block of pixels.                    */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    widget                                Pointer to widget             */
51
/*    block                                 Rectangle to move             */
52
/*    x_shift                               Number of pixels to shift on  */
53
/*                                            the x-axis                  */
54
/*    y_shift                               Number of pixels to shift on  */
55
/*                                            the y-axis                  */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    status                                Completion status             */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    _gx_system_dirty_partial_add          Add area to the dirty list    */
64
/*    _gx_widget_canvas_get                 Find canvas associated with   */
65
/*                                            the specified widget        */
66
/*    _gx_canvas_drawing_initiate           Start canvas draw             */
67
/*    _gx_canvas_block_move                 Canvas-level block move call  */
68
/*    _gx_canvas_drawing_complete           Finish canvas draw            */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    Application Code                                                    */
73
/*    GUIX Internal Code                                                  */
74
/*                                                                        */
75
/**************************************************************************/
76
3814
UINT _gx_widget_block_move(GX_WIDGET *widget, GX_RECTANGLE *block, INT x_shift, INT y_shift)
77
{
78
GX_CANVAS   *canvas;
79
UINT         status;
80
GX_RECTANGLE dirty;
81
GX_VALUE     width;
82
GX_VALUE     height;
83
84
✓✓
3814
    if (widget -> gx_widget_status & GX_STATUS_TRANSPARENT)
85
    {
86
        /* cannot do block move if transparent widget */
87
323
        _gx_system_dirty_partial_add(widget, block);
88
323
        return GX_SUCCESS;
89
    }
90
91
3491
    _gx_widget_canvas_get(widget, &canvas);
92
93
✓✓
3491
    if (!canvas)
94
    {
95
1
        return GX_INVALID_CANVAS;
96
    }
97
98
3490
    GX_ENTER_CRITICAL
99
100
3490
    _gx_widget_width_get(widget, &width);
101
3490
    _gx_widget_height_get(widget, &height);
102
103
✓✓✓✓
3490
    if ((GX_ABS(x_shift) >= width) || (GX_ABS(y_shift) >= height))
104
    {
105
        /* Shift is too large, just invalidate the widget. */
106
752
        _gx_system_dirty_partial_add(widget, block);
107
    }
108
    else
109
    {
110
2738
        status = _gx_canvas_drawing_initiate(canvas, widget, block);
111
112
✓✓
2738
        if (status == GX_SUCCESS)
113
        {
114
✓✓
2687
            if (_gx_canvas_block_move(block, (GX_VALUE)x_shift, (GX_VALUE)y_shift, &dirty) == GX_SUCCESS)
115
            {
116
                /* re-draw the portion that could not be moved */
117
2669
                UINT inner_status = _gx_canvas_drawing_initiate(canvas, widget, &dirty);
118
119
✓✗
2669
                if (inner_status == GX_SUCCESS)
120
                {
121
2669
                    widget->gx_widget_draw_function(widget);
122
2669
                    _gx_canvas_drawing_complete(canvas, GX_FALSE);
123
                }
124
                else if (inner_status == GX_NO_VIEWS)
125
                {
126
                    _gx_canvas_drawing_complete(canvas, GX_FALSE);
127
                }
128
2669
                _gx_canvas_drawing_complete(canvas, GX_TRUE);
129
            }
130
            else
131
            {
132
                /* block move was not successful, just invalidate the widget client */
133
18
                _gx_system_dirty_partial_add(widget, block);
134
18
                _gx_canvas_drawing_complete(canvas, GX_FALSE);
135
            }
136
        }
137
✓✓
51
        else if (status == GX_NO_VIEWS)
138
        {
139
50
            _gx_canvas_drawing_complete(canvas, GX_FALSE);
140
        }
141
    }
142
143
3490
    GX_EXIT_CRITICAL
144
3490
    return(GX_SUCCESS);
145
}
146