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_hide                                     PORTABLE C      */
37 /*                                                           6.1.3        */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function makes a canvas invisible                              */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    canvas                                Canvas control block          */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _gx_canvas_dirty_mark                 Set the canvas dirty flag     */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application                                                         */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
67 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*  12-31-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            modified canvas dirty logic,*/
71 /*                                            resulting in version 6.1.3  */
72 /*                                                                        */
73 /**************************************************************************/
_gx_canvas_hide(GX_CANVAS * canvas)74 UINT  _gx_canvas_hide(GX_CANVAS *canvas)
75 {
76 VOID         (*hide_function)(INT layer);
77 GX_CANVAS   *head = _gx_system_canvas_created_list;
78 GX_RECTANGLE dirty;
79 GX_RECTANGLE combine;
80 
81     /* change canvas status flag. */
82     canvas -> gx_canvas_status &= ~(UINT)(GX_CANVAS_VISIBLE);
83 
84     if (canvas -> gx_canvas_hardware_layer >= 0)
85     {
86         hide_function = canvas -> gx_canvas_display -> gx_display_layer_services -> gx_display_layer_hide;
87 
88         if (hide_function)
89         {
90             hide_function(canvas -> gx_canvas_hardware_layer);
91             return(GX_SUCCESS);
92         }
93     }
94 
95     /* mark the canvas dirty so that it get refreshed */
96     _gx_utility_rectangle_define(&dirty, 0, 0, (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1), (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1));
97     if (canvas -> gx_canvas_display_offset_x || canvas -> gx_canvas_display_offset_y)
98     {
99         _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y);
100     }
101 
102     while (head)
103     {
104         if (head -> gx_canvas_status & GX_CANVAS_VISIBLE)
105         {
106             _gx_utility_rectangle_define(&combine, 0, 0, (GX_VALUE)(head -> gx_canvas_x_resolution - 1), (GX_VALUE)(head -> gx_canvas_y_resolution - 1));
107 
108             if (head -> gx_canvas_display_offset_x || head -> gx_canvas_display_offset_y)
109             {
110                 _gx_utility_rectangle_shift(&combine, head -> gx_canvas_display_offset_x, head -> gx_canvas_display_offset_y);
111             }
112 
113             _gx_utility_rectangle_combine(&combine, &dirty);
114             _gx_canvas_dirty_mark(head, &combine);
115         }
116 
117         head = head -> gx_canvas_created_next;
118     }
119 
120     /* Return successful status.  */
121     return(GX_SUCCESS);
122 }
123 
124