GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_scroll_wheel_gradient_create.c Lines: 20 20 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
/**   Scroll Wheel Management (Scroll Wheel)                              */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_scroll_wheel.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
#include "gx_widget.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_scroll_wheel_gradient_create                    PORTABLE C      */
37
/*                                                           6.1.5        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    Create the gradient pixelmap used to overlay the scroll wheel       */
45
/*    widget drawing.                                                     */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    wheel                                 Scroll wheel control block    */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _gx_utility_gradient_create           Create a gradient pixelmap    */
58
/*    _gx_utility_gradient_delete           Delete a gradient             */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*  12-31-2020     Kenneth Maxwell          Modified comment(s), added    */
72
/*                                            display rotation support,   */
73
/*                                            resulting in version 6.1.3  */
74
/*  03-02-2021     Kenneth Maxwell          Modified comment(s), added    */
75
/*                                            flip rotation support,      */
76
/*                                            resulting in version 6.1.5  */
77
/*                                                                        */
78
/**************************************************************************/
79
191
VOID _gx_scroll_wheel_gradient_create(GX_SCROLL_WHEEL *wheel)
80
{
81
GX_UBYTE    gradient_mode;
82
INT         height;
83
GX_CANVAS  *canvas;
84
GX_DISPLAY *display;
85
86
    /* test to see if the scroll wheel has an alpha-mask overlay */
87
191
    if (wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_start ||
88
13
        wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_end)
89
    {
90
        /* yes, test to see if it has been created */
91
179
        if (wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_data == GX_NULL)
92
        {
93
155
            _gx_widget_canvas_get((GX_WIDGET *)wheel, &canvas);
94
95
155
            if (canvas)
96
            {
97
154
                display = canvas -> gx_canvas_display;
98
154
                gradient_mode = GX_GRADIENT_TYPE_MIRROR | GX_GRADIENT_TYPE_ALPHA;
99
154
                height = wheel -> gx_widget_size.gx_rectangle_bottom - wheel -> gx_widget_size.gx_rectangle_top + 1;
100
101
154
                if (display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_NONE ||
102
72
                    display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_FLIP)
103
                {
104
85
                    _gx_utility_gradient_create(&wheel -> gx_scroll_wheel_gradient, 3, (GX_VALUE)height,
105
                                                gradient_mode | GX_GRADIENT_TYPE_VERTICAL,
106
85
                                                wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_start,
107
85
                                                wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_end);
108
                }
109
                else
110
                {
111
                    /* Generate rotated gradient map. */
112
69
                    _gx_utility_gradient_create(&wheel -> gx_scroll_wheel_gradient, (GX_VALUE)height, 3,
113
                                                gradient_mode,
114
69
                                                wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_start,
115
69
                                                wheel -> gx_scroll_wheel_gradient.gx_gradient_alpha_end);
116
117
69
                    GX_SWAP_VALS(wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_width,
118
                                 wheel -> gx_scroll_wheel_gradient.gx_gradient_pixelmap.gx_pixelmap_height);
119
                }
120
            }
121
        }
122
    }
123
    else
124
    {
125
        /* gradient is not used, if it has been created then delete it */
126
12
        _gx_utility_gradient_delete(&wheel -> gx_scroll_wheel_gradient);
127
    }
128
191
}
129