@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.
@@ -176,13 +176,13 @@ namespace gea::embedded::ui
176
176
  node.layout.scroll_y = static_cast<int32_t>(y);
177
177
  continue;
178
178
  }
179
- if (node.style.overflow != 2)
179
+ if (node.computedStyle().overflow != 2)
180
180
  {
181
181
  node.layout.scroll_x = 0;
182
182
  node.layout.scroll_y = 0;
183
183
  continue;
184
184
  }
185
- if (scrollsOverflowX(node.style))
185
+ if (scrollsOverflowX(node.computedStyle()))
186
186
  {
187
187
  int x = offsets[i].x;
188
188
  const int maxX = ViewRenderer::scrollMaxX(node);
@@ -197,7 +197,7 @@ namespace gea::embedded::ui
197
197
  node.layout.scroll_x = 0;
198
198
  }
199
199
 
200
- if (scrollsOverflowY(node.style))
200
+ if (scrollsOverflowY(node.computedStyle()))
201
201
  {
202
202
  int y = offsets[i].y;
203
203
  const int maxY = ViewRenderer::scrollMaxY(node);
@@ -259,15 +259,15 @@ namespace gea::embedded::ui
259
259
 
260
260
  bool dirtyRectNeedsRasterGuard(const Node &node)
261
261
  {
262
- if (hasAnyBorder(node.style))
262
+ if (hasAnyBorder(node.computedStyle()))
263
263
  return true;
264
- if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0 || node.render.previous_filter_blur_radius > 0)
264
+ if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0 || node.render.previous_filter_blur_radius > 0)
265
265
  return true;
266
- if (node.style.mask_right_fade_width > 0)
266
+ if (node.computedStyle().mask_right_fade_width > 0)
267
267
  return true;
268
- if ((GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) > 0)
268
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0) > 0)
269
269
  return true;
270
- return node.style.has_bg && (styleHasRoundedRasterEdge(node.style) || node.style.bg_alpha < 255);
270
+ return node.computedStyle().has_bg && (styleHasRoundedRasterEdge(node.computedStyle()) || node.computedStyle().bg_alpha < 255);
271
271
  }
272
272
 
273
273
  constexpr int kRetainedMoveDirtyGuardPx = GEA_EMBEDDED_RETAINED_MOVE_DIRTY_GUARD_PX;
@@ -407,12 +407,12 @@ namespace gea::embedded::ui
407
407
 
408
408
  int nodeBoxRotation(const Node &node, bool usePrevious)
409
409
  {
410
- return usePrevious ? node.render.previous_transform_rotate : rstyle(node.style).transform_rotate;
410
+ return usePrevious ? node.render.previous_transform_rotate : rstyle(node.computedStyle()).transform_rotate;
411
411
  }
412
412
 
413
413
  bool hasTransformState(const Node &node)
414
414
  {
415
- const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
415
+ const RareStyle &rs = rstyle(node.computedStyle()); // one pool lookup, not 11
416
416
  return hasIndividualLinearTransform(rs) || hadIndividualLinearTransform(node.render) ||
417
417
  rs.transform_rotate != 0 ||
418
418
  node.render.previous_transform_rotate != 0 ||
@@ -442,17 +442,17 @@ namespace gea::embedded::ui
442
442
 
443
443
  bool hasThreeDimensionalTransformState(const Node &node)
444
444
  {
445
- const auto &r = rstyle(node.style);
445
+ const auto &r = rstyle(node.computedStyle());
446
446
  return ((r.rotate_angle % 3600) && (r.rotate_axis_x || r.rotate_axis_y)) ||
447
447
  ((node.render.previous_rotate_angle % 3600) && (node.render.previous_rotate_axis_x || node.render.previous_rotate_axis_y)) ||
448
448
  r.scale_z != 1000 || node.render.previous_scale_z != 1000 ||
449
- rstyle(node.style).transform_rotate_x != 0 ||
449
+ rstyle(node.computedStyle()).transform_rotate_x != 0 ||
450
450
  node.render.previous_transform_rotate_x != 0 ||
451
- rstyle(node.style).transform_rotate_y != 0 ||
451
+ rstyle(node.computedStyle()).transform_rotate_y != 0 ||
452
452
  node.render.previous_transform_rotate_y != 0 ||
453
- composedTranslateZ(rstyle(node.style)) != 0 ||
453
+ composedTranslateZ(rstyle(node.computedStyle())) != 0 ||
454
454
  node.render.previous_transform_translate_z != 0 ||
455
- rstyle(node.style).perspective > 0 ||
455
+ rstyle(node.computedStyle()).perspective > 0 ||
456
456
  node.render.previous_perspective > 0;
457
457
  }
458
458
 
@@ -516,16 +516,16 @@ namespace gea::embedded::ui
516
516
  for (int i = 0; i < 4; ++i)
517
517
  {
518
518
  #if GEA_CSS_PERCENT_RADIUS
519
- if (node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset)
519
+ if (node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset)
520
520
  {
521
- const double p = static_cast<double>(node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)]) / 1000.0;
521
+ const double p = static_cast<double>(node.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(i)]) / 1000.0;
522
522
  rx[i] = std::max(0.0, width * p);
523
523
  ry[i] = std::max(0.0, height * p);
524
524
  }
525
525
  else
526
526
  #endif
527
527
  {
528
- const double r = static_cast<double>(std::max(0, static_cast<int>(node.style.border_radius[GEA_CSS_RADIUS_INDEX(i)])));
528
+ const double r = static_cast<double>(std::max(0, static_cast<int>(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(i)])));
529
529
  rx[i] = r;
