GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_offset_set.c Lines: 24 24 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 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
/**   Canvas Management (Canvas)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
#include "gx_canvas.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_canvas_offset_set                               PORTABLE C      */
38
/*                                                           6.1.11       */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function assigns a canvas x,y display offset                   */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    canvas                                Canvas control block          */
50
/*    x                                     X coordinate of offset        */
51
/*    y                                     Y coordinate of offset        */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    gx_canvas_dirty_mark                  mark canvas as needing refresh*/
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    _gx_animation_start                                                 */
64
/*    _gx_animation_update                                                */
65
/*                                                                        */
66
/**************************************************************************/
67
1569
UINT  _gx_canvas_offset_set(GX_CANVAS *canvas, GX_VALUE xoffset, GX_VALUE yoffset)
68
{
69
GX_RECTANGLE oldpos;
70
GX_CANVAS   *backcanvas;
71
72
VOID (*offset_function)(INT layer, GX_VALUE x, GX_VALUE y);
73
74
    /* if there is a background canvas under this one it needs
75
       to be marked as dirty in the area
76
       this canvas is moving from
77
     */
78
79
1569
    if (canvas -> gx_canvas_hardware_layer >= 0)
80
    {
81
2
        offset_function = canvas -> gx_canvas_display -> gx_display_layer_services -> gx_display_layer_offset_set;
82
83
2
        if (offset_function)
84
        {
85
1
            offset_function(canvas -> gx_canvas_hardware_layer, xoffset, yoffset);
86
            /* move the canvas display position */
87
1
            canvas -> gx_canvas_display_offset_x = xoffset;
88
1
            canvas -> gx_canvas_display_offset_y = yoffset;
89
1
            return(GX_SUCCESS);
90
        }
91
    }
92
93
1568
    if ((canvas -> gx_canvas_status & GX_CANVAS_MANAGED) &&
94
1567
        canvas -> gx_canvas_created_next)
95
    {
96
521
        backcanvas = canvas -> gx_canvas_created_next;
97
98
        /* find the bottom layer canvas */
99
1190
        while (backcanvas -> gx_canvas_created_next)
100
        {
101
669
            backcanvas = backcanvas -> gx_canvas_created_next;
102
        }
103
104
        /* calculate rectangle bounding this canvas */
105
106
521
        oldpos.gx_rectangle_left  = canvas -> gx_canvas_display_offset_x;
107
521
        oldpos.gx_rectangle_top = canvas -> gx_canvas_display_offset_y;
108
521
        oldpos.gx_rectangle_right = (GX_VALUE)(oldpos.gx_rectangle_left + canvas -> gx_canvas_x_resolution - 1);
109
521
        oldpos.gx_rectangle_bottom = (GX_VALUE)(oldpos.gx_rectangle_top + canvas -> gx_canvas_y_resolution - 1);
110
111
521
        if (backcanvas -> gx_canvas_draw_count > 0)
112
        {
113
74
             _gx_utility_rectangle_combine(&oldpos, &backcanvas -> gx_canvas_dirty_area);
114
        }
115
116
        /* mark the background as dirty */
117
521
        _gx_canvas_dirty_mark(backcanvas, &oldpos);
118
    }
119
120
    /* move the canvas display position */
121
1568
    canvas -> gx_canvas_display_offset_x = xoffset;
122
1568
    canvas -> gx_canvas_display_offset_y = yoffset;
123
124
    /* now mark the foreground canvas as dirty and modified */
125
1568
    _gx_canvas_dirty_mark(canvas, NULL);
126
1568
    return GX_SUCCESS;
127
}
128