@geastack/engine 0.1.7 → 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.
@@ -17,3 +17,8 @@
17
17
  #ifndef GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
18
18
  #define GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS 1
19
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
@@ -34,30 +34,30 @@ namespace {
34
34
 
35
35
  bool hasTransformState(const Node &node)
36
36
  {
37
- return hasIndividualLinearTransform(rstyle(node.style)) || hadIndividualLinearTransform(node.render) ||
38
- rstyle(node.style).transform_rotate != 0 ||
37
+ return hasIndividualLinearTransform(rstyle(node.computedStyle())) || hadIndividualLinearTransform(node.render) ||
38
+ rstyle(node.computedStyle()).transform_rotate != 0 ||
39
39
  node.render.previous_transform_rotate != 0 ||
40
- rstyle(node.style).transform_rotate_x != 0 ||
40
+ rstyle(node.computedStyle()).transform_rotate_x != 0 ||
41
41
  node.render.previous_transform_rotate_x != 0 ||
42
- rstyle(node.style).transform_rotate_y != 0 ||
42
+ rstyle(node.computedStyle()).transform_rotate_y != 0 ||
43
43
  node.render.previous_transform_rotate_y != 0 ||
44
- composedTranslateX(rstyle(node.style)) != 0 ||
44
+ composedTranslateX(rstyle(node.computedStyle())) != 0 ||
45
45
  node.render.previous_transform_translate_x != 0 ||
46
- composedTranslateY(rstyle(node.style)) != 0 ||
46
+ composedTranslateY(rstyle(node.computedStyle())) != 0 ||
47
47
  node.render.previous_transform_translate_y != 0 ||
48
- composedTranslateZ(rstyle(node.style)) != 0 ||
48
+ composedTranslateZ(rstyle(node.computedStyle())) != 0 ||
49
49
  node.render.previous_transform_translate_z != 0 ||
50
- composedTranslateXPercent(rstyle(node.style)) != 0 ||
50
+ composedTranslateXPercent(rstyle(node.computedStyle())) != 0 ||
51
51
  node.render.previous_transform_translate_x_percent != 0 ||
52
- composedTranslateYPercent(rstyle(node.style)) != 0 ||
52
+ composedTranslateYPercent(rstyle(node.computedStyle())) != 0 ||
53
53
  node.render.previous_transform_translate_y_percent != 0 ||
54
- rstyle(node.style).transform_scale_x != 1000 ||
54
+ rstyle(node.computedStyle()).transform_scale_x != 1000 ||
55
55
  node.render.previous_transform_scale_x != 1000 ||
56
- rstyle(node.style).transform_scale_y != 1000 ||
57
- rstyle(node.style).transform_scale_z != 1000 ||
56
+ rstyle(node.computedStyle()).transform_scale_y != 1000 ||
57
+ rstyle(node.computedStyle()).transform_scale_z != 1000 ||
58
58
  node.render.previous_transform_scale_y != 1000 ||
59
59
  node.render.previous_transform_scale_z != 1000 ||
60
- rstyle(node.style).perspective > 0 ||
60
+ rstyle(node.computedStyle()).perspective > 0 ||
61
61
  node.render.previous_perspective > 0;
62
62
  }
63
63
 
@@ -83,7 +83,7 @@ bool isDescendantOf(const TreeState &state, int node, int ancestor)
83
83
  bool hasRightFadeMask(const TreeState &state, int node)
84
84
  {
85
85
  for (int cursor = node; cursor >= 0; cursor = state.nodes[cursor].parent) {
86
- if (state.nodes[cursor].style.mask_right_fade_width > 0) return true;
86
+ if (state.nodes[cursor].computedStyle().mask_right_fade_width > 0) return true;
87
87
  }
88
88
  return false;
89
89
  }
@@ -103,13 +103,13 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
103
103
  if (state.nodes[scrollNode].type != NodeType::VirtualList) return false;
104
104
  // The list is the slot's containing block only when it is itself positioned
105
105
  // (matches containingBlockForAbsoluteNode in the layout engine).
106
- const auto parentPosition = state.nodes[scrollNode].style.position;
106
+ const auto parentPosition = state.nodes[scrollNode].computedStyle().position;
107
107
  if (parentPosition != 1 && parentPosition != 2) return false;
108
- if (n.style.position != 1) return false;
108
+ if (n.computedStyle().position != 1) return false;
109
109
  // Anchored via top/bottom (the windowed axis); refresh() recomputes y from
110
110
  // these offsets directly.
111
- if (GEA_CSS_POSITION_PX_0(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_0(n.style) == kUnset &&
112
- GEA_CSS_POSITION_PX_2(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_2(n.style) == kUnset)
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)
113
113
  return false;
114
114
  if (hasTransformState(n)) return false;
115
115
  // The reconcile translates the slot box; a pending size change needs layout.
@@ -121,8 +121,8 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
121
121
  template <int side>
122
122
  int resolvedSlotOffset(const Node &slot, int basis)
123
123
  {
124
- int offset = GEA_CSS_POSITION_PX(slot.style, side) != kUnset ? GEA_CSS_POSITION_PX(slot.style, side) : 0;
125
- const int percent = GEA_CSS_POSITION_PERCENT(slot.style, side);
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);
126
126
  if (percent != kUnset) {
127
127
  const int numerator = basis * percent;
128
128
  offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
@@ -168,12 +168,12 @@ bool nonVirtualListScrollbarThumbBounds(const Node &n, int scrollTop, int *thumb
168
168
  // inline formatting), and stacks them as a column otherwise.
169
169
  bool flowsChildrenAsRow(const TreeState &state, const Node &p)
170
170
  {
171
- if (usesRowLayout(p.style)) return true;
172
- if (p.style.flex_direction_explicit || p.style.display != kDisplayBlock) return false;
171
+ if (usesRowLayout(p.computedStyle())) return true;
172
+ if (p.computedStyle().flex_direction_explicit || p.computedStyle().display != kDisplayBlock) return false;
173
173
  bool anyInFlow = false;
174
174
  for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
175
175
  const Node &child = state.nodes[c];
176
- if (child.style.display == kDisplayNone || isOutOfFlowPosition(child.style.position)) continue;
176
+ if (child.computedStyle().display == kDisplayNone || isOutOfFlowPosition(child.computedStyle().position)) continue;
177
177
  if (!LayoutEngine::isInlineLevelNode(child)) return false;
178
178
  anyInFlow = true;
179
179
  }
@@ -196,20 +196,20 @@ void shiftSiblingsForRemeasuredText(TreeState &state, int id, int oldWidth, int
196
196
  {
197
197
  const Node &n = state.nodes[id];
198
198
  const Node &p = state.nodes[n.parent];
199
- if (p.style.flex_wrap || p.style.justify_content != 0) return;
199
+ if (p.computedStyle().flex_wrap || p.computedStyle().justify_content != 0) return;
200
200
  const bool row = flowsChildrenAsRow(state, p);
201
201
  const int delta = row ? n.layout.width - oldWidth : n.layout.height - oldHeight;
202
202
  if (delta == 0) return;
203
203
  int totalFlex = 0;
204
204
  for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
205
205
  const Node &child = state.nodes[c];
206
- if (child.style.display == kDisplayNone || isOutOfFlowPosition(child.style.position)) continue;
207
- totalFlex += child.style.flex;
206
+ if (child.computedStyle().display == kDisplayNone || isOutOfFlowPosition(child.computedStyle().position)) continue;
207
+ totalFlex += child.computedStyle().flex;
208
208
  }
209
209
  if (totalFlex > 0) return;
210
210
  for (int c = n.next_sibling; c >= 0; c = state.nodes[c].next_sibling) {
211
211
  Node &sib = state.nodes[c];
212
- if (sib.style.display == kDisplayNone || isOutOfFlowPosition(sib.style.position)) continue;
212
+ if (sib.computedStyle().display == kDisplayNone || isOutOfFlowPosition(sib.computedStyle().position)) continue;
213
213
  if (row) sib.layout.x += delta;
214
214
  else sib.layout.y += delta;
215
215
  translateSlotDescendants(state, c, row ? delta : 0, row ? 0 : delta);
@@ -251,15 +251,15 @@ void remeasureDirtyTextInPlace(TreeState &state, int id, bool siblingsCoveredByR
251
251
  // shift the following stacked siblings by any height delta. Hugged
252
252
  // (non-stretch / explicit-width) boxes re-measure naturally and keep
253
253
  // their left anchor — the cross axis never right-flushes by default.
254
- const int align = n.style.align_self >= 0 ? n.style.align_self : p.style.align_items;
255
- const bool stretched = align == 0 && n.style.width == kUnset && n.style.width_percent == kUnset;
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;
256
256
  if (!TextRenderer::remeasureContentBox(id, stretched)) return;
257
257
  if (siblingsCoveredByReplay) shiftSiblingsForRemeasuredText(state, id, oldWidth, oldHeight);
258
258
  return;
259
259
  }
260
260
  if (!TextRenderer::remeasureContentBox(id)) return;
261
- const int oldRight = n.layout.x + oldWidth + n.style.margin[1];
262
- const int parentRight = p.layout.x + p.layout.width - p.style.padding[1];
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];
263
263
  if (oldRight == parentRight) {
264
264
  n.layout.x += oldWidth - n.layout.width;
265
265
  return;
@@ -319,25 +319,25 @@ int RootScrollOnlyRefresh::refreshNode(int root,
319
319
 
320
320
  if (n->render.scroll_dirty && !n->render.non_scroll_dirty) {
321
321
  if (foundNode >= 0) return -1;
322
- if (!isViewLikeNodeType(n->type) || n->style.display == 1) return -1;
322
+ if (!isViewLikeNodeType(n->type) || n->computedStyle().display == 1) return -1;
323
323
  // Accept a pure scroll on exactly one axis the node overflows. The
324
324
  // horizontal case mirrors the vertical fast path (see refresh()): a
325
325
  // virtual-list is vertical-only. Rejecting a both-axes change keeps the
326
326
  // single-axis scrollRect blit unambiguous.
327
327
  const bool changedY = n->layout.scroll_y != n->layout.previous_scroll_y;
328
328
  const bool changedX = n->layout.scroll_x != n->layout.previous_scroll_x;
329
- const bool canScrollYAxis = n->type == NodeType::VirtualList || scrollsOverflowY(n->style);
330
- const bool canScrollXAxis = n->type != NodeType::VirtualList && scrollsOverflowX(n->style);
329
+ const bool canScrollYAxis = n->type == NodeType::VirtualList || scrollsOverflowY(n->computedStyle());
330
+ const bool canScrollXAxis = n->type != NodeType::VirtualList && scrollsOverflowX(n->computedStyle());
331
331
  const bool vertical = changedY && !changedX && canScrollYAxis;
332
332
  const bool horizontal = changedX && !changedY && canScrollXAxis;
333
333
  if (!vertical && !horizontal) return -1;
334
334
  if (!layoutUnchanged(*n)) return -1;
335
335
  if (hasTransformState(*n)) return -1;
336
- if (n->style.opacity != 255 || hasAnyBorder(n->style)) return -1;
336
+ if (n->computedStyle().opacity != 255 || hasAnyBorder(n->computedStyle())) return -1;
337
337
  for (int r = 0; r < 4; r++) {
338
- if (n->style.border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return -1;
338
+ if (n->computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return -1;
339
339
  #if GEA_CSS_PERCENT_RADIUS
340
- if (n->style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return -1;
340
+ if (n->computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return -1;
341
341
  #endif
342
342
  }
343
343
  foundNode = i;
@@ -364,7 +364,7 @@ int RootScrollOnlyRefresh::refreshNode(int root,
364
364
  for (int i = 0; i < state.nodeCount; i++) {
365
365
  if (i == foundNode) continue;
366
366
  const Node &o = state.nodes[i];
367
- if (o.style.display == 1 || o.style.opacity == 0) continue;
367
+ if (o.computedStyle().display == 1 || o.computedStyle().opacity == 0) continue;
368
368
  if (o.layout.width <= 0 || o.layout.height <= 0) continue;
369
369
  // Skip the scroll node's own subtree and its ancestor chain — and any
370
370
  // node inside a display:none subtree: a hidden ancestor removes the
@@ -376,7 +376,7 @@ int RootScrollOnlyRefresh::refreshNode(int root,
376
376
  bool hidden = false;
377
377
  for (int a = i; a >= 0; a = state.nodes[a].parent) {
378
378
  if (a == foundNode) { related = true; break; }
379
- if (state.nodes[a].style.display == 1) { hidden = true; break; }
379
+ if (state.nodes[a].computedStyle().display == 1) { hidden = true; break; }
380
380
  }
381
381
  if (related || hidden) continue;
382
382
  for (int a = foundNode; a >= 0; a = state.nodes[a].parent) {
@@ -442,8 +442,8 @@ int RootScrollOnlyRefresh::refreshNode(int root,
442
442
  // Consult the pending flag, not just the two laid-out boxes; the sibling
443
443
  // fast path already screens on exactly this pair (`absolute_leaf_refresh.cpp`).
444
444
  if (n->render.layout_dirty &&
445
- ((n->style.height != kUnset && n->style.height != n->layout.height) ||
446
- (n->style.width != kUnset && n->style.width != n->layout.width))) {
445
+ ((n->computedStyle().height != kUnset && n->computedStyle().height != n->layout.height) ||
446
+ (n->computedStyle().width != kUnset && n->computedStyle().width != n->layout.width))) {
447
447
  return -1;
448
448
  }
449
449
  if (!layoutUnchanged(*n)) {
@@ -489,20 +489,20 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
489
489
  {
490
490
  auto &state = treeState();
491
491
  auto &perf = refreshPerfStatsMutable();
492
- perf.rootScrollCalls++;
492
+ GEA_REFRESH_PERF(perf.rootScrollCalls++);
493
493
  DirtyNode extraDirtyNodes[kMaxExtraDirtyNodes];
494
494
  int extraDirtyCount = 0;
495
495
  int slotNodes[kMaxSlotRepositionNodes];
496
496
  int slotCount = 0;
497
497
  const std::int64_t scanStartUs = refreshPerfNowUs();
498
498
  int scroll_node = refreshNode(root, extraDirtyNodes, &extraDirtyCount, slotNodes, &slotCount, width, height);
499
- perf.rootScrollScanUs += refreshPerfNowUs() - scanStartUs;
499
+ GEA_REFRESH_PERF(perf.rootScrollScanUs += refreshPerfNowUs() - scanStartUs);
500
500
  if (scroll_node < 0) {
501
- perf.rootScrollRejected++;
501
+ GEA_REFRESH_PERF(perf.rootScrollRejected++);
502
502
  return 0;
503
503
  }
504
- perf.rootScrollAccepted++;
505
- perf.rootScrollExtraDirtyNodes += extraDirtyCount;
504
+ GEA_REFRESH_PERF(perf.rootScrollAccepted++);
505
+ GEA_REFRESH_PERF(perf.rootScrollExtraDirtyNodes += extraDirtyCount);
506
506
 
507
507
  Node *n = &state.nodes[scroll_node];
508
508
  // refreshNode accepted a pure single-axis scroll; derive which axis moved.
@@ -539,19 +539,19 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
539
539
  damage.oldX1 = slot.layout.x + slot.layout.width - 1;
540
540
  damage.oldY1 = slot.layout.y + slot.layout.height - 1;
541
541
  damage.moved = false;
542
- if (slot.style.display == 1) continue; // display:none — erase old rect only
542
+ if (slot.computedStyle().display == 1) continue; // display:none — erase old rect only
543
543
 
544
544
  int newX = slot.layout.x;
545
- if (GEA_CSS_POSITION_PX_3(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_3(slot.style) != kUnset)
545
+ if (GEA_CSS_POSITION_PX_3(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_3(slot.computedStyle()) != kUnset)
546
546
  newX = n->layout.x + resolvedSlotOffset<3>(slot, n->layout.width);
547
- else if (GEA_CSS_POSITION_PX_1(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_1(slot.style) != kUnset)
547
+ else if (GEA_CSS_POSITION_PX_1(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_1(slot.computedStyle()) != kUnset)
548
548
  newX = n->layout.x + n->layout.width - slot.layout.width -
549
549
  resolvedSlotOffset<1>(slot, n->layout.width);
550
550
 
551
551
  int newY = slot.layout.y;
552
- if (GEA_CSS_POSITION_PX_0(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_0(slot.style) != kUnset)
552
+ if (GEA_CSS_POSITION_PX_0(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_0(slot.computedStyle()) != kUnset)
553
553
  newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset<0>(slot, n->layout.height);
554
- else if (GEA_CSS_POSITION_PX_2(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_2(slot.style) != kUnset)
554
+ else if (GEA_CSS_POSITION_PX_2(slot.computedStyle()) != kUnset || GEA_CSS_POSITION_PERCENT_2(slot.computedStyle()) != kUnset)
555
555
  newY = n->layout.y - n->layout.scroll_y + n->layout.height - slot.layout.height -
556
556
  resolvedSlotOffset<2>(slot, n->layout.height);
557
557
 
@@ -574,7 +574,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
574
574
  if (!ViewportRegion::clipRect(width, height, &vx, &vy, &vw, &vh)) {
575
575
  const std::int64_t snapshotStartUs = refreshPerfNowUs();
576
576
  LayoutSnapshot::capture();
577
- perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs;
577
+ GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
578
578
  return 1;
579
579
  }
580
580
 
@@ -677,12 +677,12 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
677
677
  state.displayListDirty = false;
678
678
  coverageRoot = -1;
679
679
  }
680
- perf.rootScrollRebuildUs += refreshPerfNowUs() - rebuildStartUs;
680
+ GEA_REFRESH_PERF(perf.rootScrollRebuildUs += refreshPerfNowUs() - rebuildStartUs);
681
681
  }
682
- perf.rootScrollMovePx += abs_move;
683
- perf.rootScrollViewportPx += vw * vh;
684
- perf.rootScrollStripPx += horizontal ? (vh * (abs_move < vw ? abs_move : vw))
685
- : (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)));
686
686
 
687
687
  gea::platform::display::Display::resetClip();
688
688
  gea::platform::display::Display::setAlpha(255);
@@ -726,7 +726,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
726
726
  if (!contentHasRightFadeMask && abs_move > 0 && abs_move < viewportExtent) {
727
727
  const std::int64_t scrollRectStartUs = refreshPerfNowUs();
728
728
  gea::platform::display::Display::scrollRect(vx, vy, vw, vh, horizontal ? move : 0, horizontal ? 0 : move);
729
- perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs;
729
+ GEA_REFRESH_PERF(perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs);
730
730
 
731
731
  const std::int64_t stripReplayStartUs = refreshPerfNowUs();
732
732
  if (horizontal) {
@@ -738,7 +738,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
738
738
  } else {
739
739
  replayScrollNodeRegion(vx, vy, vw, abs_move);
740
740
  }
741
- perf.rootScrollStripReplayUs += refreshPerfNowUs() - stripReplayStartUs;
741
+ GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - stripReplayStartUs);
742
742
 
743
743
  // Scrollbar damage is vertical-only: the horizontal forecast/rail rows use
744
744
  // scrollbar-width:none and draw no thumb, so a horizontal scroll skips it.
@@ -774,12 +774,12 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
774
774
  } else {
775
775
  replayScrollbarDamage(n->layout.y, n->layout.height);
776
776
  }
777
- perf.rootScrollScrollbarReplayUs += refreshPerfNowUs() - scrollbarReplayStartUs;
777
+ GEA_REFRESH_PERF(perf.rootScrollScrollbarReplayUs += refreshPerfNowUs() - scrollbarReplayStartUs);
778
778
  }
779
779
  } else {
780
780
  const std::int64_t fullReplayStartUs = refreshPerfNowUs();
781
781
  replayScrollNodeRegion(vx, vy, vw, vh);
782
- perf.rootScrollFullReplayUs += refreshPerfNowUs() - fullReplayStartUs;
782
+ GEA_REFRESH_PERF(perf.rootScrollFullReplayUs += refreshPerfNowUs() - fullReplayStartUs);
783
783
  }
784
784
 
785
785
  // Repaint repositioned slots: the vacated box (now showing whatever sits
@@ -806,7 +806,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
806
806
  replaySlotRect(damage.newX0, damage.newY0, damage.newX1, damage.newY1);
807
807
  }
808
808
  }
809
- perf.rootScrollStripReplayUs += refreshPerfNowUs() - slotReplayStartUs;
809
+ GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - slotReplayStartUs);
810
810
 
811
811
  const std::int64_t extraReplayStartUs = refreshPerfNowUs();
812
812
  for (int i = 0; i < extraDirtyCount; i++) {
@@ -828,7 +828,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
828
828
  DisplayList::instance().replay();
829
829
  gea::platform::display::Display::popClip();
830
830
  }
831
- perf.rootScrollExtraReplayUs += refreshPerfNowUs() - extraReplayStartUs;
831
+ GEA_REFRESH_PERF(perf.rootScrollExtraReplayUs += refreshPerfNowUs() - extraReplayStartUs);
832
832
 
833
833
  const std::int64_t flushStartUs = refreshPerfNowUs();
834
834
  if (kSelfFlushingScroll && !damageOverflow) {
@@ -837,11 +837,11 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
837
837
  } else {
838
838
  gea::platform::display::Display::flush();
839
839
  }
840
- perf.rootScrollFlushUs += refreshPerfNowUs() - flushStartUs;
840
+ GEA_REFRESH_PERF(perf.rootScrollFlushUs += refreshPerfNowUs() - flushStartUs);
841
841
 
842
842
  const std::int64_t snapshotStartUs = refreshPerfNowUs();
843
843
  LayoutSnapshot::capture();
844
- perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs;
844
+ GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
845
845
 
846
846
  return 1;
847
847
  }
@@ -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
+ }