530
530
  ry[i] = r;
531
531
  }
@@ -630,9 +630,9 @@ namespace gea::embedded::ui
630
630
  {
631
631
  return isViewLikeNodeType(node.type) &&
632
632
  node.first_child < 0 &&
633
- node.style.display != 1 &&
634
- node.style.has_bg &&
635
- !hasAnyBorder(node.style) &&
633
+ node.computedStyle().display != 1 &&
634
+ node.computedStyle().has_bg &&
635
+ !hasAnyBorder(node.computedStyle()) &&
636
636
  hasTransformState(node);
637
637
  }
638
638
 
@@ -651,11 +651,11 @@ namespace gea::embedded::ui
651
651
  node.type == NodeType::Image ||
652
652
  node.type == NodeType::Canvas)
653
653
  return true;
654
- if (node.style.has_bg || hasAnyBorder(node.style))
654
+ if (node.computedStyle().has_bg || hasAnyBorder(node.computedStyle()))
655
655
  return true;
656
- if ((GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) > 0 || (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0)
656
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(node.computedStyle()).box_shadow_alpha : 0) > 0 || (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0)
657
657
  return true;
658
- if (node.style.mask_right_fade_width > 0)
658
+ if (node.computedStyle().mask_right_fade_width > 0)
659
659
  return true;
660
660
  return false;
661
661
  }
@@ -867,7 +867,7 @@ namespace gea::embedded::ui
867
867
  if (node < 0 || node >= state.nodeCount)
868
868
  return;
869
869
  Node &n = state.nodes[node];
