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