@geastack/engine 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/canvas.cpp +105 -48
- package/css/declarative.h +6 -0
- package/css/engine.h +20 -0
- package/image_store.cpp +136 -33
- package/package.json +4 -3
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +77 -62
- package/ui/core.cpp +26 -3
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +369 -0
- package/ui/document.cpp +11 -0
- package/ui/image_node.cpp +25 -24
- package/ui/input.cpp +46 -26
- package/ui/input_render.cpp +31 -27
- package/ui/internal.h +22 -0
- package/ui/layout.cpp +899 -613
- package/ui/layout_snapshot.cpp +29 -2
- package/ui/node_features.h +36 -0
- package/ui/node_lifecycle.cpp +358 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +816 -96
- package/ui/node_text.h +84 -0
- package/ui/refresh_perf.h +19 -17
- package/ui/render.cpp +341 -259
- package/ui/renderer_features.h +24 -0
- package/ui/root_scroll_refresh.cpp +86 -69
- package/ui/storage_usage.h +45 -0
- package/ui/style.cpp +1398 -349
- package/ui/style_values.h +2 -2
- package/ui/text.cpp +172 -154
- package/ui/tree_events.cpp +218 -92
- package/ui/tree_events.h +44 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +51 -19
- package/ui/tree_render.cpp +159 -126
- package/ui/tree_scroll_mirror.cpp +30 -4
- package/ui/tree_state.cpp +334 -115
- package/ui/tree_state.h +118 -22
- package/ui/tree_style.cpp +679 -303
- package/ui/view.cpp +268 -208
- package/ui/virtual_keyboard.cpp +18 -11
package/ui/layout_snapshot.cpp
CHANGED
|
@@ -13,20 +13,27 @@ void LayoutSnapshot::capture()
|
|
|
13
13
|
// !anyTransformActive), and anyTransformActive checks both current and previous
|
|
14
14
|
// transforms — so for a tree with no transforms (e.g. bouncing-balls) these reads
|
|
15
15
|
// are pure per-frame waste and the stale previous_* values are never observed. Skip
|
|
16
|
-
// them. The filter snapshot is independent
|
|
16
|
+
// them. The filter snapshot is independent and retained when filters are reachable.
|
|
17
|
+
#if GEA_CSS_TRANSFORMS
|
|
17
18
|
const bool captureTransforms = ViewRenderer::anyTransformActive();
|
|
19
|
+
#endif
|
|
18
20
|
for (int i = 0; i < state.nodeCount; i++) {
|
|
19
21
|
state.nodes[i].layout.previous_x = state.nodes[i].layout.x;
|
|
20
22
|
state.nodes[i].layout.previous_y = state.nodes[i].layout.y;
|
|
21
23
|
state.nodes[i].layout.previous_width = state.nodes[i].layout.width;
|
|
22
24
|
state.nodes[i].layout.previous_height = state.nodes[i].layout.height;
|
|
25
|
+
#if GEA_CSS_SCROLLING
|
|
23
26
|
state.nodes[i].layout.previous_scroll_x = state.nodes[i].layout.scroll_x;
|
|
24
27
|
state.nodes[i].layout.previous_scroll_y = state.nodes[i].layout.scroll_y;
|
|
28
|
+
#endif
|
|
25
29
|
// ONE RareStyle pool lookup per node, not ~16 — rstyle() is an out-of-line
|
|
26
30
|
// deque index (separate cache line from the node). Per-field lookups here cost
|
|
27
31
|
// ~1ms/frame on the spinning css-3d-cube (the "snap" phase); spine read these as
|
|
28
32
|
// direct ComputedStyle fields. (Same regression class as the reproject path.)
|
|
29
|
-
|
|
33
|
+
#if GEA_CSS_TRANSFORMS || GEA_CSS_FILTERS
|
|
34
|
+
const RareStyle &rs = rstyle(state.nodes[i].computedStyle());
|
|
35
|
+
#endif
|
|
36
|
+
#if GEA_CSS_TRANSFORMS
|
|
30
37
|
state.nodes[i].render.previous_transformable_box = ViewRenderer::isTransformableBox(state.nodes[i]);
|
|
31
38
|
if (captureTransforms) {
|
|
32
39
|
state.nodes[i].render.previous_rotate_angle = rs.rotate_angle;
|
|
@@ -60,12 +67,21 @@ void LayoutSnapshot::capture()
|
|
|
60
67
|
state.nodes[i].render.previous_perspective_origin_x = rs.perspective_origin_x;
|
|
61
68
|
state.nodes[i].render.previous_perspective_origin_y = rs.perspective_origin_y;
|
|
62
69
|
}
|
|
70
|
+
#endif
|
|
71
|
+
#if GEA_CSS_FILTERS
|
|
63
72
|
state.nodes[i].render.previous_filter_blur_radius = rs.filter_blur_radius;
|
|
73
|
+
#endif
|
|
64
74
|
state.nodes[i].render.dirty = 0;
|
|
65
75
|
state.nodes[i].render.layout_dirty = 0;
|
|
76
|
+
#if GEA_CSS_SCROLLING
|
|
66
77
|
state.nodes[i].render.scroll_dirty = 0;
|
|
78
|
+
#endif
|
|
79
|
+
#if GEA_CSS_SCROLLING
|
|
67
80
|
state.nodes[i].render.non_scroll_dirty = 0;
|
|
81
|
+
#endif
|
|
82
|
+
#if GEA_CSS_TRANSFORMS
|
|
68
83
|
state.nodes[i].render.transform_dirty = 0;
|
|
84
|
+
#endif
|
|
69
85
|
state.nodes[i].render.bg_recolor_pending = 0;
|
|
70
86
|
state.nodes[i].render.text_layout_stable = 0;
|
|
71
87
|
state.nodes[i].render.text_partial_dirty = 0;
|
|
@@ -74,9 +90,18 @@ void LayoutSnapshot::capture()
|
|
|
74
90
|
state.nodeCommandDirtyCanOverpaint[i] = 0;
|
|
75
91
|
if (state.nodes[i].type == NodeType::VirtualList) VirtualListRenderer::captureSnapshot(i);
|
|
76
92
|
}
|
|
93
|
+
#if GEA_CSS_SCROLLING
|
|
77
94
|
for (int i = 0; i < kScrollDirtyWordCount; i++)
|
|
78
95
|
state.scrollDirtyNodes[i] = 0;
|
|
79
96
|
state.scrollDirtyAny = false;
|
|
97
|
+
#endif
|
|
98
|
+
// Previous-frame transforms just changed. Geometry cached while collecting
|
|
99
|
+
// dirty bounds refers to the old snapshot; callers after capture must observe
|
|
100
|
+
// the new one, just as the uncached path does. The refresh serial is the
|
|
101
|
+
// geometry cache's authority for both current and previous transforms.
|
|
102
|
+
#if GEA_CSS_TRANSFORMS
|
|
103
|
+
if (captureTransforms && ++state.refreshSerial == 0) state.refreshSerial = 1;
|
|
104
|
+
#endif
|
|
80
105
|
}
|
|
81
106
|
|
|
82
107
|
void LayoutSnapshot::markChangesDirty()
|
|
@@ -90,7 +115,9 @@ void LayoutSnapshot::markChangesDirty()
|
|
|
90
115
|
n->layout.height != n->layout.previous_height) {
|
|
91
116
|
n->render.dirty = 1;
|
|
92
117
|
n->render.layout_dirty = 1;
|
|
118
|
+
#if GEA_CSS_SCROLLING
|
|
93
119
|
n->render.non_scroll_dirty = 1;
|
|
120
|
+
#endif
|
|
94
121
|
}
|
|
95
122
|
}
|
|
96
123
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
// Positive whole-program node reachability facts. Older or opaque builds
|
|
4
|
+
// retain every native node kind; applications do not opt into compact storage.
|
|
5
|
+
#ifndef GEA_UI_IMAGE_NODES
|
|
6
|
+
#define GEA_UI_IMAGE_NODES 1
|
|
7
|
+
#endif
|
|
8
|
+
#ifndef GEA_UI_INPUT_NODES
|
|
9
|
+
#define GEA_UI_INPUT_NODES 1
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
// Generated from the whole-source class-token bound. Unknown programs retain
|
|
13
|
+
// four inline entries. Overflow support is independent of this capacity.
|
|
14
|
+
#ifndef GEA_UI_CLASS_INLINE_TOKENS
|
|
15
|
+
#define GEA_UI_CLASS_INLINE_TOKENS 4
|
|
16
|
+
#endif
|
|
17
|
+
static_assert(GEA_UI_CLASS_INLINE_TOKENS >= 1 && GEA_UI_CLASS_INLINE_TOKENS <= 4,
|
|
18
|
+
"Class inline capacity must be between one and four tokens");
|
|
19
|
+
|
|
20
|
+
// A separate positive proof covers every class assignment and rules out opaque
|
|
21
|
+
// mutation. Older analyzers and unknown programs retain overflow support.
|
|
22
|
+
#ifndef GEA_UI_CLASS_OVERFLOW
|
|
23
|
+
#define GEA_UI_CLASS_OVERFLOW 1
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
// Closed whole-source auxiliary-state proof. Unknown/older programs keep all
|
|
27
|
+
// owners; callers cannot prune these through application manifest switches.
|
|
28
|
+
#ifndef GEA_UI_NODE_LISTENERS
|
|
29
|
+
#define GEA_UI_NODE_LISTENERS 1
|
|
30
|
+
#endif
|
|
31
|
+
#ifndef GEA_UI_NODE_ATTRIBUTES
|
|
32
|
+
#define GEA_UI_NODE_ATTRIBUTES 1
|
|
33
|
+
#endif
|
|
34
|
+
#ifndef GEA_UI_DEFAULT_STYLES
|
|
35
|
+
#define GEA_UI_DEFAULT_STYLES 1
|
|
36
|
+
#endif
|
package/ui/node_lifecycle.cpp
CHANGED
|
@@ -4,105 +4,361 @@
|
|
|
4
4
|
#include "pixel.h"
|
|
5
5
|
|
|
6
6
|
#include <cstring>
|
|
7
|
+
#include <cstdlib>
|
|
8
|
+
#include <new>
|
|
9
|
+
#include <utility>
|
|
10
|
+
#if defined(ESP_PLATFORM)
|
|
11
|
+
#include "esp_heap_caps.h"
|
|
12
|
+
#endif
|
|
7
13
|
|
|
8
14
|
namespace gea::embedded::ui {
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
namespace {
|
|
17
|
+
// One immutable default image. Resetting CSS must not construct/destroy a whole
|
|
18
|
+
// Node, touch its text ownership, or initialize layout/render state on the stack.
|
|
19
|
+
constexpr ComputedStyle makeDefaultStyle()
|
|
11
20
|
{
|
|
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
|
-
|
|
21
|
+
ComputedStyle style{};
|
|
22
|
+
style.display = kDisplayBlock;
|
|
23
|
+
#if GEA_CSS_DISPLAY_EXPLICIT
|
|
24
|
+
style.display_explicit = 0;
|
|
25
|
+
#endif
|
|
26
|
+
#if GEA_CSS_FLEX_DIRECTION
|
|
27
|
+
style.flex_direction = 0;
|
|
28
|
+
#endif
|
|
29
|
+
#if GEA_CSS_FLEX_DIRECTION
|
|
30
|
+
style.flex_direction_explicit = 0;
|
|
31
|
+
#endif
|
|
32
|
+
#if GEA_CSS_FLEX_WRAP
|
|
33
|
+
style.flex_wrap = 0;
|
|
34
|
+
#endif
|
|
35
|
+
#if GEA_CSS_JUSTIFY_CONTENT
|
|
36
|
+
style.justify_content = 0;
|
|
37
|
+
#endif
|
|
38
|
+
#if GEA_CSS_ALIGN_ITEMS
|
|
39
|
+
style.align_items = 0;
|
|
40
|
+
#endif
|
|
41
|
+
#if GEA_CSS_JUSTIFY_ITEMS
|
|
42
|
+
style.justify_items = 0;
|
|
43
|
+
#endif
|
|
44
|
+
#if GEA_CSS_ALIGN_CONTENT
|
|
45
|
+
style.align_content = 0;
|
|
46
|
+
#endif
|
|
47
|
+
#if GEA_CSS_ALIGN_SELF
|
|
48
|
+
style.align_self = -1;
|
|
49
|
+
#endif
|
|
50
|
+
#if GEA_CSS_GAP
|
|
51
|
+
style.gap = 0;
|
|
52
|
+
#endif
|
|
53
|
+
#if GEA_CSS_ORDER
|
|
54
|
+
style.order = 0;
|
|
55
|
+
#endif
|
|
56
|
+
#if GEA_CSS_BOX_SIZING
|
|
57
|
+
style.box_sizing = 0;
|
|
58
|
+
#endif
|
|
59
|
+
#if GEA_CSS_FLOATS
|
|
60
|
+
style.float_side = 0;
|
|
61
|
+
style.clear_side = 0;
|
|
62
|
+
#endif
|
|
63
|
+
#if GEA_CSS_WRITING_MODE
|
|
64
|
+
style.writing_mode = -1;
|
|
65
|
+
style.direction = -1;
|
|
66
|
+
#endif
|
|
67
|
+
#if GEA_CSS_MARGIN_AUTO
|
|
68
|
+
style.margin_auto = 0;
|
|
69
|
+
#endif
|
|
70
|
+
#if GEA_CSS_AXIS_GAP
|
|
71
|
+
style.row_gap = style.column_gap = kUnset;
|
|
72
|
+
#endif
|
|
73
|
+
#if GEA_CSS_PERCENT_GAP
|
|
74
|
+
style.row_gap_percent = style.column_gap_percent = kUnset;
|
|
75
|
+
#endif
|
|
41
76
|
// Grid tracks moved to RareStyle (default 0 for a node with no rare_style),
|
|
42
77
|
// so a fresh node needs no explicit reset here.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
#if GEA_CSS_WIDTH_EXPRESSIONS
|
|
79
|
+
style.width_expression = -1;
|
|
80
|
+
#endif
|
|
81
|
+
#if GEA_CSS_HEIGHT_EXPRESSIONS
|
|
82
|
+
style.height_expression = -1;
|
|
83
|
+
#endif
|
|
84
|
+
style.width = kUnset;
|
|
85
|
+
style.height = kUnset;
|
|
86
|
+
#if GEA_CSS_WIDTH_PERCENT
|
|
87
|
+
style.width_percent = kUnset;
|
|
88
|
+
#endif
|
|
89
|
+
#if GEA_CSS_HEIGHT_PERCENT
|
|
90
|
+
style.height_percent = kUnset;
|
|
91
|
+
#endif
|
|
92
|
+
#if GEA_CSS_MIN_WIDTH
|
|
93
|
+
style.min_width = kUnset;
|
|
94
|
+
#endif
|
|
95
|
+
#if GEA_CSS_MIN_HEIGHT
|
|
96
|
+
style.min_height = kUnset;
|
|
97
|
+
#endif
|
|
98
|
+
#if GEA_CSS_MAX_WIDTH
|
|
99
|
+
style.max_width = kUnset;
|
|
100
|
+
#endif
|
|
101
|
+
#if GEA_CSS_MAX_HEIGHT
|
|
102
|
+
style.max_height = kUnset;
|
|
103
|
+
#endif
|
|
104
|
+
#if GEA_CSS_FLEX_FACTORS
|
|
105
|
+
style.flex = 0;
|
|
106
|
+
#endif
|
|
107
|
+
#if GEA_CSS_FLEX_FACTORS
|
|
108
|
+
style.flex_shrink = 1;
|
|
109
|
+
#endif
|
|
110
|
+
#if GEA_CSS_FLEX_BASIS
|
|
111
|
+
style.flex_basis = kUnset;
|
|
112
|
+
#endif
|
|
55
113
|
for (int i = 0; i < 4; i++) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
114
|
+
#if GEA_CSS_PADDING
|
|
115
|
+
style.padding[i] = 0;
|
|
116
|
+
#endif
|
|
117
|
+
#if GEA_CSS_MARGINS
|
|
118
|
+
style.margin[i] = 0;
|
|
119
|
+
#endif
|
|
60
120
|
// per-side border width/color/alpha moved to RareStyle (defaults there).
|
|
61
|
-
|
|
62
|
-
|
|
121
|
+
style.border_radius[GEA_CSS_RADIUS_INDEX(i)] = 0;
|
|
122
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
123
|
+
style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] = kUnset;
|
|
124
|
+
#endif
|
|
63
125
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
126
|
+
#if GEA_CSS_POSITION_TOP
|
|
127
|
+
GEA_CSS_POSITION_PX_0(style) = kUnset;
|
|
128
|
+
#endif
|
|
129
|
+
#if GEA_CSS_POSITION_TOP_PERCENT
|
|
130
|
+
GEA_CSS_POSITION_PERCENT_0(style) = kUnset;
|
|
131
|
+
#endif
|
|
132
|
+
#if GEA_CSS_POSITION_RIGHT
|
|
133
|
+
GEA_CSS_POSITION_PX_1(style) = kUnset;
|
|
134
|
+
#endif
|
|
135
|
+
#if GEA_CSS_POSITION_RIGHT_PERCENT
|
|
136
|
+
GEA_CSS_POSITION_PERCENT_1(style) = kUnset;
|
|
137
|
+
#endif
|
|
138
|
+
#if GEA_CSS_POSITION_BOTTOM
|
|
139
|
+
GEA_CSS_POSITION_PX_2(style) = kUnset;
|
|
140
|
+
#endif
|
|
141
|
+
#if GEA_CSS_POSITION_BOTTOM_PERCENT
|
|
142
|
+
GEA_CSS_POSITION_PERCENT_2(style) = kUnset;
|
|
143
|
+
#endif
|
|
144
|
+
#if GEA_CSS_POSITION_LEFT
|
|
145
|
+
GEA_CSS_POSITION_PX_3(style) = kUnset;
|
|
146
|
+
#endif
|
|
147
|
+
#if GEA_CSS_POSITION_LEFT_PERCENT
|
|
148
|
+
GEA_CSS_POSITION_PERCENT_3(style) = kUnset;
|
|
149
|
+
#endif
|
|
150
|
+
style.position = 0;
|
|
151
|
+
#if GEA_CSS_Z_INDEX
|
|
152
|
+
style.z_index = 0;
|
|
153
|
+
style.z_index_auto = 1;
|
|
154
|
+
#endif
|
|
155
|
+
style.bg_color = 0;
|
|
156
|
+
style.has_bg = 0;
|
|
157
|
+
style.bg_alpha = 0;
|
|
158
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
159
|
+
style.bg_fill = 0;
|
|
160
|
+
#endif
|
|
71
161
|
// gradients + background-grid moved to RareStyle (defaults there).
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
162
|
+
#if GEA_CSS_ACTIVE_BACKGROUND
|
|
163
|
+
style.active_bg_color = 0;
|
|
164
|
+
#endif
|
|
165
|
+
#if GEA_CSS_ACTIVE_BACKGROUND
|
|
166
|
+
style.has_active_bg = 0;
|
|
167
|
+
#endif
|
|
168
|
+
style.text_color = gea::framework::graphics::pixel::nativeColor(255, 255, 255);
|
|
169
|
+
#if GEA_CSS_TEXT_ALPHA
|
|
170
|
+
style.text_alpha = 255;
|
|
171
|
+
#endif
|
|
172
|
+
#if GEA_CSS_OPACITY
|
|
173
|
+
style.opacity = 255;
|
|
174
|
+
#endif
|
|
175
|
+
#if GEA_CSS_BLINK
|
|
176
|
+
style.blink_interval_ms = 0;
|
|
177
|
+
style.blink_started_ms = 0;
|
|
178
|
+
style.blink_visible = 1;
|
|
179
|
+
#endif
|
|
180
|
+
#if GEA_CSS_BORDER_COLORS
|
|
181
|
+
style.border_color_flags = 0;
|
|
182
|
+
#endif
|
|
183
|
+
#if GEA_CSS_BORDER_WIDTHS
|
|
184
|
+
style.border_width = 0;
|
|
185
|
+
#endif
|
|
186
|
+
#if GEA_CSS_BORDER_COLORS
|
|
187
|
+
style.border_color = gea::framework::graphics::pixel::nativeColor(255, 255, 255);
|
|
188
|
+
#endif
|
|
189
|
+
#if GEA_CSS_BORDER_ALPHA
|
|
190
|
+
style.border_alpha = 255;
|
|
191
|
+
#endif
|
|
83
192
|
// transform / perspective / filter / box-shadow moved to RareStyle; a fresh
|
|
84
193
|
// node (rare_style = -1) reads their correct defaults from the zero entry.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
194
|
+
style.font_id = -1;
|
|
195
|
+
style.font_size = 0;
|
|
196
|
+
#if GEA_CSS_FONT_WEIGHT
|
|
197
|
+
style.font_weight = 400;
|
|
198
|
+
#endif
|
|
199
|
+
#if GEA_CSS_LINE_HEIGHT
|
|
200
|
+
style.line_height = 0;
|
|
201
|
+
#endif
|
|
202
|
+
#if GEA_CSS_LINE_HEIGHT_MULTIPLIER
|
|
203
|
+
style.line_height_multiplier = -1;
|
|
204
|
+
#endif
|
|
205
|
+
#if GEA_CSS_TEXT_ALIGN
|
|
206
|
+
style.text_align = 0;
|
|
207
|
+
#endif
|
|
208
|
+
#if GEA_CSS_TEXT_DECORATION
|
|
209
|
+
style.text_decoration = 0;
|
|
210
|
+
#endif
|
|
211
|
+
#if GEA_CSS_TEXT_TRANSFORM
|
|
212
|
+
style.text_transform = 0;
|
|
213
|
+
#endif
|
|
214
|
+
#if GEA_CSS_WHITE_SPACE
|
|
215
|
+
style.white_space = 0;
|
|
216
|
+
#endif
|
|
217
|
+
#if GEA_CSS_TEXT_OVERFLOW
|
|
218
|
+
style.text_overflow = 0;
|
|
219
|
+
#endif
|
|
220
|
+
style.overflow = 0;
|
|
221
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
222
|
+
style.overflow_x = 0;
|
|
223
|
+
#endif
|
|
224
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
225
|
+
style.overflow_y = 0;
|
|
226
|
+
#endif
|
|
227
|
+
#if GEA_CSS_MASK
|
|
228
|
+
style.mask_right_fade_width = 0;
|
|
229
|
+
#endif
|
|
230
|
+
#if GEA_CSS_IMAGE_FIT
|
|
231
|
+
style.image_fit = 0;
|
|
232
|
+
#endif
|
|
233
|
+
#if GEA_CSS_TRANSFORMS
|
|
234
|
+
style.backface_hidden = 0;
|
|
235
|
+
#endif
|
|
236
|
+
#if GEA_CSS_VISIBILITY
|
|
237
|
+
style.visibility = 0;
|
|
238
|
+
#endif
|
|
239
|
+
#if GEA_CSS_POINTER_EVENTS
|
|
240
|
+
style.pointer_events = 0;
|
|
241
|
+
#endif
|
|
242
|
+
return style;
|
|
243
|
+
}
|
|
244
|
+
constexpr ComputedStyle kDefaultStyle = makeDefaultStyle();
|
|
245
|
+
} // namespace
|
|
246
|
+
|
|
247
|
+
void NodeLifecycle::resetStyle(ComputedStyle &style)
|
|
248
|
+
{
|
|
249
|
+
// Member assignment preserves adjacent state when Node reuses tail padding.
|
|
250
|
+
style = kDefaultStyle;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#if GEA_EMBEDDED_SHARED_STYLES
|
|
254
|
+
namespace {
|
|
255
|
+
SharedStyleRecord *g_sharedStyleHead = nullptr;
|
|
256
|
+
std::size_t g_sharedStyleRecords = 0;
|
|
257
|
+
SharedStyleRecord &defaultStyleRecord()
|
|
258
|
+
{
|
|
259
|
+
static SharedStyleRecord record{kDefaultStyle, 0, nullptr};
|
|
260
|
+
return record;
|
|
261
|
+
}
|
|
262
|
+
void retainStyle(SharedStyleRecord *record)
|
|
263
|
+
{
|
|
264
|
+
if (record != &defaultStyleRecord()) ++record->references;
|
|
265
|
+
}
|
|
266
|
+
void releaseStyle(SharedStyleRecord *record)
|
|
267
|
+
{
|
|
268
|
+
if (record == &defaultStyleRecord() || --record->references != 0) return;
|
|
269
|
+
// Reclamation is cold; keep no backward link in every style record.
|
|
270
|
+
// The per-frame read/write path still uses the same direct record pointer.
|
|
271
|
+
auto **link = &g_sharedStyleHead;
|
|
272
|
+
while (*link && *link != record) link = &(*link)->next;
|
|
273
|
+
if (!*link) std::abort();
|
|
274
|
+
*link = record->next;
|
|
275
|
+
record->~SharedStyleRecord();
|
|
276
|
+
#if defined(ESP_PLATFORM)
|
|
277
|
+
heap_caps_free(record);
|
|
278
|
+
#else
|
|
279
|
+
std::free(record);
|
|
280
|
+
#endif
|
|
281
|
+
--g_sharedStyleRecords;
|
|
282
|
+
}
|
|
283
|
+
SharedStyleRecord *copyStyle(const ComputedStyle &value)
|
|
284
|
+
{
|
|
285
|
+
#if defined(ESP_PLATFORM)
|
|
286
|
+
void *storage = heap_caps_malloc(sizeof(SharedStyleRecord), MALLOC_CAP_SPIRAM);
|
|
287
|
+
#else
|
|
288
|
+
void *storage = std::malloc(sizeof(SharedStyleRecord));
|
|
289
|
+
#endif
|
|
290
|
+
if (!storage) std::abort();
|
|
291
|
+
auto *record = new (storage) SharedStyleRecord{value, 1, g_sharedStyleHead};
|
|
292
|
+
g_sharedStyleHead = record;
|
|
293
|
+
++g_sharedStyleRecords;
|
|
294
|
+
return record;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
NodeStyleStorage::NodeStyleStorage() : record_(&defaultStyleRecord()) {}
|
|
298
|
+
NodeStyleStorage::~NodeStyleStorage() { releaseStyle(record_); }
|
|
299
|
+
NodeStyleStorage::NodeStyleStorage(const NodeStyleStorage &other) : record_(other.record_) { retainStyle(record_); }
|
|
300
|
+
NodeStyleStorage &NodeStyleStorage::operator=(const NodeStyleStorage &other)
|
|
301
|
+
{
|
|
302
|
+
if (this != &other) { retainStyle(other.record_); releaseStyle(record_); record_ = other.record_; }
|
|
303
|
+
return *this;
|
|
304
|
+
}
|
|
305
|
+
NodeStyleStorage::NodeStyleStorage(NodeStyleStorage &&other) noexcept
|
|
306
|
+
: record_(std::exchange(other.record_, &defaultStyleRecord())) {}
|
|
307
|
+
NodeStyleStorage &NodeStyleStorage::operator=(NodeStyleStorage &&other) noexcept
|
|
308
|
+
{
|
|
309
|
+
if (this != &other) { releaseStyle(record_); record_ = std::exchange(other.record_, &defaultStyleRecord()); }
|
|
310
|
+
return *this;
|
|
311
|
+
}
|
|
312
|
+
ComputedStyle &NodeStyleStorage::detach()
|
|
313
|
+
{
|
|
314
|
+
auto *copy = copyStyle(record_->value);
|
|
315
|
+
releaseStyle(record_);
|
|
316
|
+
record_ = copy;
|
|
317
|
+
return record_->value;
|
|
318
|
+
}
|
|
319
|
+
void NodeStyleStorage::reset() { releaseStyle(record_); record_ = &defaultStyleRecord(); }
|
|
320
|
+
void NodeStyleStorage::intern()
|
|
321
|
+
{
|
|
322
|
+
if (record_ == &defaultStyleRecord() || record_->value.rare_style >= 0) return;
|
|
323
|
+
// Called at the end of CSS recomputation, never in the per-frame read path.
|
|
324
|
+
for (auto *other = g_sharedStyleHead; other; other = other->next) {
|
|
325
|
+
if (other == record_ || !(other->value == record_->value)) continue;
|
|
326
|
+
retainStyle(other);
|
|
327
|
+
releaseStyle(record_);
|
|
328
|
+
record_ = other;
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
std::size_t NodeStyleStorage::allocatedBytes() { return g_sharedStyleRecords * sizeof(SharedStyleRecord); }
|
|
333
|
+
std::size_t NodeStyleStorage::allocatedRecords() { return g_sharedStyleRecords; }
|
|
334
|
+
std::size_t NodeStyleStorage::allocatedHeapBytes()
|
|
335
|
+
{
|
|
336
|
+
#if defined(ESP_PLATFORM)
|
|
337
|
+
std::size_t bytes = 0;
|
|
338
|
+
for (auto *record = g_sharedStyleHead; record; record = record->next)
|
|
339
|
+
bytes += heap_caps_get_allocated_size(record);
|
|
340
|
+
return bytes;
|
|
341
|
+
#else
|
|
342
|
+
return allocatedBytes();
|
|
343
|
+
#endif
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
#else
|
|
347
|
+
void Node::resetComputedStyle() { NodeLifecycle::resetStyle(style); }
|
|
348
|
+
#endif
|
|
349
|
+
|
|
350
|
+
void NodeLifecycle::init(Node *n, NodeType type)
|
|
351
|
+
{
|
|
352
|
+
n->type = type;
|
|
353
|
+
#if GEA_EMBEDDED_SHARED_STYLES && !GEA_CSS_CUSTOM_PROPERTIES
|
|
354
|
+
n->class_style_tracked = false;
|
|
355
|
+
#endif
|
|
356
|
+
n->resetComputedStyle();
|
|
99
357
|
n->text.clear();
|
|
358
|
+
#if GEA_UI_IMAGE_NODES
|
|
100
359
|
n->image_id = -1;
|
|
360
|
+
#endif
|
|
101
361
|
n->tag_id = 0; // 0 = empty tag (interned tag table index 0)
|
|
102
|
-
n->style.image_fit = 0;
|
|
103
|
-
n->style.backface_hidden = 0;
|
|
104
|
-
n->style.visibility = 0;
|
|
105
|
-
n->style.pointer_events = 0;
|
|
106
362
|
n->parent = -1;
|
|
107
363
|
n->first_child = -1;
|
|
108
364
|
n->last_child = -1;
|
|
@@ -113,16 +369,25 @@ void NodeLifecycle::init(Node *n, NodeType type)
|
|
|
113
369
|
n->layout.width = 0;
|
|
114
370
|
n->layout.height = 0;
|
|
115
371
|
n->layout.inline_indent = 0;
|
|
372
|
+
#if !GEA_EMBEDDED_SHARED_STYLES
|
|
373
|
+
n->layout.memo_avail_w = n->layout.memo_avail_h = 0;
|
|
374
|
+
n->layout.memo_pass = 0;
|
|
375
|
+
#endif
|
|
376
|
+
#if GEA_CSS_SCROLLING
|
|
116
377
|
n->layout.scroll_x = 0;
|
|
117
378
|
n->layout.scroll_y = 0;
|
|
118
379
|
n->layout.scroll_content_width = 0;
|
|
119
380
|
n->layout.scroll_content_height = 0;
|
|
381
|
+
#endif
|
|
120
382
|
n->layout.previous_x = 0;
|
|
121
383
|
n->layout.previous_y = 0;
|
|
122
384
|
n->layout.previous_width = 0;
|
|
123
385
|
n->layout.previous_height = 0;
|
|
386
|
+
#if GEA_CSS_SCROLLING
|
|
124
387
|
n->layout.previous_scroll_x = 0;
|
|
125
388
|
n->layout.previous_scroll_y = 0;
|
|
389
|
+
#endif
|
|
390
|
+
#if GEA_CSS_TRANSFORMS
|
|
126
391
|
n->render.previous_rotate_angle = 0;
|
|
127
392
|
n->render.previous_rotate_axis_x = 0;
|
|
128
393
|
n->render.previous_rotate_axis_y = 0;
|
|
@@ -150,12 +415,21 @@ void NodeLifecycle::init(Node *n, NodeType type)
|
|
|
150
415
|
n->render.previous_perspective_origin_x = 500;
|
|
151
416
|
n->render.previous_perspective_origin_y = 500;
|
|
152
417
|
n->render.previous_transformable_box = 0;
|
|
418
|
+
#endif
|
|
419
|
+
#if GEA_CSS_FILTERS
|
|
153
420
|
n->render.previous_filter_blur_radius = 0;
|
|
421
|
+
#endif
|
|
154
422
|
n->render.inline_baseline = 0;
|
|
155
423
|
n->render.dirty = 0;
|
|
424
|
+
#if GEA_CSS_SCROLLING
|
|
156
425
|
n->render.scroll_dirty = 0;
|
|
426
|
+
#endif
|
|
427
|
+
#if GEA_CSS_SCROLLING
|
|
157
428
|
n->render.non_scroll_dirty = 0;
|
|
429
|
+
#endif
|
|
430
|
+
#if GEA_CSS_TRANSFORMS
|
|
158
431
|
n->render.transform_dirty = 0;
|
|
432
|
+
#endif
|
|
159
433
|
n->render.text_layout_stable = 0;
|
|
160
434
|
}
|
|
161
435
|
|