870
- if (n.style.display != 1 && n.layout.width > 0 && n.layout.height > 0)
870
+ if (n.computedStyle().display != 1 && n.layout.width > 0 && n.layout.height > 0)
871
871
  {
872
872
  int nx0, ny0, nx1, ny1;
873
873
  ViewRenderer::transformedBounds(n, usePrevious, &nx0, &ny0, &nx1, &ny1);
@@ -912,7 +912,7 @@ namespace gea::embedded::ui
912
912
 
913
913
  int filterBlurRadiusForNode(const Node &node, bool usePrevious)
914
914
  {
915
- return usePrevious ? node.render.previous_filter_blur_radius : (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
915
+ return usePrevious ? node.render.previous_filter_blur_radius : (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
916
916
  }
917
917
 
918
918
  DirtyRegions::Rect filterBlurBoundsRect(const Node &node, bool usePrevious, int origin)
@@ -935,7 +935,7 @@ namespace gea::embedded::ui
935
935
  for (int i = 0; i < state.nodeCount; i++)
936
936
  {
937
937
  const Node &node = state.nodes[i];
938
- if (node.style.display == 1)
938
+ if (node.computedStyle().display == 1)
939
939
  continue;
940
940
  for (int pass = 0; pass < 2; pass++)
941
941
  {
@@ -1172,18 +1172,18 @@ namespace gea::embedded::ui
1172
1172
 
1173
1173
  bool panNodeHasTransform(const Node &n)
1174
1174
  {
1175
- return hasIndividualLinearTransform(rstyle(n.style)) || hadIndividualLinearTransform(n.render) ||
1176
- rstyle(n.style).transform_rotate != 0 || n.render.previous_transform_rotate != 0 ||
1177
- rstyle(n.style).transform_rotate_x != 0 || n.render.previous_transform_rotate_x != 0 ||
1178
- rstyle(n.style).transform_rotate_y != 0 || n.render.previous_transform_rotate_y != 0 ||
1179
- composedTranslateX(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x != 0 ||
1180
- composedTranslateY(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y != 0 ||
1181
- composedTranslateZ(rstyle(n.style)) != 0 || n.render.previous_transform_translate_z != 0 ||
1182
- composedTranslateXPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_x_percent != 0 ||
1183
- composedTranslateYPercent(rstyle(n.style)) != 0 || n.render.previous_transform_translate_y_percent != 0 ||
1184
- rstyle(n.style).transform_scale_x != 1000 || n.render.previous_transform_scale_x != 1000 ||
1185
- rstyle(n.style).transform_scale_y != 1000 || rstyle(n.style).transform_scale_z != 1000 || n.render.previous_transform_scale_y != 1000 || n.render.previous_transform_scale_z != 1000 ||
1186
- rstyle(n.style).perspective > 0 || n.render.previous_perspective > 0;
1175
+ return hasIndividualLinearTransform(rstyle(n.computedStyle())) || hadIndividualLinearTransform(n.render) ||
1176
+ rstyle(n.computedStyle()).transform_rotate != 0 || n.render.previous_transform_rotate != 0 ||
1177
+ rstyle(n.computedStyle()).transform_rotate_x != 0 || n.render.previous_transform_rotate_x != 0 ||
1178
+ rstyle(n.computedStyle()).transform_rotate_y != 0 || n.render.previous_transform_rotate_y != 0 ||
1179
+ composedTranslateX(rstyle(n.computedStyle())) != 0 || n.render.previous_transform_translate_x != 0 ||
1180
+ composedTranslateY(rstyle(n.computedStyle())) != 0 || n.render.previous_transform_translate_y != 0 ||
1181
+ composedTranslateZ(rstyle(n.computedStyle())) != 0 || n.render.previous_transform_translate_z != 0 ||
1182
+ composedTranslateXPercent(rstyle(n.computedStyle())) != 0 || n.render.previous_transform_translate_x_percent != 0 ||
1183
+ composedTranslateYPercent(rstyle(n.computedStyle())) != 0 || n.render.previous_transform_translate_y_percent != 0 ||
1184
+ rstyle(n.computedStyle()).transform_scale_x != 1000 || n.render.previous_transform_scale_x != 1000 ||
1185
+ rstyle(n.computedStyle()).transform_scale_y != 1000 || rstyle(n.computedStyle()).transform_scale_z != 1000 || n.render.previous_transform_scale_y != 1000 || n.render.previous_transform_scale_z != 1000 ||
1186
+ rstyle(n.computedStyle()).perspective > 0 || n.render.previous_perspective > 0;
1187
1187
  }
1188
1188
 
1189
1189
  bool panIsDescendantOf(int node, int ancestor)
@@ -1206,43 +1206,43 @@ namespace gea::embedded::ui
1206
1206
  {
1207
1207
  if (n.type != NodeType::View)
1208
1208
  return false;
1209
- if (n.style.opacity != 255)
1209
+ if (n.computedStyle().opacity != 255)
1210
1210
  return false;
1211
- if (hasAnyBorder(n.style))
1211
+ if (hasAnyBorder(n.computedStyle()))
1212
1212
  return false;
1213
1213
  for (int r = 0; r < 4; r++)
1214
1214
  {
1215
- if (n.style.border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0)
1215
+ if (n.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0)
1216
1216
  return false;
1217
1217
  #if GEA_CSS_PERCENT_RADIUS
1218
- if (n.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset && n.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != 0)
1218
+ if (n.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset && n.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != 0)
1219
1219
  return false;
1220
1220
  #endif
1221
1221
  }
1222
- if ((GEA_CSS_FILTERS ? rstyle(n.style).filter_blur_radius : 0) > 0)
1222
+ if ((GEA_CSS_FILTERS ? rstyle(n.computedStyle()).filter_blur_radius : 0) > 0)
1223
1223
  return false;
1224
- if (n.style.mask_right_fade_width > 0)
1224
+ if (n.computedStyle().mask_right_fade_width > 0)
1225
1225
  return false;
1226
- if ((GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_alpha : 0) > 0 &&
1227
- ((GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_offset_x : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_offset_y : 0) != 0 ||
1228
- (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_blur_radius : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.style).box_shadow_spread : 0) != 0))
1226
+ if ((GEA_CSS_BOX_SHADOW ? rstyle(n.computedStyle()).box_shadow_alpha : 0) > 0 &&
1227
+ ((GEA_CSS_BOX_SHADOW ? rstyle(n.computedStyle()).box_shadow_offset_x : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.computedStyle()).box_shadow_offset_y : 0) != 0 ||
1228
+ (GEA_CSS_BOX_SHADOW ? rstyle(n.computedStyle()).box_shadow_blur_radius : 0) != 0 || (GEA_CSS_BOX_SHADOW ? rstyle(n.computedStyle()).box_shadow_spread : 0) != 0))
1229
1229
  return false;
1230
- if (n.style.has_bg)
1230
+ if (n.computedStyle().has_bg)
1231
1231
  {
1232
1232
  // A narrow solid rectangle still has horizontal edges: scrolling
1233
1233
  // it creates a ghost just like scrolling text or a rounded control.
1234
- if (n.style.bg_alpha != 255 || panNodeHasTransform(n) ||
1234
+ if (n.computedStyle().bg_alpha != 255 || panNodeHasTransform(n) ||
1235
1235
  n.layout.x > viewportX || n.layout.x + n.layout.width < viewportX + viewportWidth)
1236
1236
  return false;
1237
1237
  for (int parent = n.parent; parent >= 0; parent = treeState().nodes[parent].parent) {
1238
1238
  const Node &clip = treeState().nodes[parent];
1239
- if (panNodeHasTransform(clip) || (clip.style.overflow &&
1239
+ if (panNodeHasTransform(clip) || (clip.computedStyle().overflow &&
1240
1240
  (clip.layout.x > viewportX || clip.layout.x + clip.layout.width < viewportX + viewportWidth)))
1241
1241
  return false;
1242
1242
  }
1243
- if (styleHasBackgroundImage(n.style))
1243
+ if (styleHasBackgroundImage(n.computedStyle()))
1244
1244
  return false; // gradient fill (linear/radial/overlay)
1245
- if (rstyle(n.style).bg_grid_axes != 0)
1245
+ if (rstyle(n.computedStyle()).bg_grid_axes != 0)
1246
1246
  return false; // grid overlay
1247
1247
  }
1248
1248
  return true;
@@ -1257,7 +1257,7 @@ namespace gea::embedded::ui
1257
1257
  gea::platform::display::Display::resetClip();
1258
1258
  gea::platform::display::Display::setAlpha(255);
1259
1259
  DisplayList::instance().replayDirectDirtyRegion(rx, ry, rx + rw - 1, ry + rh - 1, origin);
1260
- refreshPerfStatsMutable().treePanRepaintArea += rw * rh;
1260
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treePanRepaintArea += rw * rh);
1261
1261
  return true;
1262
1262
  }
1263
1263
 
@@ -1321,14 +1321,14 @@ namespace gea::embedded::ui
1321
1321
  Node *n = &state.nodes[i];
1322
1322
  if (!n->render.dirty)
1323
1323
  continue;
1324
- if (n->style.display == kDisplayNone)
1324
+ if (n->computedStyle().display == kDisplayNone)
1325
1325
  continue;
1326
1326
  if (n->first_child < 0)
1327
1327
  continue;
1328
1328
  if (n->parent < 0)
1329
1329
  continue;
1330
1330
  Node *p = &state.nodes[n->parent];
1331
- if (p->style.overflow != 1)
1331
+ if (p->computedStyle().overflow != 1)
1332
1332
  continue; // parent must clip (overflow:hidden)
1333
1333
  const int dx = n->layout.x - n->layout.previous_x;
1334
1334
  const int dy = n->layout.y - n->layout.previous_y;
@@ -1340,7 +1340,7 @@ namespace gea::embedded::ui
1340
1340
  continue;
1341
1341
  if (n->layout.previous_width <= 0 || n->layout.previous_height <= 0)
1342
1342
  continue;
1343
- if (n->style.opacity != 255)
1343
+ if (n->computedStyle().opacity != 255)
1344
1344
  continue;
1345
1345
  if (panNodeHasTransform(*n))
1346
1346
  continue;
@@ -1459,7 +1459,7 @@ namespace gea::embedded::ui
1459
1459
  panCoverageWrapperX = W->layout.x;
1460
1460
  panCoveragePadding = kPanRecordPadding;
1461
1461
  panCoverageSerial = DisplayList::instance().recordSerial();
1462
- refreshPerfStatsMutable().treeRecordNodeUs += refreshPerfNowUs() - rebuildStartUs;
1462
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeRecordNodeUs += refreshPerfNowUs() - rebuildStartUs);
1463
1463
  }
1464
1464
 
1465
1465
  // ---- Commit: shift the framebuffer and repaint only what the shift can't. ----
@@ -1489,7 +1489,7 @@ namespace gea::embedded::ui
1489
1489
  for (int i = 0; i < state.nodeCount; i++)
1490
1490
  {
1491
1491
  Node *n = &state.nodes[i];
1492
- if (n->style.display == kDisplayNone)
1492
+ if (n->computedStyle().display == kDisplayNone)
1493
1493
  continue;
1494
1494
  if (i == wrapper || panIsDescendantOf(i, wrapper))
1495
1495
  continue;
@@ -1550,9 +1550,9 @@ namespace gea::embedded::ui
1550
1550
  state.canvases.forEach([](CanvasSurfaceState &surface)
1551
1551
  {
1552
1552
  if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
1553
- refreshPerfStatsMutable().treePanReplayCalls++;
1553
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treePanReplayCalls++);
1554
1554
  if (directRegions > 0)
1555
- refreshPerfStatsMutable().treeDirectReplayCalls++;
1555
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeDirectReplayCalls++);
1556
1556
  return true;
1557
1557
  }
1558
1558
 
@@ -1655,10 +1655,12 @@ namespace gea::embedded::ui
1655
1655
  gea::platform::display::Display::resetClip();
1656
1656
  gea::platform::display::Display::setAlpha(255);
1657
1657
 
1658
- LayoutEngine::instance().beginLayoutPass();
1659
- LayoutEngine::instance().layoutNode(root, width, height);
1660
- applyPendingScrollIntoView();
1661
- LayoutEngine::instance().resolveAbsoluteCoords(root, 0, 0);
1658
+ {
1659
+ LayoutEngine::Pass layoutPass;
1660
+ LayoutEngine::instance().layoutNode(root, width, height);
1661
+ applyPendingScrollIntoView();
1662
+ LayoutEngine::instance().resolveAbsoluteCoords(root, 0, 0);
1663
+ }
1662
1664
  noteLaidOutViewport(root, width, height);
1663
1665
  state.refreshSerial++;
1664
1666
  if (state.refreshSerial == 0)
@@ -1729,7 +1731,7 @@ namespace gea::embedded::ui
1729
1731
  PreservedScrollOffset scrollOffsets[kMaxNodes];
1730
1732
  preserveScrollOffsets(scrollOffsets, kMaxNodes);
1731
1733
  #endif
1732
- LayoutEngine::instance().beginLayoutPass();
1734
+ LayoutEngine::Pass layoutPass;
1733
1735
  LayoutEngine::instance().layoutNode(root, width, height);
1734
1736
  #if GEA_CSS_SCROLLING
1735
1737
  restoreScrollOffsetsAfterLayout(scrollOffsets, kMaxNodes);
@@ -1835,7 +1837,7 @@ namespace gea::embedded::ui
1835
1837
  const bool dimsStable = a.layout.width == a.layout.previous_width &&
1836
1838
  a.layout.height == a.layout.previous_height &&
1837
1839
  a.layout.width > 0 && a.layout.height > 0;
1838
- if (dimsStable && a.style.display != kDisplayNone)
1840
+ if (dimsStable && a.computedStyle().display != kDisplayNone)
1839
1841
  return scope;
1840
1842
  }
1841
1843
  return -1;
@@ -1861,7 +1863,7 @@ namespace gea::embedded::ui
1861
1863
  // moves content, so native renderers must re-sync.
1862
1864
  state.refreshSerial++;
1863
1865
  auto &perf = refreshPerfStatsMutable();
1864
- perf.treeRefreshCalls++;
1866
+ GEA_REFRESH_PERF(perf.treeRefreshCalls++);
1865
1867
  DisplayList::instance().clearRetainedBackgroundRecolors();
1866
1868
 
1867
1869
  const bool textClipDependencies = DisplayList::instance().hasTextClippedBackgrounds();
@@ -1919,7 +1921,7 @@ namespace gea::embedded::ui
1919
1921
  const bool framebuffer_was_dirty = false;
1920
1922
  #endif
1921
1923
  int layout_mode = AbsoluteLeafRefresh::mode();
1922
- perf.treeLayoutModeUs += refreshPerfNowUs() - layoutModeStartUs;
1924
+ GEA_REFRESH_PERF(perf.treeLayoutModeUs += refreshPerfNowUs() - layoutModeStartUs);
1923
1925
  if (layout_mode < 0)
1924
1926
  {
1925
1927
  if (!framebuffer_was_dirty && !state.displayListDirty && state.pendingScrollIntoViewNode < 0)
@@ -1970,13 +1972,13 @@ namespace gea::embedded::ui
1970
1972
  if (scope >= 0)
1971
1973
  scope = stableScopeAt(state, scope, root);
1972
1974
  if (scope < 0)
1973
- perf.treeScopedRejectReason = 1;
1975
+ GEA_REFRESH_PERF(perf.treeScopedRejectReason = 1);
1974
1976
  for (int attempt = 0; scope >= 0 && attempt < 2; attempt++)
1975
1977
  {
1976
1978
  scoped = LayoutEngine::instance().layoutNodeScoped(scope, root);
1977
1979
  if (scoped)
1978
1980
  {
1979
- perf.treeScopedLayouts++;
1981
+ GEA_REFRESH_PERF(perf.treeScopedLayouts++);
1980
1982
  break;
1981
1983
  }
1982
1984
  // Most rejects mean the scope autosized to the new content —
@@ -1985,9 +1987,9 @@ namespace gea::embedded::ui
1985
1987
  scope = stableScopeAt(state, state.nodes[scope].parent, root);
1986
1988
  }
1987
1989
  }
1990
+ LayoutEngine::Pass layoutPass(!scoped);
1988
1991
  if (!scoped)
1989
1992
  {
1990
- LayoutEngine::instance().beginLayoutPass();
1991
1993
  LayoutEngine::instance().layoutNode(root, width, height);
1992
1994
  }
1993
1995
  #if GEA_CSS_SCROLLING
@@ -2012,7 +2014,7 @@ namespace gea::embedded::ui
2012
2014
  continue;
2013
2015
  if (n.parent < 0 && i != root)
2014
2016
  continue;
2015
- if (n.style.display == kDisplayNone)
2017
+ if (n.computedStyle().display == kDisplayNone)
2016
2018
  continue;
2017
2019
  if (n.layout.previous_width <= 0 && n.layout.previous_height <= 0 &&
2018
2020
  n.layout.width <= 0 && n.layout.height <= 0)
@@ -2046,7 +2048,7 @@ namespace gea::embedded::ui
2046
2048
  state.refreshSerial++;
2047
2049
  if (state.refreshSerial == 0)
2048
2050
  state.refreshSerial = 1;
2049
- perf.treeLayoutUs += refreshPerfNowUs() - layoutStartUs;
2051
+ GEA_REFRESH_PERF(perf.treeLayoutUs += refreshPerfNowUs() - layoutStartUs);
2050
2052
 
2051
2053
  const std::int64_t displayListStartUs = refreshPerfNowUs();
2052
2054
  const bool display_list_was_dirty = state.displayListDirty;
@@ -2306,10 +2308,10 @@ namespace gea::embedded::ui
2306
2308
  }
2307
2309
  state.displayListDirty = false;
2308
2310
  displayListFullRecord = !reprojected;
2309
- perf.treeRecordNodeUs += refreshPerfNowUs() - recordNodeStartUs;
2310
- perf.treeRecordCalls++;
2311
- perf.treeRecordedNodes += state.nodeCount;
2312
- perf.treeRecordedCommands += DisplayList::instance().commandCount();
2311
+ GEA_REFRESH_PERF(perf.treeRecordNodeUs += refreshPerfNowUs() - recordNodeStartUs);
2312
+ GEA_REFRESH_PERF(perf.treeRecordCalls++);
2313
+ GEA_REFRESH_PERF(perf.treeRecordedNodes += state.nodeCount);
2314
+ GEA_REFRESH_PERF(perf.treeRecordedCommands += DisplayList::instance().commandCount());
2313
2315
  }
2314
2316
  else if (!can_keep_display_list)
2315
2317
  {
@@ -2329,16 +2331,16 @@ namespace gea::embedded::ui
2329
2331
  DisplayList::instance().recordNode(root, 255);
2330
2332
  DisplayList::instance().weldTransformedFaces();
2331
2333
  state.displayListDirty = false;
2332
- perf.treeRecordNodeUs += refreshPerfNowUs() - recordNodeStartUs;
2333
- perf.treeRecordCalls++;
2334
- perf.treeRecordedNodes += state.nodeCount;
2335
- perf.treeRecordedCommands += DisplayList::instance().commandCount();
2334
+ GEA_REFRESH_PERF(perf.treeRecordNodeUs += refreshPerfNowUs() - recordNodeStartUs);
2335
+ GEA_REFRESH_PERF(perf.treeRecordCalls++);
2336
+ GEA_REFRESH_PERF(perf.treeRecordedNodes += state.nodeCount);
2337
+ GEA_REFRESH_PERF(perf.treeRecordedCommands += DisplayList::instance().commandCount());
2336
2338
  }
2337
2339
  if (displayListFullRecord)
2338
- perf.treeFullRecords++;
2340
+ GEA_REFRESH_PERF(perf.treeFullRecords++);
2339
2341
  if (reprojected)
2340
- perf.treeReprojects++;
2341
- perf.treeDisplayListUs += refreshPerfNowUs() - displayListStartUs;
2342
+ GEA_REFRESH_PERF(perf.treeReprojects++);
2343
+ GEA_REFRESH_PERF(perf.treeDisplayListUs += refreshPerfNowUs() - displayListStartUs);
2342
2344
 
2343
2345
  // Horizontal-pan fast path: when a camera/world wrapper translated the viewport
2344
2346
  // this frame (and nothing structural changed), memcpy-shift the viewport instead
@@ -2436,10 +2438,10 @@ namespace gea::embedded::ui
2436
2438
  direct_replay &&
2437
2439
  n->render.bg_recolor_pending &&
2438
2440
  n->first_child < 0 &&
2439
- !hasAnyBorder(n->style) &&
2440
- n->style.opacity == 255 &&
2441
- (GEA_CSS_FILTERS ? rstyle(n->style).filter_blur_radius : 0) <= 0 &&
2442
- (GEA_CSS_BOX_SHADOW ? rstyle(n->style).box_shadow_blur_radius : 0) <= 0 &&
2441
+ !hasAnyBorder(n->computedStyle()) &&
2442
+ n->computedStyle().opacity == 255 &&
2443
+ (GEA_CSS_FILTERS ? rstyle(n->computedStyle()).filter_blur_radius : 0) <= 0 &&
2444
+ (GEA_CSS_BOX_SHADOW ? rstyle(n->computedStyle()).box_shadow_blur_radius : 0) <= 0 &&
2443
2445
  n->layout.x == n->layout.previous_x &&
2444
2446
  n->layout.y == n->layout.previous_y &&
2445
2447
  n->layout.width == n->layout.previous_width &&
@@ -2452,7 +2454,7 @@ namespace gea::embedded::ui
2452
2454
  int recolorY1 = -1;
2453
2455
  if (DisplayList::instance().recolorRetainedSolidBackground(i,
2454
2456
  n->render.bg_recolor_from,
2455
- n->style.bg_color,
2457
+ n->computedStyle().bg_color,
2456
2458
  &recolorX0,
2457
2459
  &recolorY0,
2458
2460
  &recolorX1,
@@ -2498,8 +2500,8 @@ namespace gea::embedded::ui
2498
2500
  addDirtyRegion(flush_rects, &flush_rect_count, repair, width, height);
2499
2501
  }
2500
2502
  }
2501
- perf.treeBgRecolorCalls++;
2502
- perf.treeBgRecolorPixels += recolorPixels;
2503
+ GEA_REFRESH_PERF(perf.treeBgRecolorCalls++);
2504
+ GEA_REFRESH_PERF(perf.treeBgRecolorPixels += recolorPixels);
2503
2505
  n->render.dirty = 0;
2504
2506
  n->render.layout_dirty = 0;
2505
2507
  #if GEA_CSS_SCROLLING
@@ -2718,7 +2720,7 @@ namespace gea::embedded::ui
2718
2720
  // replay the full filtered source/output bounds so the cache never mixes
2719
2721
  // retained pixels with the current frame.
2720
2722
  expandDirtyRegionsForFilterBlur(rects, &rect_count, flush_rects, &flush_rect_count, unifiedRectPath, width, height);
2721
- perf.treeDirtyCollectUs += refreshPerfNowUs() - dirtyCollectStartUs;
2723
+ GEA_REFRESH_PERF(perf.treeDirtyCollectUs += refreshPerfNowUs() - dirtyCollectStartUs);
2722
2724
  // Done collecting (and the structural/framebuffer/filter adds above); clear the
2723
2725
  // broad-bbox flag so it can't leak into any later addDirtyRegion path.
2724
2726
  g_broadDirtyBbox = false;
@@ -2778,28 +2780,30 @@ namespace gea::embedded::ui
2778
2780
  coalesceHighCoverageDirtyRegions(flush_rects, &flush_rect_count, width, height);
2779
2781
  #endif
2780
2782
  }
2781
- perf.treeDirtyCoalesceUs += refreshPerfNowUs() - dirtyCoalesceStartUs;
2783
+ GEA_REFRESH_PERF(perf.treeDirtyCoalesceUs += refreshPerfNowUs() - dirtyCoalesceStartUs);
2782
2784
 
2783
2785
  gea::platform::display::DisplayFlushRect flushRects[DirtyRegions::kMaxRects];
2784
2786
  int flushRectCount = 0;
2787
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
2785
2788
  if (rect_count > 0)
2786
2789
  {
2787
- perf.treeReplayRegions += rect_count;
2790
+ GEA_REFRESH_PERF(perf.treeReplayRegions += rect_count);
2788
2791
  for (int i = 0; i < rect_count; i++)
2789
2792
  {
2790
2793
  if (rects[i].origin >= 0)
2791
- perf.treeReplayOriginRegions++;
2794
+ GEA_REFRESH_PERF(perf.treeReplayOriginRegions++);
2792
2795
  if (perf.treeReplayRegionSampleCount < gea::embedded::ui::RefreshPerfStats::kMaxTreeReplayRegionSamples)
2793
2796
  {
2794
2797
  const int sample = perf.treeReplayRegionSampleCount++;
2795
- perf.treeReplayRegionX0[sample] = static_cast<std::int16_t>(rects[i].x0);
2796
- perf.treeReplayRegionY0[sample] = static_cast<std::int16_t>(rects[i].y0);
2797
- perf.treeReplayRegionX1[sample] = static_cast<std::int16_t>(rects[i].x1);
2798
- perf.treeReplayRegionY1[sample] = static_cast<std::int16_t>(rects[i].y1);
2799
- perf.treeReplayRegionOrigin[sample] = static_cast<std::int16_t>(rects[i].origin);
2798
+ GEA_REFRESH_PERF(perf.treeReplayRegionX0[sample] = static_cast<std::int16_t>(rects[i].x0));
2799
+ GEA_REFRESH_PERF(perf.treeReplayRegionY0[sample] = static_cast<std::int16_t>(rects[i].y0));
2800
+ GEA_REFRESH_PERF(perf.treeReplayRegionX1[sample] = static_cast<std::int16_t>(rects[i].x1));
2801
+ GEA_REFRESH_PERF(perf.treeReplayRegionY1[sample] = static_cast<std::int16_t>(rects[i].y1));
2802
+ GEA_REFRESH_PERF(perf.treeReplayRegionOrigin[sample] = static_cast<std::int16_t>(rects[i].origin));
2800
2803
  }
2801
2804
  }
2802
2805
  }
2806
+ #endif
2803
2807
  const bool hasFlushOnlyRecolorRegions = preserveFlushOnlyRecolorRegions && flush_rect_count > 0;
2804
2808
  const bool simpleDirtyReplayAvailable =
2805
2809
  direct_replay && unifiedRectPath && DisplayList::instance().canReplaySimpleDirtyRegions(width, height);
@@ -2818,7 +2822,7 @@ namespace gea::embedded::ui
2818
2822
  #endif
2819
2823
  if (simpleUnifiedReplay)
2820
2824
  {
2821
- perf.treeDirectReplayCalls++;
2825
+ GEA_REFRESH_PERF(perf.treeDirectReplayCalls++);
2822
2826
  #if GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH
2823
2827
  // Fused: skip the separate replay-into-framebuffer pass entirely. Hand the
2824
2828
  // coalesced dirty windows to the flush, which chunks them and calls
@@ -2844,7 +2848,7 @@ namespace gea::embedded::ui
2844
2848
  gea::platform::display::Display::flushRectsRasterized(sparseRects, sparseCount, fusedReplayRaster, &fctx, /*allowPerChunkDrain=*/false);
2845
2849
  gea::platform::display::Display::rebindCanvasToFramebuffer();
2846
2850
  }
2847
- perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs;
2851
+ GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs);
2848
2852
  }
