@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Generated from the app's source/style analysis by the build driver. These
|
|
5
|
+
// describe reachable instructions, not app configuration switches. Builds made
|
|
6
|
+
// without an analyzer retain the complete renderer. Cache sizing only matters
|
|
7
|
+
// inside a feature's enabled branch; the disabled branches use no cache storage.
|
|
8
|
+
#ifndef GEA_EMBEDDED_RENDERER_CIRCLES
|
|
9
|
+
#define GEA_EMBEDDED_RENDERER_CIRCLES 1
|
|
10
|
+
#endif
|
|
11
|
+
#ifndef GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
12
|
+
#define GEA_EMBEDDED_RENDERER_TRANSFORMS 1
|
|
13
|
+
#endif
|
|
14
|
+
#ifndef GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
15
|
+
#define GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS 1
|
|
16
|
+
#endif
|
|
17
|
+
#ifndef GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
18
|
+
#define GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS 1
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Independent proof: old analyzers cannot certify triangle batches absent.
|
|
22
|
+
#ifndef GEA_EMBEDDED_RENDERER_TRIANGLE_OCCLUSION
|
|
23
|
+
#define GEA_EMBEDDED_RENDERER_TRIANGLE_OCCLUSION 1
|
|
24
|
+
#endif
|
|
@@ -29,34 +29,35 @@
|
|
|
29
29
|
|
|
30
30
|
namespace gea::embedded::ui {
|
|
31
31
|
|
|
32
|
+
#if GEA_CSS_SCROLLING
|
|
32
33
|
namespace {
|
|
33
34
|
|
|
34
35
|
bool hasTransformState(const Node &node)
|
|
35
36
|
{
|
|
36
|
-
return hasIndividualLinearTransform(rstyle(node.
|
|
37
|
-
rstyle(node.
|
|
37
|
+
return hasIndividualLinearTransform(rstyle(node.computedStyle())) || hadIndividualLinearTransform(node.render) ||
|
|
38
|
+
rstyle(node.computedStyle()).transform_rotate != 0 ||
|
|
38
39
|
node.render.previous_transform_rotate != 0 ||
|
|
39
|
-
rstyle(node.
|
|
40
|
+
rstyle(node.computedStyle()).transform_rotate_x != 0 ||
|
|
40
41
|
node.render.previous_transform_rotate_x != 0 ||
|
|
41
|
-
rstyle(node.
|
|
42
|
+
rstyle(node.computedStyle()).transform_rotate_y != 0 ||
|
|
42
43
|
node.render.previous_transform_rotate_y != 0 ||
|
|
43
|
-
composedTranslateX(rstyle(node.
|
|
44
|
+
composedTranslateX(rstyle(node.computedStyle())) != 0 ||
|
|
44
45
|
node.render.previous_transform_translate_x != 0 ||
|
|
45
|
-
composedTranslateY(rstyle(node.
|
|
46
|
+
composedTranslateY(rstyle(node.computedStyle())) != 0 ||
|
|
46
47
|
node.render.previous_transform_translate_y != 0 ||
|
|
47
|
-
composedTranslateZ(rstyle(node.
|
|
48
|
+
composedTranslateZ(rstyle(node.computedStyle())) != 0 ||
|
|
48
49
|
node.render.previous_transform_translate_z != 0 ||
|
|
49
|
-
composedTranslateXPercent(rstyle(node.
|
|
50
|
+
composedTranslateXPercent(rstyle(node.computedStyle())) != 0 ||
|
|
50
51
|
node.render.previous_transform_translate_x_percent != 0 ||
|
|
51
|
-
composedTranslateYPercent(rstyle(node.
|
|
52
|
+
composedTranslateYPercent(rstyle(node.computedStyle())) != 0 ||
|
|
52
53
|
node.render.previous_transform_translate_y_percent != 0 ||
|
|
53
|
-
rstyle(node.
|
|
54
|
+
rstyle(node.computedStyle()).transform_scale_x != 1000 ||
|
|
54
55
|
node.render.previous_transform_scale_x != 1000 ||
|
|
55
|
-
rstyle(node.
|
|
56
|
-
rstyle(node.
|
|
56
|
+
rstyle(node.computedStyle()).transform_scale_y != 1000 ||
|
|
57
|
+
rstyle(node.computedStyle()).transform_scale_z != 1000 ||
|
|
57
58
|
node.render.previous_transform_scale_y != 1000 ||
|
|
58
59
|
node.render.previous_transform_scale_z != 1000 ||
|
|
59
|
-
rstyle(node.
|
|
60
|
+
rstyle(node.computedStyle()).perspective > 0 ||
|
|
60
61
|
node.render.previous_perspective > 0;
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -82,7 +83,7 @@ bool isDescendantOf(const TreeState &state, int node, int ancestor)
|
|
|
82
83
|
bool hasRightFadeMask(const TreeState &state, int node)
|
|
83
84
|
{
|
|
84
85
|
for (int cursor = node; cursor >= 0; cursor = state.nodes[cursor].parent) {
|
|
85
|
-
if (state.nodes[cursor].
|
|
86
|
+
if (state.nodes[cursor].computedStyle().mask_right_fade_width > 0) return true;
|
|
86
87
|
}
|
|
87
88
|
return false;
|
|
88
89
|
}
|
|
@@ -102,13 +103,13 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
|
|
|
102
103
|
if (state.nodes[scrollNode].type != NodeType::VirtualList) return false;
|
|
103
104
|
// The list is the slot's containing block only when it is itself positioned
|
|
104
105
|
// (matches containingBlockForAbsoluteNode in the layout engine).
|
|
105
|
-
const auto parentPosition = state.nodes[scrollNode].
|
|
106
|
+
const auto parentPosition = state.nodes[scrollNode].computedStyle().position;
|
|
106
107
|
if (parentPosition != 1 && parentPosition != 2) return false;
|
|
107
|
-
if (n.
|
|
108
|
+
if (n.computedStyle().position != 1) return false;
|
|
108
109
|
// Anchored via top/bottom (the windowed axis); refresh() recomputes y from
|
|
109
110
|
// these offsets directly.
|
|
110
|
-
if (n.
|
|
111
|
-
n.
|
|
111
|
+
if (GEA_CSS_POSITION_PX_0(n.computedStyle()) == kUnset && GEA_CSS_POSITION_PERCENT_0(n.computedStyle()) == kUnset &&
|
|
112
|
+
GEA_CSS_POSITION_PX_2(n.computedStyle()) == kUnset && GEA_CSS_POSITION_PERCENT_2(n.computedStyle()) == kUnset)
|
|
112
113
|
return false;
|
|
113
114
|
if (hasTransformState(n)) return false;
|
|
114
115
|
// The reconcile translates the slot box; a pending size change needs layout.
|
|
@@ -117,10 +118,11 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
|
|
|
117
118
|
return true;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
template <int side>
|
|
122
|
+
int resolvedSlotOffset(const Node &slot, int basis)
|
|
121
123
|
{
|
|
122
|
-
int offset = slot.
|
|
123
|
-
const int percent = slot.
|
|
124
|
+
int offset = GEA_CSS_POSITION_PX(slot.computedStyle(), side) != kUnset ? GEA_CSS_POSITION_PX(slot.computedStyle(), side) : 0;
|
|
125
|
+
const int percent = GEA_CSS_POSITION_PERCENT(slot.computedStyle(), side);
|
|
124
126
|
if (percent != kUnset) {
|
|
125
127
|
const int numerator = basis * percent;
|
|
126
128
|
offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
|
|
@@ -166,12 +168,12 @@ bool nonVirtualListScrollbarThumbBounds(const Node &n, int scrollTop, int *thumb
|
|
|
166
168
|
// inline formatting), and stacks them as a column otherwise.
|
|
167
169
|
bool flowsChildrenAsRow(const TreeState &state, const Node &p)
|
|
168
170
|
{
|
|
169
|
-
if (usesRowLayout(p.
|
|
170
|
-
if (p.
|
|
171
|
+
if (usesRowLayout(p.computedStyle())) return true;
|
|
172
|
+
if (p.computedStyle().flex_direction_explicit || p.computedStyle().display != kDisplayBlock) return false;
|
|
171
173
|
bool anyInFlow = false;
|
|
172
174
|
for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
|
|
173
175
|
const Node &child = state.nodes[c];
|
|
174
|
-
if (child.
|
|
176
|
+
if (child.computedStyle().display == kDisplayNone || isOutOfFlowPosition(child.computedStyle().position)) continue;
|
|
175
177
|
if (!LayoutEngine::isInlineLevelNode(child)) return false;
|
|
176
178
|
anyInFlow = true;
|
|
177
179
|
}
|
|
@@ -194,20 +196,20 @@ void shiftSiblingsForRemeasuredText(TreeState &state, int id, int oldWidth, int
|
|
|
194
196
|
{
|
|
195
197
|
const Node &n = state.nodes[id];
|
|
196
198
|
const Node &p = state.nodes[n.parent];
|
|
197
|
-
if (p.
|
|
199
|
+
if (p.computedStyle().flex_wrap || p.computedStyle().justify_content != 0) return;
|
|
198
200
|
const bool row = flowsChildrenAsRow(state, p);
|
|
199
201
|
const int delta = row ? n.layout.width - oldWidth : n.layout.height - oldHeight;
|
|
200
202
|
if (delta == 0) return;
|
|
201
203
|
int totalFlex = 0;
|
|
202
204
|
for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
|
|
203
205
|
const Node &child = state.nodes[c];
|
|
204
|
-
if (child.
|
|
205
|
-
totalFlex += child.
|
|
206
|
+
if (child.computedStyle().display == kDisplayNone || isOutOfFlowPosition(child.computedStyle().position)) continue;
|
|
207
|
+
totalFlex += child.computedStyle().flex;
|
|
206
208
|
}
|
|
207
209
|
if (totalFlex > 0) return;
|
|
208
210
|
for (int c = n.next_sibling; c >= 0; c = state.nodes[c].next_sibling) {
|
|
209
211
|
Node &sib = state.nodes[c];
|
|
210
|
-
if (sib.
|
|
212
|
+
if (sib.computedStyle().display == kDisplayNone || isOutOfFlowPosition(sib.computedStyle().position)) continue;
|
|
211
213
|
if (row) sib.layout.x += delta;
|
|
212
214
|
else sib.layout.y += delta;
|
|
213
215
|
translateSlotDescendants(state, c, row ? delta : 0, row ? 0 : delta);
|
|
@@ -249,15 +251,15 @@ void remeasureDirtyTextInPlace(TreeState &state, int id, bool siblingsCoveredByR
|
|
|
249
251
|
// shift the following stacked siblings by any height delta. Hugged
|
|
250
252
|
// (non-stretch / explicit-width) boxes re-measure naturally and keep
|
|
251
253
|
// their left anchor — the cross axis never right-flushes by default.
|
|
252
|
-
const int align = n.
|
|
253
|
-
const bool stretched = align == 0 && n.
|
|
254
|
+
const int align = n.computedStyle().align_self >= 0 ? n.computedStyle().align_self : p.computedStyle().align_items;
|
|
255
|
+
const bool stretched = align == 0 && n.computedStyle().width == kUnset && n.computedStyle().width_percent == kUnset;
|
|
254
256
|
if (!TextRenderer::remeasureContentBox(id, stretched)) return;
|
|
255
257
|
if (siblingsCoveredByReplay) shiftSiblingsForRemeasuredText(state, id, oldWidth, oldHeight);
|
|
256
258
|
return;
|
|
257
259
|
}
|
|
258
260
|
if (!TextRenderer::remeasureContentBox(id)) return;
|
|
259
|
-
const int oldRight = n.layout.x + oldWidth + n.
|
|
260
|
-
const int parentRight = p.layout.x + p.layout.width - p.
|
|
261
|
+
const int oldRight = n.layout.x + oldWidth + n.computedStyle().margin[1];
|
|
262
|
+
const int parentRight = p.layout.x + p.layout.width - p.computedStyle().padding[1];
|
|
261
263
|
if (oldRight == parentRight) {
|
|
262
264
|
n.layout.x += oldWidth - n.layout.width;
|
|
263
265
|
return;
|
|
@@ -317,23 +319,26 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
317
319
|
|
|
318
320
|
if (n->render.scroll_dirty && !n->render.non_scroll_dirty) {
|
|
319
321
|
if (foundNode >= 0) return -1;
|
|
320
|
-
if (!isViewLikeNodeType(n->type) || n->
|
|
322
|
+
if (!isViewLikeNodeType(n->type) || n->computedStyle().display == 1) return -1;
|
|
321
323
|
// Accept a pure scroll on exactly one axis the node overflows. The
|
|
322
324
|
// horizontal case mirrors the vertical fast path (see refresh()): a
|
|
323
325
|
// virtual-list is vertical-only. Rejecting a both-axes change keeps the
|
|
324
326
|
// single-axis scrollRect blit unambiguous.
|
|
325
327
|
const bool changedY = n->layout.scroll_y != n->layout.previous_scroll_y;
|
|
326
328
|
const bool changedX = n->layout.scroll_x != n->layout.previous_scroll_x;
|
|
327
|
-
const bool canScrollYAxis = n->type == NodeType::VirtualList || scrollsOverflowY(n->
|
|
328
|
-
const bool canScrollXAxis = n->type != NodeType::VirtualList && scrollsOverflowX(n->
|
|
329
|
+
const bool canScrollYAxis = n->type == NodeType::VirtualList || scrollsOverflowY(n->computedStyle());
|
|
330
|
+
const bool canScrollXAxis = n->type != NodeType::VirtualList && scrollsOverflowX(n->computedStyle());
|
|
329
331
|
const bool vertical = changedY && !changedX && canScrollYAxis;
|
|
330
332
|
const bool horizontal = changedX && !changedY && canScrollXAxis;
|
|
331
333
|
if (!vertical && !horizontal) return -1;
|
|
332
334
|
if (!layoutUnchanged(*n)) return -1;
|
|
333
335
|
if (hasTransformState(*n)) return -1;
|
|
334
|
-
if (n->
|
|
336
|
+
if (n->computedStyle().opacity != 255 || hasAnyBorder(n->computedStyle())) return -1;
|
|
335
337
|
for (int r = 0; r < 4; r++) {
|
|
336
|
-
if (n->
|
|
338
|
+
if (n->computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return -1;
|
|
339
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
340
|
+
if (n->computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return -1;
|
|
341
|
+
#endif
|
|
337
342
|
}
|
|
338
343
|
foundNode = i;
|
|
339
344
|
continue;
|
|
@@ -359,7 +364,7 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
359
364
|
for (int i = 0; i < state.nodeCount; i++) {
|
|
360
365
|
if (i == foundNode) continue;
|
|
361
366
|
const Node &o = state.nodes[i];
|
|
362
|
-
if (o.
|
|
367
|
+
if (o.computedStyle().display == 1 || o.computedStyle().opacity == 0) continue;
|
|
363
368
|
if (o.layout.width <= 0 || o.layout.height <= 0) continue;
|
|
364
369
|
// Skip the scroll node's own subtree and its ancestor chain — and any
|
|
365
370
|
// node inside a display:none subtree: a hidden ancestor removes the
|
|
@@ -371,7 +376,7 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
371
376
|
bool hidden = false;
|
|
372
377
|
for (int a = i; a >= 0; a = state.nodes[a].parent) {
|
|
373
378
|
if (a == foundNode) { related = true; break; }
|
|
374
|
-
if (state.nodes[a].
|
|
379
|
+
if (state.nodes[a].computedStyle().display == 1) { hidden = true; break; }
|
|
375
380
|
}
|
|
376
381
|
if (related || hidden) continue;
|
|
377
382
|
for (int a = foundNode; a >= 0; a = state.nodes[a].parent) {
|
|
@@ -437,8 +442,8 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
437
442
|
// Consult the pending flag, not just the two laid-out boxes; the sibling
|
|
438
443
|
// fast path already screens on exactly this pair (`absolute_leaf_refresh.cpp`).
|
|
439
444
|
if (n->render.layout_dirty &&
|
|
440
|
-
((n->
|
|
441
|
-
(n->
|
|
445
|
+
((n->computedStyle().height != kUnset && n->computedStyle().height != n->layout.height) ||
|
|
446
|
+
(n->computedStyle().width != kUnset && n->computedStyle().width != n->layout.width))) {
|
|
442
447
|
return -1;
|
|
443
448
|
}
|
|
444
449
|
if (!layoutUnchanged(*n)) {
|
|
@@ -484,20 +489,20 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
484
489
|
{
|
|
485
490
|
auto &state = treeState();
|
|
486
491
|
auto &perf = refreshPerfStatsMutable();
|
|
487
|
-
perf.rootScrollCalls
|
|
492
|
+
GEA_REFRESH_PERF(perf.rootScrollCalls++);
|
|
488
493
|
DirtyNode extraDirtyNodes[kMaxExtraDirtyNodes];
|
|
489
494
|
int extraDirtyCount = 0;
|
|
490
495
|
int slotNodes[kMaxSlotRepositionNodes];
|
|
491
496
|
int slotCount = 0;
|
|
492
497
|
const std::int64_t scanStartUs = refreshPerfNowUs();
|
|
493
498
|
int scroll_node = refreshNode(root, extraDirtyNodes, &extraDirtyCount, slotNodes, &slotCount, width, height);
|
|
494
|
-
perf.rootScrollScanUs += refreshPerfNowUs() - scanStartUs;
|
|
499
|
+
GEA_REFRESH_PERF(perf.rootScrollScanUs += refreshPerfNowUs() - scanStartUs);
|
|
495
500
|
if (scroll_node < 0) {
|
|
496
|
-
perf.rootScrollRejected
|
|
501
|
+
GEA_REFRESH_PERF(perf.rootScrollRejected++);
|
|
497
502
|
return 0;
|
|
498
503
|
}
|
|
499
|
-
perf.rootScrollAccepted
|
|
500
|
-
perf.rootScrollExtraDirtyNodes += extraDirtyCount;
|
|
504
|
+
GEA_REFRESH_PERF(perf.rootScrollAccepted++);
|
|
505
|
+
GEA_REFRESH_PERF(perf.rootScrollExtraDirtyNodes += extraDirtyCount);
|
|
501
506
|
|
|
502
507
|
Node *n = &state.nodes[scroll_node];
|
|
503
508
|
// refreshNode accepted a pure single-axis scroll; derive which axis moved.
|
|
@@ -534,21 +539,21 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
534
539
|
damage.oldX1 = slot.layout.x + slot.layout.width - 1;
|
|
535
540
|
damage.oldY1 = slot.layout.y + slot.layout.height - 1;
|
|
536
541
|
damage.moved = false;
|
|
537
|
-
if (slot.
|
|
542
|
+
if (slot.computedStyle().display == 1) continue; // display:none — erase old rect only
|
|
538
543
|
|
|
539
544
|
int newX = slot.layout.x;
|
|
540
|
-
if (slot.
|
|
541
|
-
newX = n->layout.x + resolvedSlotOffset(slot,
|
|
542
|
-
else if (slot.
|
|
545
|
+
if (GEA_CSS_POSITION_PX_3(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_3(slot.computedStyle()) != kUnset)
|
|
546
|
+
newX = n->layout.x + resolvedSlotOffset<3>(slot, n->layout.width);
|
|
547
|
+
else if (GEA_CSS_POSITION_PX_1(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_1(slot.computedStyle()) != kUnset)
|
|
543
548
|
newX = n->layout.x + n->layout.width - slot.layout.width -
|
|
544
|
-
resolvedSlotOffset(slot,
|
|
549
|
+
resolvedSlotOffset<1>(slot, n->layout.width);
|
|
545
550
|
|
|
546
551
|
int newY = slot.layout.y;
|
|
547
|
-
if (slot.
|
|
548
|
-
newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset(slot,
|
|
549
|
-
else if (slot.
|
|
552
|
+
if (GEA_CSS_POSITION_PX_0(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_0(slot.computedStyle()) != kUnset)
|
|
553
|
+
newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset<0>(slot, n->layout.height);
|
|
554
|
+
else if (GEA_CSS_POSITION_PX_2(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_2(slot.computedStyle()) != kUnset)
|
|
550
555
|
newY = n->layout.y - n->layout.scroll_y + n->layout.height - slot.layout.height -
|
|
551
|
-
resolvedSlotOffset(slot,
|
|
556
|
+
resolvedSlotOffset<2>(slot, n->layout.height);
|
|
552
557
|
|
|
553
558
|
const int dx = newX - slot.layout.x;
|
|
554
559
|
const int dy = newY - slot.layout.y;
|
|
@@ -569,7 +574,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
569
574
|
if (!ViewportRegion::clipRect(width, height, &vx, &vy, &vw, &vh)) {
|
|
570
575
|
const std::int64_t snapshotStartUs = refreshPerfNowUs();
|
|
571
576
|
LayoutSnapshot::capture();
|
|
572
|
-
perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs;
|
|
577
|
+
GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
|
|
573
578
|
return 1;
|
|
574
579
|
}
|
|
575
580
|
|
|
@@ -672,12 +677,12 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
672
677
|
state.displayListDirty = false;
|
|
673
678
|
coverageRoot = -1;
|
|
674
679
|
}
|
|
675
|
-
perf.rootScrollRebuildUs += refreshPerfNowUs() - rebuildStartUs;
|
|
680
|
+
GEA_REFRESH_PERF(perf.rootScrollRebuildUs += refreshPerfNowUs() - rebuildStartUs);
|
|
676
681
|
}
|
|
677
|
-
perf.rootScrollMovePx += abs_move;
|
|
678
|
-
perf.rootScrollViewportPx += vw * vh;
|
|
679
|
-
perf.rootScrollStripPx += horizontal ? (vh * (abs_move < vw ? abs_move : vw))
|
|
680
|
-
: (vw * (abs_move < vh ? abs_move : vh));
|
|
682
|
+
GEA_REFRESH_PERF(perf.rootScrollMovePx += abs_move);
|
|
683
|
+
GEA_REFRESH_PERF(perf.rootScrollViewportPx += vw * vh);
|
|
684
|
+
GEA_REFRESH_PERF(perf.rootScrollStripPx += horizontal ? (vh * (abs_move < vw ? abs_move : vw))
|
|
685
|
+
: (vw * (abs_move < vh ? abs_move : vh)));
|
|
681
686
|
|
|
682
687
|
gea::platform::display::Display::resetClip();
|
|
683
688
|
gea::platform::display::Display::setAlpha(255);
|
|
@@ -721,7 +726,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
721
726
|
if (!contentHasRightFadeMask && abs_move > 0 && abs_move < viewportExtent) {
|
|
722
727
|
const std::int64_t scrollRectStartUs = refreshPerfNowUs();
|
|
723
728
|
gea::platform::display::Display::scrollRect(vx, vy, vw, vh, horizontal ? move : 0, horizontal ? 0 : move);
|
|
724
|
-
perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs;
|
|
729
|
+
GEA_REFRESH_PERF(perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs);
|
|
725
730
|
|
|
726
731
|
const std::int64_t stripReplayStartUs = refreshPerfNowUs();
|
|
727
732
|
if (horizontal) {
|
|
@@ -733,7 +738,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
733
738
|
} else {
|
|
734
739
|
replayScrollNodeRegion(vx, vy, vw, abs_move);
|
|
735
740
|
}
|
|
736
|
-
perf.rootScrollStripReplayUs += refreshPerfNowUs() - stripReplayStartUs;
|
|
741
|
+
GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - stripReplayStartUs);
|
|
737
742
|
|
|
738
743
|
// Scrollbar damage is vertical-only: the horizontal forecast/rail rows use
|
|
739
744
|
// scrollbar-width:none and draw no thumb, so a horizontal scroll skips it.
|
|
@@ -769,12 +774,12 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
769
774
|
} else {
|
|
770
775
|
replayScrollbarDamage(n->layout.y, n->layout.height);
|
|
771
776
|
}
|
|
772
|
-
perf.rootScrollScrollbarReplayUs += refreshPerfNowUs() - scrollbarReplayStartUs;
|
|
777
|
+
GEA_REFRESH_PERF(perf.rootScrollScrollbarReplayUs += refreshPerfNowUs() - scrollbarReplayStartUs);
|
|
773
778
|
}
|
|
774
779
|
} else {
|
|
775
780
|
const std::int64_t fullReplayStartUs = refreshPerfNowUs();
|
|
776
781
|
replayScrollNodeRegion(vx, vy, vw, vh);
|
|
777
|
-
perf.rootScrollFullReplayUs += refreshPerfNowUs() - fullReplayStartUs;
|
|
782
|
+
GEA_REFRESH_PERF(perf.rootScrollFullReplayUs += refreshPerfNowUs() - fullReplayStartUs);
|
|
778
783
|
}
|
|
779
784
|
|
|
780
785
|
// Repaint repositioned slots: the vacated box (now showing whatever sits
|
|
@@ -801,7 +806,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
801
806
|
replaySlotRect(damage.newX0, damage.newY0, damage.newX1, damage.newY1);
|
|
802
807
|
}
|
|
803
808
|
}
|
|
804
|
-
perf.rootScrollStripReplayUs += refreshPerfNowUs() - slotReplayStartUs;
|
|
809
|
+
GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - slotReplayStartUs);
|
|
805
810
|
|
|
806
811
|
const std::int64_t extraReplayStartUs = refreshPerfNowUs();
|
|
807
812
|
for (int i = 0; i < extraDirtyCount; i++) {
|
|
@@ -823,7 +828,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
823
828
|
DisplayList::instance().replay();
|
|
824
829
|
gea::platform::display::Display::popClip();
|
|
825
830
|
}
|
|
826
|
-
perf.rootScrollExtraReplayUs += refreshPerfNowUs() - extraReplayStartUs;
|
|
831
|
+
GEA_REFRESH_PERF(perf.rootScrollExtraReplayUs += refreshPerfNowUs() - extraReplayStartUs);
|
|
827
832
|
|
|
828
833
|
const std::int64_t flushStartUs = refreshPerfNowUs();
|
|
829
834
|
if (kSelfFlushingScroll && !damageOverflow) {
|
|
@@ -832,11 +837,11 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
832
837
|
} else {
|
|
833
838
|
gea::platform::display::Display::flush();
|
|
834
839
|
}
|
|
835
|
-
perf.rootScrollFlushUs += refreshPerfNowUs() - flushStartUs;
|
|
840
|
+
GEA_REFRESH_PERF(perf.rootScrollFlushUs += refreshPerfNowUs() - flushStartUs);
|
|
836
841
|
|
|
837
842
|
const std::int64_t snapshotStartUs = refreshPerfNowUs();
|
|
838
843
|
LayoutSnapshot::capture();
|
|
839
|
-
perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs;
|
|
844
|
+
GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
|
|
840
845
|
|
|
841
846
|
return 1;
|
|
842
847
|
}
|
|
@@ -858,7 +863,19 @@ void rootScrollImageHoldTick()
|
|
|
858
863
|
if (state.mountedRoot < 0) return;
|
|
859
864
|
Tree::instance().markDisplayListDirty();
|
|
860
865
|
state.nodes[state.mountedRoot].render.dirty = 1;
|
|
866
|
+
#if GEA_CSS_SCROLLING
|
|
861
867
|
state.nodes[state.mountedRoot].render.non_scroll_dirty = 1;
|
|
868
|
+
#endif
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
#else
|
|
872
|
+
int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
873
|
+
{
|
|
874
|
+
(void)root; (void)width; (void)height;
|
|
875
|
+
return 0;
|
|
862
876
|
}
|
|
863
877
|
|
|
878
|
+
void rootScrollImageHoldTick() {}
|
|
879
|
+
#endif
|
|
880
|
+
|
|
864
881
|
} // namespace gea::embedded::ui
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
#if defined(ESP_PLATFORM)
|
|
8
|
+
#include "esp_heap_caps.h"
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
namespace gea::embedded::ui {
|
|
12
|
+
// Read-only census, requested after the frame sample. No allocation counters
|
|
13
|
+
// or writes are added to style/text/render hot paths. Heap excludes allocator
|
|
14
|
+
// headers; callers report those separately. Shared control blocks are opaque
|
|
15
|
+
// to standard C++, so an owning shared_ptr explicitly makes a census partial.
|
|
16
|
+
struct StorageUsage {
|
|
17
|
+
std::size_t payload = 0, heap = 0, allocations = 0, staticBytes = 0;
|
|
18
|
+
std::size_t untrackedOwners = 0;
|
|
19
|
+
void addAllocation(const void *pointer, std::size_t requested) {
|
|
20
|
+
if (!pointer) return;
|
|
21
|
+
payload += requested;
|
|
22
|
+
#if defined(ESP_PLATFORM)
|
|
23
|
+
heap += heap_caps_get_allocated_size(const_cast<void *>(pointer));
|
|
24
|
+
#else
|
|
25
|
+
heap += requested;
|
|
26
|
+
#endif
|
|
27
|
+
++allocations;
|
|
28
|
+
}
|
|
29
|
+
template <class T, class A> void addVector(const std::vector<T, A> &values) {
|
|
30
|
+
if (values.capacity()) addAllocation(values.data(), values.capacity() * sizeof(T));
|
|
31
|
+
}
|
|
32
|
+
void addString(const std::string &value) {
|
|
33
|
+
const auto data = reinterpret_cast<std::uintptr_t>(value.data());
|
|
34
|
+
const auto object = reinterpret_cast<std::uintptr_t>(&value);
|
|
35
|
+
// Small-string buffers belong to their already-counted string object.
|
|
36
|
+
if (value.capacity() && (data < object || data >= object + sizeof(value)))
|
|
37
|
+
addAllocation(value.data(), value.capacity() + 1);
|
|
38
|
+
}
|
|
39
|
+
StorageUsage &operator+=(const StorageUsage &other) {
|
|
40
|
+
payload += other.payload; heap += other.heap; allocations += other.allocations;
|
|
41
|
+
staticBytes += other.staticBytes; untrackedOwners += other.untrackedOwners;
|
|
42
|
+
return *this;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|