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 |
|
|
/** Utility (Utility) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#include "gx_api.h" |
26 |
|
|
#include "gx_canvas.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
|
30 |
|
|
/**************************************************************************/ |
31 |
|
|
/* */ |
32 |
|
|
/* FUNCTION RELEASE */ |
33 |
|
|
/* */ |
34 |
|
|
/* _gx_utility_gradient_delete PORTABLE C */ |
35 |
|
|
/* 6.1 */ |
36 |
|
|
/* AUTHOR */ |
37 |
|
|
/* */ |
38 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
39 |
|
|
/* */ |
40 |
|
|
/* DESCRIPTION */ |
41 |
|
|
/* */ |
42 |
|
|
/* This function deletes a previously created gradient. */ |
43 |
|
|
/* */ |
44 |
|
|
/* INPUT */ |
45 |
|
|
/* */ |
46 |
|
|
/* gradient Pointer to GX_GRADIENT */ |
47 |
|
|
/* */ |
48 |
|
|
/* OUTPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* None */ |
51 |
|
|
/* */ |
52 |
|
|
/* CALLS */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLED BY */ |
55 |
|
|
/* */ |
56 |
|
|
/* RELEASE HISTORY */ |
57 |
|
|
/* */ |
58 |
|
|
/* DATE NAME DESCRIPTION */ |
59 |
|
|
/* */ |
60 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
61 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
62 |
|
|
/* resulting in version 6.1 */ |
63 |
|
|
/* */ |
64 |
|
|
/**************************************************************************/ |
65 |
|
23 |
UINT _gx_utility_gradient_delete(GX_GRADIENT *gradient) |
66 |
|
|
{ |
67 |
|
23 |
const GX_UBYTE *data_ptr = gradient -> gx_gradient_pixelmap.gx_pixelmap_data; |
68 |
|
|
GX_GRADIENT *search; |
69 |
|
23 |
GX_BOOL in_use = GX_FALSE; |
70 |
|
|
|
71 |
|
23 |
GX_ENTER_CRITICAL |
72 |
|
|
|
73 |
✓✓ |
23 |
if (data_ptr) |
74 |
|
|
{ |
75 |
|
|
/* check to see if any other gradients are using same pixelmap data, |
76 |
|
|
if not, then time to delete pixelmap data |
77 |
|
|
*/ |
78 |
|
9 |
search = _gx_system_gradient_list; |
79 |
|
|
|
80 |
✓✓ |
21 |
while (search) |
81 |
|
|
{ |
82 |
✓✓ |
18 |
if (search != gradient && |
83 |
✓✓ |
12 |
search -> gx_gradient_pixelmap.gx_pixelmap_data == data_ptr) |
84 |
|
|
{ |
85 |
|
6 |
in_use = GX_TRUE; |
86 |
|
6 |
break; |
87 |
|
|
} |
88 |
|
12 |
search = search -> gx_gradient_next; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
/* unlink this gradient from gradient list */ |
92 |
|
|
|
93 |
✓✓ |
9 |
if (gradient -> gx_gradient_next) |
94 |
|
|
{ |
95 |
|
5 |
gradient -> gx_gradient_next -> gx_gradient_previous = gradient -> gx_gradient_previous; |
96 |
|
|
} |
97 |
✓✓ |
9 |
if (gradient -> gx_gradient_previous) |
98 |
|
|
{ |
99 |
|
4 |
gradient -> gx_gradient_previous -> gx_gradient_next = gradient -> gx_gradient_next; |
100 |
|
|
} |
101 |
|
|
else |
102 |
|
|
{ |
103 |
|
5 |
_gx_system_gradient_list = gradient -> gx_gradient_next; |
104 |
|
|
} |
105 |
|
|
} |
106 |
|
|
|
107 |
|
23 |
GX_EXIT_CRITICAL |
108 |
|
|
|
109 |
✓✓✓✓ ✓✓ |
23 |
if (data_ptr && !in_use && _gx_system_memory_free) |
110 |
|
|
{ |
111 |
|
2 |
_gx_system_memory_free((void *)data_ptr); |
112 |
|
|
} |
113 |
|
|
|
114 |
|
23 |
memset(gradient, 0, sizeof(GX_GRADIENT)); |
115 |
|
|
|
116 |
|
23 |
return GX_SUCCESS; |
117 |
|
|
} |
118 |
|
|
|