2849
2853
  #else
2850
2854
  // A single wide flush of the dirty union avoids the per-window overhead and
@@ -2898,7 +2902,7 @@ namespace gea::embedded::ui
2898
2902
  gea::platform::display::Display::pushClip(r->x0, r->y0, r->x1 - r->x0 + 1, r->y1 - r->y0 + 1);
2899
2903
  const std::int64_t replayStartUs = refreshPerfNowUs();
2900
2904
  DisplayList::instance().replaySimpleClippedDirtyRegion(r->x0, r->y0, r->x1, r->y1, r->origin);
2901
- perf.treeReplayUs += refreshPerfNowUs() - replayStartUs;
2905
+ GEA_REFRESH_PERF(perf.treeReplayUs += refreshPerfNowUs() - replayStartUs);
2902
2906
  gea::platform::display::Display::popClip();
2903
2907
  }
2904
2908
  }
@@ -2914,7 +2918,7 @@ namespace gea::embedded::ui
2914
2918
  regions[i] = DisplayReplayRegion{r->x0, r->y0, r->x1, r->y1, r->origin};
2915
2919
  }
2916
2920
  DisplayList::instance().replayDirectDirtyRegions(regions, rect_count);
2917
- perf.treeReplayUs += refreshPerfNowUs() - replayStartUs;
2921
+ GEA_REFRESH_PERF(perf.treeReplayUs += refreshPerfNowUs() - replayStartUs);
2918
2922
  }
