GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_window_border_draw.c Lines: 29 29 100.0 %
Date: 2026-03-06 19:21:09 Branches: 18 18 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
/**   Window Management (Window)                                          */
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_canvas.h"
30
#include "gx_context.h"
31
#include "gx_widget.h"
32
#include "gx_utility.h"
33
#include "gx_window.h"
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gx_window_border_draw                              PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function draws the background of a window widget width         */
48
/*    specified fill color.                                               */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    win                                   Window control block          */
53
/*    fill_color                            Specified fill color ID       */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    status                                Completion status             */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_context_pixelmap_get              Get pixelmap with specified   */
62
/*                                            resource ID                 */
63
/*    _gx_widget_border_width_get           Get the border width          */
64
/*    _gx_widget_client_get                 Get the widget client         */
65
/*    _gx_widget_border_draw                Draw widget background        */
66
/*    _gx_canvas_pixelmap_tile              Draw pixelmap in tile style   */
67
/*    _gx_canvas_pixelmap_draw              Draw the pixelmap             */
68
/*    _gx_utility_rectangle_overlap_detect  Detect rectangle overlap      */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    Application Code                                                    */
73
/*    GUIX Internal Code                                                  */
74
/*                                                                        */
75
/**************************************************************************/
76
492267
VOID  _gx_window_border_draw(GX_WINDOW *win, GX_RESOURCE_ID fill_color)
77
{
78
492267
GX_WIDGET       *widget = (GX_WIDGET *)win;
79
492267
GX_PIXELMAP     *pixelmap = GX_NULL;
80
492267
GX_BOOL          fill = GX_TRUE;
81
GX_DRAW_CONTEXT *context;
82
GX_VALUE         width;
83
GX_VALUE         height;
84
GX_RECTANGLE     client;
85
GX_RECTANGLE     old_clip;
86
GX_VALUE         border_width;
87
88
    /* test to see if we need to solid fill */
89
90
492267
    if (win -> gx_window_wallpaper != 0)
91
    {
92
96410
        _gx_context_pixelmap_get(win -> gx_window_wallpaper, &pixelmap);
93
94
        /* do we have a wallpaper ? */
95
96410
        if (pixelmap)
96
        {
97
96403
            _gx_widget_border_width_get(widget, &border_width);
98
99
            /* get size of client rectangle */
100
96403
            _gx_widget_client_get(widget, border_width, &client);
101
102
            /* is the wallpaper transparent at all ? */
103
96403
            if ((pixelmap -> gx_pixelmap_flags & (GX_PIXELMAP_TRANSPARENT | GX_PIXELMAP_ALPHA)) == 0)
104
            {
105
                /* will the wallpaper fill my client area ? */
106
51594
                if (widget -> gx_widget_style & GX_STYLE_TILE_WALLPAPER)
107
                {
108
                    /* yes, don't need to fill */
109
1737
                    fill = GX_FALSE;
110
                }
111
                else
112
                {
113
49857
                    width = (GX_VALUE)(client.gx_rectangle_right - client.gx_rectangle_left + 1);
114
49857
                    height = (GX_VALUE)(client.gx_rectangle_bottom - client.gx_rectangle_top + 1);
115
116
49857
                    if (pixelmap -> gx_pixelmap_width >= width &&
117
47995
                        pixelmap -> gx_pixelmap_height >= height)
118
                    {
119
                        /* yes, don't need to solid fill */
120
47991
                        fill = GX_FALSE;
121
                    }
122
                }
123
            }
124
        }
125
    }
126
127
492267
    _gx_widget_border_draw(widget, GX_COLOR_ID_WINDOW_BORDER, fill_color, fill_color, fill);
128
129
492267
    if (pixelmap)
130
    {
131
96403
        _gx_widget_context_fill_set(widget);
132
96403
        if (widget -> gx_widget_style & GX_STYLE_TILE_WALLPAPER)
133
        {
134
            /* tile the pixelmap into the window client area */
135
1970
            _gx_canvas_pixelmap_tile(&client, pixelmap);
136
        }
137
        else
138
        {
139
            /* temporarily set context clipping to my client area */
140
94433
            context = _gx_system_current_draw_context;
141
94433
            old_clip = context -> gx_draw_context_dirty;
142
94433
            fill = _gx_utility_rectangle_overlap_detect(&client, &old_clip, &context -> gx_draw_context_dirty);
143
144
94433
            if (fill)
145
            {
146
                /* draw the pixelmap */
147
94374
                _gx_canvas_pixelmap_draw(client.gx_rectangle_left, client.gx_rectangle_top, pixelmap);
148
94374
                context -> gx_draw_context_dirty = old_clip;
149
            }
150
        }
151
    }
152
492267
}
153