forked from duanjiahao/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNative.cs
More file actions
293 lines (211 loc) · 11 KB
/
Native.cs
File metadata and controls
293 lines (211 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine.Scripting;
namespace UnityEngine.CSSLayout
{
internal static class Native
{
private const string DllName = "CSSLayout";
private static Dictionary<IntPtr, WeakReference> s_MeasureFunctions = new Dictionary<IntPtr, WeakReference>();
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern IntPtr CSSNodeNew();
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeInit(IntPtr cssNode);
public static void CSSNodeFree(IntPtr cssNode)
{
if (!(cssNode == IntPtr.Zero))
{
Native.CSSNodeSetMeasureFunc(cssNode, null);
Native.CSSNodeFreeInternal(cssNode);
}
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void CSSNodeFreeInternal(IntPtr cssNode);
public static void CSSNodeReset(IntPtr cssNode)
{
Native.CSSNodeSetMeasureFunc(cssNode, null);
Native.CSSNodeResetInternal(cssNode);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void CSSNodeResetInternal(IntPtr cssNode);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int CSSNodeGetInstanceCount();
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeRemoveChild(IntPtr node, IntPtr child);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern IntPtr CSSNodeGetChild(IntPtr node, uint index);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern uint CSSNodeChildCount(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeCalculateLayout(IntPtr node, float availableWidth, float availableHeight, CSSDirection parentDirection);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeMarkDirty(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool CSSNodeIsDirty(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodePrint(IntPtr node, CSSPrintOptions options);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool CSSValueIsUndefined(float value);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeSetContext(IntPtr node, IntPtr context);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern IntPtr CSSNodeGetContext(IntPtr node);
public static void CSSNodeSetMeasureFunc(IntPtr node, CSSMeasureFunc measureFunc)
{
if (measureFunc != null)
{
Native.s_MeasureFunctions[node] = new WeakReference(measureFunc);
CSSLayoutCallbacks.RegisterWrapper(node);
}
else if (Native.s_MeasureFunctions.ContainsKey(node))
{
Native.s_MeasureFunctions.Remove(node);
CSSLayoutCallbacks.UnegisterWrapper(node);
}
}
public static CSSMeasureFunc CSSNodeGetMeasureFunc(IntPtr node)
{
WeakReference weakReference = null;
CSSMeasureFunc result;
if (Native.s_MeasureFunctions.TryGetValue(node, out weakReference) && weakReference.IsAlive)
{
result = (weakReference.Target as CSSMeasureFunc);
}
else
{
result = null;
}
return result;
}
[RequiredByNativeCode]
public unsafe static void CSSNodeMeasureInvoke(IntPtr node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, IntPtr returnValueAddress)
{
CSSMeasureFunc cSSMeasureFunc = Native.CSSNodeGetMeasureFunc(node);
if (cSSMeasureFunc != null)
{
*(CSSSize*)((void*)returnValueAddress) = cSSMeasureFunc(node, width, widthMode, height, heightMode);
}
}
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeSetHasNewLayout(IntPtr node, bool hasNewLayout);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool CSSNodeGetHasNewLayout(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetDirection(IntPtr node, CSSDirection direction);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSDirection CSSNodeStyleGetDirection(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, CSSFlexDirection flexDirection);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, CSSJustify justifyContent);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSJustify CSSNodeStyleGetJustifyContent(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetAlignContent(IntPtr node, CSSAlign alignContent);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSAlign CSSNodeStyleGetAlignContent(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetAlignItems(IntPtr node, CSSAlign alignItems);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSAlign CSSNodeStyleGetAlignItems(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, CSSAlign alignSelf);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSAlign CSSNodeStyleGetAlignSelf(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetPositionType(IntPtr node, CSSPositionType positionType);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSPositionType CSSNodeStyleGetPositionType(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, CSSWrap flexWrap);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSWrap CSSNodeStyleGetFlexWrap(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetOverflow(IntPtr node, CSSOverflow flexWrap);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSOverflow CSSNodeStyleGetOverflow(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetFlexGrow(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetFlexShrink(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetFlexBasis(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetWidth(IntPtr node, float width);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetWidth(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetHeight(IntPtr node, float height);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetHeight(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetMinWidth(IntPtr node, float minWidth);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetMinWidth(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetMinHeight(IntPtr node, float minHeight);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetMinHeight(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetMaxWidth(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetMaxHeight(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetAspectRatio(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetPosition(IntPtr node, CSSEdge edge, float position);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetPosition(IntPtr node, CSSEdge edge);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetMargin(IntPtr node, CSSEdge edge, float margin);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetMargin(IntPtr node, CSSEdge edge);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetPadding(IntPtr node, CSSEdge edge, float padding);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetPadding(IntPtr node, CSSEdge edge);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void CSSNodeStyleSetBorder(IntPtr node, CSSEdge edge, float border);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeStyleGetBorder(IntPtr node, CSSEdge edge);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetLeft(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetTop(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetRight(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetBottom(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetWidth(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern float CSSNodeLayoutGetHeight(IntPtr node);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern CSSDirection CSSNodeLayoutGetDirection(IntPtr node);
}
}