2919
2923
  }
2920
2924
  else
@@ -2927,7 +2931,7 @@ namespace gea::embedded::ui
2927
2931
  gea::platform::display::Display::pushClip(r->x0, r->y0, r->x1 - r->x0 + 1, r->y1 - r->y0 + 1);
2928
2932
  const std::int64_t replayStartUs = refreshPerfNowUs();
2929
2933
  DisplayList::instance().replaySimpleClippedDirtyRegion(r->x0, r->y0, r->x1, r->y1, r->origin);
2930
- perf.treeReplayUs += refreshPerfNowUs() - replayStartUs;
2934
+ GEA_REFRESH_PERF(perf.treeReplayUs += refreshPerfNowUs() - replayStartUs);
2931
2935
  gea::platform::display::Display::popClip();
2932
2936
  }
2933
2937
  }
@@ -2962,12 +2966,12 @@ namespace gea::embedded::ui
2962
2966
  if (sparseCount > 0)
2963
2967
  gea::platform::display::Display::flushRects(sparseRects, sparseCount);
2964
2968
  }
2965
- perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs;
2969
+ GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs);
2966
2970
  #endif
2967
2971
  }
2968
2972
  else if (interleavedUnifiedFlush)
2969
2973
  {
2970
- perf.treeDirectReplayCalls++;
2974
+ GEA_REFRESH_PERF(perf.treeDirectReplayCalls++);
2971
2975
  #if GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH && GEA_EMBEDDED_DISPLAY_FUSE_INTERLEAVED_REPLAY_FLUSH
2972
2976
  FusedReplayRasterCtx fctx{width, height};
2973
2977
  gea::platform::display::DisplayFlushRect sparseRects[DirtyRegions::kMaxRects];
@@ -2986,7 +2990,7 @@ namespace gea::embedded::ui
2986
2990
  gea::platform::display::Display::flushRectsRasterized(sparseRects, sparseCount, fusedDirectReplayRaster, &fctx, /*allowPerChunkDrain=*/false);
2987
2991
  gea::platform::display::Display::rebindCanvasToFramebuffer();
2988
2992
  }
2989
- perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs;
2993
+ GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs);
2990
2994
  #else
2991
2995
  for (int i = 0; i < rect_count; i++)
2992
2996
  {
@@ -2997,11 +3001,11 @@ namespace gea::embedded::ui
2997
3001
  const std::int64_t replayStartUs = refreshPerfNowUs();
2998
3002
  const DisplayReplayRegion region{r->x0, r->y0, r->x1, r->y1, r->origin};
2999
3003
  DisplayList::instance().replayDirectDirtyRegions(&region, 1);
3000
- perf.treeReplayUs += refreshPerfNowUs() - replayStartUs;
3004
+ GEA_REFRESH_PERF(perf.treeReplayUs += refreshPerfNowUs() - replayStartUs);
3001
3005
  gea::platform::display::Display::popClip();
3002
3006
  const std::int64_t flushStartUs = refreshPerfNowUs();
3003
3007
  gea::platform::display::Display::flush();
3004
- perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs;
3008
+ GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs);
3005
3009
  }
3006
3010
  #endif
3007
3011
  }
@@ -3010,7 +3014,7 @@ namespace gea::embedded::ui
3010
3014
  const std::int64_t replayStartUs = refreshPerfNowUs();
3011
3015
  if (direct_replay && rect_count > 0)
3012
3016
  {
3013
- perf.treeDirectReplayCalls++;
3017
+ GEA_REFRESH_PERF(perf.treeDirectReplayCalls++);
3014
3018
  gea::platform::display::Display::resetClip();
3015
3019
  gea::platform::display::Display::setAlpha(255);
3016
3020
  DisplayReplayRegion regions[DirtyRegions::kMaxRects];
@@ -3034,7 +3038,7 @@ namespace gea::embedded::ui
3034
3038
  gea::platform::display::Display::popClip();
3035
3039
  }
3036
3040
  }
3037
- perf.treeReplayUs += refreshPerfNowUs() - replayStartUs;
3041
+ GEA_REFRESH_PERF(perf.treeReplayUs += refreshPerfNowUs() - replayStartUs);
3038
3042
  }
3039
3043
 
3040
3044
  // Static-backdrop cache: once the static scene (bg + stage) has been stable for a
@@ -3089,7 +3093,7 @@ namespace gea::embedded::ui
3089
3093
  }
3090
3094
  if (flushRectCount > 0)
3091
3095
  gea::platform::display::Display::flushRects(flushRects, flushRectCount);
3092
- perf.treeFlushRectsUs += refreshPerfNowUs() - flushRectsStartUs;
3096
+ GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushRectsStartUs);
3093
3097
  }
3094
3098
  const std::int64_t snapshotStartUs = refreshPerfNowUs();
3095
3099
  LayoutSnapshot::capture();
@@ -3104,7 +3108,7 @@ namespace gea::embedded::ui
3104
3108
  if (displayCanvas)
3105
3109
  displayCanvas->resetDirty();
3106
3110
  #endif
3107
- perf.treeSnapshotUs += refreshPerfNowUs() - snapshotStartUs;
3111
+ GEA_REFRESH_PERF(perf.treeSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
3108
3112
  }
3109
3113
 
3110
3114
  void Tree::frame(int timestamp_ms)
@@ -3130,11 +3134,11 @@ namespace gea::embedded::ui
3130
3134
  for (int i = 0; i < state.nodeCount; i++)
3131
3135
  {
3132
3136
  Node *n = &state.nodes[i];
3133
- if (n->style.blink_interval_ms <= 0)
3137
+ if (n->computedStyle().blink_interval_ms <= 0)
3134
3138
  {
3135
- if (!n->style.blink_visible)
3139
+ if (!n->computedStyle().blink_visible)
3136
3140
  {
3137
- n->style.blink_visible = 1;
3141
+ n->mutableStyle().blink_visible = 1;
3138
3142
  n->render.dirty = 1;
3139
3143
  n->render.layout_dirty = 1;
3140
3144
  #if GEA_CSS_SCROLLING
@@ -3145,13 +3149,13 @@ namespace gea::embedded::ui
3145
3149
  continue;
3146
3150
  }
3147
3151
 
3148
- int elapsed = timestamp_ms - n->style.blink_started_ms;
3152
+ int elapsed = timestamp_ms - n->computedStyle().blink_started_ms;
3149
3153
  if (elapsed < 0)
3150
3154
  elapsed = 0;
3151
- int visible = ((elapsed / n->style.blink_interval_ms) % 2) == 0;
3152
- if (n->style.blink_visible == visible)
3155
+ int visible = ((elapsed / n->computedStyle().blink_interval_ms) % 2) == 0;
3156
+ if (n->computedStyle().blink_visible == visible)
3153
3157
  continue;
3154
- n->style.blink_visible = visible;
3158
+ n->mutableStyle().blink_visible = visible;
3155
3159
  n->render.dirty = 1;
3156
3160
  n->render.layout_dirty = 1;
3157
3161
  #if GEA_CSS_SCROLLING
@@ -3178,7 +3182,7 @@ namespace gea::embedded::ui
3178
3182
  Node *n = &state.nodes[i];
3179
3183
  if (n->type != NodeType::Camera)
3180
3184
  continue;
3181
- if (n->style.display == kDisplayNone)
3185
+ if (n->computedStyle().display == kDisplayNone)
3182
3186
  continue;
3183
3187
  hasVisibleCamera = true;
3184
3188
  if (nativeOverlay)