@geastack/engine 0.1.7 → 0.1.9

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/ui/render.cpp CHANGED
@@ -274,7 +274,7 @@ int gLastScrollUiFrame = -1000;
274
274
  constexpr int kTransformedGradientLutBanks = (GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS) ? GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_BANKS : 1;
275
275
  static_assert(kTransformedGradientLutBanks > 0);
276
276
  constexpr bool kTransformedGradientA5Mirror = GEA_EMBEDDED_TRANSFORMED_GRADIENT_A5_MIRROR != 0;
277
- static_assert(kTransformedGradientA5Mirror || GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER == 0,
277
+ static_assert(kTransformedGradientA5Mirror || !GEA_EMBEDDED_RENDERER_TRANSFORMS || !GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER == 0,
278
278
  "GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER requires the transformed-gradient a5 mirror");
279
279
  constexpr int kProjectedTextCacheBanks = GEA_EMBEDDED_RENDERER_TRANSFORMS ? GEA_EMBEDDED_PROJECTED_TEXT_CACHE_BANKS : 1;
280
280
  static_assert(kProjectedTextCacheBanks > 0);
@@ -850,7 +850,7 @@ int gLastScrollUiFrame = -1000;
850
850
 
851
851
  uint8_t rightFadeMaskAlphaForChild(const Node &parent, const Node &child)
852
852
  {
853
- const int fade = parent.style.mask_right_fade_width;
853
+ const int fade = parent.computedStyle().mask_right_fade_width;
854
854
  if (fade <= 0 || parent.layout.width <= 0)
855
855
  return 255;
856
856
  if (child.layout.width <= 0 || child.layout.height <= 0)
@@ -1347,9 +1347,9 @@ int gLastScrollUiFrame = -1000;
1347
1347
  {
1348
1348
  return node.first_child < 0 &&
1349
1349
  node.type == NodeType::View &&
1350
- node.style.has_bg &&
1351
- !styleHasBackgroundImage(node.style) && rstyle(node.style).bg_clip == 0 &&
1352
- !hasAnyBorder(node.style);
1350
+ node.computedStyle().has_bg &&
1351
+ !styleHasBackgroundImage(node.computedStyle()) && rstyle(node.computedStyle()).bg_clip == 0 &&
1352
+ !hasAnyBorder(node.computedStyle());
1353
1353
  }
1354
1354
 
1355
1355
  bool isFullyRoundedFilterShape(const Node &node)
@@ -1357,10 +1357,10 @@ int gLastScrollUiFrame = -1000;
1357
1357
  const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
1358
1358
  const int minRadius = std::max(1, halfMin - 1);
1359
1359
  return halfMin > 0 &&
1360
- node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)] >= minRadius &&
1361
- node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)] >= minRadius &&
1362
- node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)] >= minRadius &&
1363
- node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)] >= minRadius;
1360
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)] >= minRadius &&
1361
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)] >= minRadius &&
1362
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)] >= minRadius &&
1363
+ node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)] >= minRadius;
1364
1364
  }
1365
1365
 
1366
1366
  bool screenToNodeRectHomography(const Node &node, double out[8])
@@ -1641,8 +1641,8 @@ int gLastScrollUiFrame = -1000;
1641
1641
  const std::int64_t t0 = refreshPerfNowUs();
1642
1642
  gea::platform::display::Display::fillCircle(cx, cy, radius, color);
1643
1643
  auto &perf = refreshPerfStatsMutable();
1644
- perf.treeReplayCircleCommands++;
1645
- perf.treeReplayCircleUs += refreshPerfNowUs() - t0;
1644
+ GEA_REFRESH_PERF(perf.treeReplayCircleCommands++);
1645
+ GEA_REFRESH_PERF(perf.treeReplayCircleUs += refreshPerfNowUs() - t0);
1646
1646
  return true;
1647
1647
  }
1648
1648
 
@@ -2011,8 +2011,8 @@ int gLastScrollUiFrame = -1000;
2011
2011
  return nx * nx + ny * ny <= 1.0;
2012
2012
  }
2013
2013
 
2014
- const double radius = static_cast<double>(std::min(std::min(node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)], node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)]),
2015
- std::min(node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)], node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)])));
2014
+ const double radius = static_cast<double>(std::min(std::min(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(0)], node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(1)]),
2015
+ std::min(node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(2)], node.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(3)])));
2016
2016
  const double r = std::max(0.0, std::min(radius, std::min(w, h) * 0.5));
2017
2017
  if (r <= 0.0)
2018
2018
  return true;
@@ -2126,7 +2126,7 @@ int gLastScrollUiFrame = -1000;
2126
2126
  const double ry = h * 0.5;
2127
2127
  if (rx <= 0.0 || ry <= 0.0)
2128
2128
  return 0;
2129
- const double blur = std::max(1.0, static_cast<double>((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0)));
2129
+ const double blur = std::max(1.0, static_cast<double>((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0)));
2130
2130
  const double dx = std::fabs(sx - (x + rx));
2131
2131
  const double dy = std::fabs(sy - (y + ry));
2132
2132
  const double alphaX = 1.0 - smoothStep(rx, rx + blur * 2.0, dx);
@@ -2220,7 +2220,7 @@ int gLastScrollUiFrame = -1000;
2220
2220
  continue;
2221
2221
  const int index = row * screenW + col;
2222
2222
  cache.alpha[index] = static_cast<std::uint8_t>(alpha);
2223
- cache.pixels[index] = node.style.bg_color;
2223
+ cache.pixels[index] = node.computedStyle().bg_color;
2224
2224
  }
2225
2225
  }
2226
2226
 
@@ -2343,7 +2343,7 @@ int gLastScrollUiFrame = -1000;
2343
2343
  continue;
2344
2344
  const int index = row * w + col;
2345
2345
  cache.alpha[index] = static_cast<std::uint8_t>((coverage * sourceAlpha + 127) / 255);
2346
- cache.pixels[index] = node.style.bg_color;
2346
+ cache.pixels[index] = node.computedStyle().bg_color;
2347
2347
  }
2348
2348
  }
2349
2349
 
@@ -2798,9 +2798,9 @@ int gLastScrollUiFrame = -1000;
2798
2798
  const int ttf = command.projectedText.textTransform;
2799
2799
  const int needBytes = srcW * srcH;
2800
2800
  auto &perf = refreshPerfStatsMutable();
2801
- perf.projectedTextCacheCalls++;
2802
- if (needBytes > perf.projectedTextCacheMaxEntryBytes)
2803
- perf.projectedTextCacheMaxEntryBytes = needBytes;
2801
+ GEA_REFRESH_PERF(perf.projectedTextCacheCalls++);
2802
+ if (GEA_EMBEDDED_UI_REFRESH_PERF && needBytes > perf.projectedTextCacheMaxEntryBytes)
2803
+ GEA_REFRESH_PERF(perf.projectedTextCacheMaxEntryBytes = needBytes);
2804
2804
  CoverageCacheEntry *hit = nullptr;
2805
2805
  for (auto &e : cache)
2806
2806
  {
@@ -2813,7 +2813,7 @@ int gLastScrollUiFrame = -1000;
2813
2813
  }
2814
2814
  if (!hit)
2815
2815
  {
2816
- perf.projectedTextCacheMisses++;
2816
+ GEA_REFRESH_PERF(perf.projectedTextCacheMisses++);
2817
2817
  // Prefer an empty slot (8 slots > the handful of distinct labels in a
2818
2818
  // scene), else evict the hash-mapped slot.
2819
2819
  int evict = textHash & 7;
@@ -2869,8 +2869,9 @@ int gLastScrollUiFrame = -1000;
2869
2869
  }
2870
2870
  else
2871
2871
  {
2872
- perf.projectedTextCacheHits++;
2872
+ GEA_REFRESH_PERF(perf.projectedTextCacheHits++);
2873
2873
  }
2874
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
2874
2875
  int cachedBytes = 0;
2875
2876
  int sramBytes = 0;
2876
2877
  for (const auto &e : cache)
@@ -2881,17 +2882,18 @@ int gLastScrollUiFrame = -1000;
2881
2882
  sramBytes += e.bytes;
2882
2883
  }
2883
2884
  if (cachedBytes > perf.projectedTextCacheBytes)
2884
- perf.projectedTextCacheBytes = cachedBytes;
2885
+ GEA_REFRESH_PERF(perf.projectedTextCacheBytes = cachedBytes);
2885
2886
  if (sramBytes > perf.projectedTextCacheSramBytes)
2886
- perf.projectedTextCacheSramBytes = sramBytes;
2887
+ GEA_REFRESH_PERF(perf.projectedTextCacheSramBytes = sramBytes);
2888
+ #endif
2887
2889
  if (hit->inSram)
2888
2890
  {
2889
- perf.projectedTextCacheSramUses++;
2891
+ GEA_REFRESH_PERF(perf.projectedTextCacheSramUses++);
2890
2892
  cb = hit->sramBuf;
2891
2893
  }
2892
2894
  else
2893
2895
  {
2894
- perf.projectedTextCachePsramUses++;
2896
+ GEA_REFRESH_PERF(perf.projectedTextCachePsramUses++);
2895
2897
  cb = hit->buf.data();
2896
2898
  }
2897
2899
  // A label with no ink at all draws nothing — skip the projected loop.
@@ -2919,7 +2921,7 @@ int gLastScrollUiFrame = -1000;
2919
2921
  else
2920
2922
  #endif
2921
2923
  {
2922
- refreshPerfStatsMutable().projectedTextCacheFallbacks++;
2924
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().projectedTextCacheFallbacks++);
2923
2925
  }
2924
2926
  const float srcXf = static_cast<float>(command.projectedText.srcX);
2925
2927
  const float srcYf = static_cast<float>(command.projectedText.srcY);
@@ -3554,7 +3556,7 @@ int gLastScrollUiFrame = -1000;
3554
3556
  std::memcpy(slot->keyA, keyA, sizeof keyA);
3555
3557
  slot->valid = true;
3556
3558
  }
3557
- const bool slotIsConstAlpha = slotConstAlpha[slot - slots] != 0;
3559
+ [[maybe_unused]] const bool slotIsConstAlpha = slotConstAlpha[slot - slots] != 0;
3558
3560
  #if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
3559
3561
  unlockSlots();
3560
3562
  #endif
@@ -3697,7 +3699,9 @@ int gLastScrollUiFrame = -1000;
3697
3699
  #if GEA_EMBEDDED_PIXEL_FORMAT == GEA_PIXEL_RGB565
3698
3700
  const bool rgb565LutBlendAvail = kTransformedGradientA5Mirror && gea_rgb565_lut_blend_available();
3699
3701
  const bool rgb565LutBlendConstAlphaAvail = gea_rgb565_lut_blend_const_alpha_available();
3700
- #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER
3702
+ #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER && GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
3703
+ // An unused transformed-gradient path must not reserve its 4 KiB SIMD
3704
+ // scratch. The cache-free scalar fallback below preserves rendering.
3701
3705
  // SIMD-blend scratch for the aligned middle of each span: gathered LUT colors
3702
3706
  // (panel->normal) + per-pixel alpha. PER-CORE: with the 2-core coarse split the
3703
3707
  // worker fills the bottom band concurrently with this core's top band, so a
@@ -3850,7 +3854,7 @@ int gLastScrollUiFrame = -1000;
3850
3854
  row[x] = gea::framework::graphics::pixel::fromRgb565(rn);
3851
3855
  };
3852
3856
  int x = xL;
3853
- #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER
3857
+ #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER && GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
3854
3858
  // The PIE kernel uses 16-byte-aligned vector load/store, so &row[aStart]
3855
3859
  // must be 16-byte (8-px) aligned at its ABSOLUTE framebuffer address — not
3856
3860
  // just at a row-local multiple of 8. The framebuffer stride is packed
@@ -4736,7 +4740,7 @@ int gLastScrollUiFrame = -1000;
4736
4740
 
4737
4741
  bool hasRetainedTransformState(const Node &node)
4738
4742
  {
4739
- const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
4743
+ const RareStyle &rs = rstyle(node.computedStyle()); // one pool lookup, not 11
4740
4744
  const bool currentTransformable = ViewRenderer::isTransformableBox(node);
4741
4745
  return (currentTransformable && hasIndividualLinearTransform(rs)) ||
4742
4746
  (node.render.previous_transformable_box && hadIndividualLinearTransform(node.render)) ||
@@ -4788,7 +4792,7 @@ int gLastScrollUiFrame = -1000;
4788
4792
  struct Key { int phase, level; };
4789
4793
  static bool effectGroup(const Node &node)
4790
4794
  {
4791
- const auto &s = node.style;
4795
+ const auto &s = node.computedStyle();
4792
4796
  const auto &rs = rstyle(s);
4793
4797
  const bool transformable = ViewRenderer::isTransformableBox(node);
4794
4798
  return s.opacity < 255 || s.mask_right_fade_width > 0 || rs.filter_present || rs.filter_blur_radius ||
@@ -4802,10 +4806,10 @@ int gLastScrollUiFrame = -1000;
4802
4806
  {
4803
4807
  const Node *nodes = Tree::instance().nodes();
4804
4808
  const Node &n = nodes[id];
4805
- const auto &s = n.style;
4809
+ const auto &s = n.computedStyle();
4806
4810
  const bool positioned = s.position != 0;
4807
4811
  const bool item = n.parent >= 0 && !isOutOfFlowPosition(s.position) &&
4808
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
4812
+ (nodes[n.parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[n.parent].computedStyle()));
4809
4813
  const int level = !s.z_index_auto && (positioned || item) ? s.z_index : 0;
4810
4814
  if (level < 0) return {0, level};
4811
4815
  if (level > 0) return {5, level};
@@ -4824,7 +4828,7 @@ int gLastScrollUiFrame = -1000;
4824
4828
  static bool participatesIn3DContext(int node, int contextRoot)
4825
4829
  {
4826
4830
  const Node *nodes = Tree::instance().nodes();
4827
- if (contextRoot < 0 || !ViewRenderer::isTransformableBox(nodes[contextRoot]) || !preserves3D(nodes[contextRoot].style))
4831
+ if (contextRoot < 0 || !ViewRenderer::isTransformableBox(nodes[contextRoot]) || !preserves3D(nodes[contextRoot].computedStyle()))
4828
4832
  return false;
4829
4833
  // A 3D rendering context follows DOM ancestry, not containing-block
4830
4834
  // ancestry. Every parent between a participant and the context root
@@ -4832,7 +4836,7 @@ int gLastScrollUiFrame = -1000;
4832
4836
  // single plane and prevents abs/fixed descendants from being hoisted
4833
4837
  // into this context.
4834
4838
  for (int parent = nodes[node].parent; parent >= 0 && parent != contextRoot; parent = nodes[parent].parent)
4835
- if (!ViewRenderer::isTransformableBox(nodes[parent]) || !preserves3D(nodes[parent].style))
4839
+ if (!ViewRenderer::isTransformableBox(nodes[parent]) || !preserves3D(nodes[parent].computedStyle()))
4836
4840
  return false;
4837
4841
  for (int parent = nodes[node].parent; parent >= 0; parent = nodes[parent].parent)
4838
4842
  if (parent == contextRoot)
@@ -4894,7 +4898,7 @@ int gLastScrollUiFrame = -1000;
4894
4898
  // each node costs 5 double-precision projections, so this avoids it
4895
4899
  // entirely for 2D trees.
4896
4900
  const bool transforms = contextRoot >= 0 && ViewRenderer::isTransformableBox(Tree::instance().nodes()[contextRoot]) &&
4897
- preserves3D(Tree::instance().nodes()[contextRoot].style) &&
4901
+ preserves3D(Tree::instance().nodes()[contextRoot].computedStyle()) &&
4898
4902
  ViewRenderer::anyTransformActive();
4899
4903
  if (!transforms)
4900
4904
  {
@@ -4952,9 +4956,9 @@ int gLastScrollUiFrame = -1000;
4952
4956
  case DisplayCommandType::PushClip: {
4953
4957
  const int id = c->clip.nodeId;
4954
4958
  const Node *owner = id >= 0 && id < Tree::instance().nodeCount() ? &Tree::instance().nodes()[id] : nullptr;
4955
- if (!owner || overflowX(owner->style)) c->clip.x += dx;
4959
+ if (!owner || overflowX(owner->computedStyle())) c->clip.x += dx;
4956
4960
  else c->bx -= dx;
4957
- if (!owner || overflowY(owner->style)) c->clip.y += dy;
4961
+ if (!owner || overflowY(owner->computedStyle())) c->clip.y += dy;
4958
4962
  else c->by -= dy;
4959
4963
  break;
4960
4964
  }
@@ -6250,8 +6254,8 @@ int gLastScrollUiFrame = -1000;
6250
6254
  auto &tree = Tree::instance();
6251
6255
  if (id < 0 || id >= tree.nodeCount()) return;
6252
6256
  const auto &node = tree.nodes()[id];
6253
- if (node.style.display == 1 || (id != owner && isOutOfFlowPosition(node.style.position))) return;
6254
- if (state.hasNodeScratchFor(id) && node.style.visibility == 0) {
6257
+ if (node.computedStyle().display == 1 || (id != owner && isOutOfFlowPosition(node.computedStyle().position))) return;
6258
+ if (state.hasNodeScratchFor(id) && node.computedStyle().visibility == 0) {
6255
6259
  const int begin = state.nodeDrawStart[id], end = state.nodeDrawEnd[id];
6256
6260
  for (int ci = std::max(0, begin); ci < end && ci < state.commandCount; ++ci) {
6257
6261
  const auto &c = state.commands[ci];
@@ -6332,23 +6336,23 @@ int gLastScrollUiFrame = -1000;
6332
6336
  switch (c.type)
6333
6337
  {
6334
6338
  case DisplayCommandType::FillRect:
6335
- perf.treeReplayFillRectCommands++;
6339
+ GEA_REFRESH_PERF(perf.treeReplayFillRectCommands++);
6336
6340
  break;
6337
6341
  case DisplayCommandType::FillCircle:
6338
- perf.treeReplayCircleCommands++;
6342
+ GEA_REFRESH_PERF(perf.treeReplayCircleCommands++);
6339
6343
  break;
6340
6344
  case DisplayCommandType::FillRoundedRect:
6341
- perf.treeReplayRoundedRectCommands++;
6345
+ GEA_REFRESH_PERF(perf.treeReplayRoundedRectCommands++);
6342
6346
  break;
6343
6347
  case DisplayCommandType::FillTransformedRoundedRect:
6344
- perf.treeReplayTransformedRoundedRectCommands++;
6348
+ GEA_REFRESH_PERF(perf.treeReplayTransformedRoundedRectCommands++);
6345
6349
  break;
6346
6350
  case DisplayCommandType::DrawText:
6347
6351
  case DisplayCommandType::DrawProjectedText:
6348
- perf.treeReplayTextCommands++;
6352
+ GEA_REFRESH_PERF(perf.treeReplayTextCommands++);
6349
6353
  break;
6350
6354
  default:
6351
- perf.treeReplayOtherCommands++;
6355
+ GEA_REFRESH_PERF(perf.treeReplayOtherCommands++);
6352
6356
  break;
6353
6357
  }
6354
6358
  }
@@ -6516,26 +6520,26 @@ int gLastScrollUiFrame = -1000;
6516
6520
  case DisplayCommandType::FillRoundedRect:
6517
6521
  case DisplayCommandType::FillQuad:
6518
6522
  case DisplayCommandType::FillTransformedRoundedRect:
6519
- __perf.treeReplayFillUs += __replayDt;
6523
+ GEA_REFRESH_PERF(__perf.treeReplayFillUs += __replayDt);
6520
6524
  break;
6521
6525
  case DisplayCommandType::FillCircle:
6522
- __perf.treeReplayCircleUs += __replayDt;
6526
+ GEA_REFRESH_PERF(__perf.treeReplayCircleUs += __replayDt);
6523
6527
  break;
6524
6528
  case DisplayCommandType::DrawText:
6525
6529
  case DisplayCommandType::DrawProjectedText:
6526
- __perf.treeReplayTextUs += __replayDt;
6530
+ GEA_REFRESH_PERF(__perf.treeReplayTextUs += __replayDt);
6527
6531
  break;
6528
6532
  case DisplayCommandType::FillLinearGradient:
6529
6533
  case DisplayCommandType::FillTransformedLinearGradient:
6530
6534
  case DisplayCommandType::FillRadialGradient:
6531
- __perf.treeReplayGradientUs += __replayDt;
6535
+ GEA_REFRESH_PERF(__perf.treeReplayGradientUs += __replayDt);
6532
6536
  break;
6533
6537
  case DisplayCommandType::BlitImage:
6534
6538
  case DisplayCommandType::BlitImageScaled:
6535
- __perf.treeReplayImageUs += __replayDt;
6539
+ GEA_REFRESH_PERF(__perf.treeReplayImageUs += __replayDt);
6536
6540
  break;
6537
6541
  default:
6538
- __perf.treeReplayOtherUs += __replayDt;
6542
+ GEA_REFRESH_PERF(__perf.treeReplayOtherUs += __replayDt);
6539
6543
  break;
6540
6544
  }
6541
6545
  }
@@ -6587,22 +6591,22 @@ int gLastScrollUiFrame = -1000;
6587
6591
  {
6588
6592
  const bool simpleBackgroundLeaf = node.first_child < 0 &&
6589
6593
  node.type == NodeType::View &&
6590
- node.style.has_bg &&
6591
- !styleHasBackgroundImage(node.style) && rstyle(node.style).bg_clip == 0 &&
6592
- !hasAnyBorder(node.style);
6594
+ node.computedStyle().has_bg &&
6595
+ !styleHasBackgroundImage(node.computedStyle()) && rstyle(node.computedStyle()).bg_clip == 0 &&
6596
+ !hasAnyBorder(node.computedStyle());
6593
6597
  if (!simpleBackgroundLeaf)
6594
6598
  return -1;
6595
- return (static_cast<int>(parentAlpha) * static_cast<int>(node.style.bg_alpha) + 127) / 255;
6599
+ return (static_cast<int>(parentAlpha) * static_cast<int>(node.computedStyle().bg_alpha) + 127) / 255;
6596
6600
  }
6597
6601
 
6598
6602
  static void recordFilterBlur(int id, const Node &node, DisplayCommandType type, uint8_t parentAlpha)
6599
6603
  {
6600
- if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) <= 0)
6604
+ if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) <= 0)
6601
6605
  return;
6602
6606
  if (node.layout.width <= 0 || node.layout.height <= 0)
6603
6607
  return;
6604
6608
  const bool sourceLayerBlur = filterBlurSourceAlphaCap(node, parentAlpha) >= 0;
6605
- const int localSpread = sourceLayerBlur ? std::max(0, static_cast<int>((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0))) * kFilterBlurPasses : 0;
6609
+ const int localSpread = sourceLayerBlur ? std::max(0, static_cast<int>((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0))) * kFilterBlurPasses : 0;
6606
6610
  int16_t xs[4] = {};
6607
6611
  int16_t ys[4] = {};
6608
6612
  ViewRenderer::transformedRectCorners(node, false,
@@ -6628,9 +6632,9 @@ int gLastScrollUiFrame = -1000;
6628
6632
  }
6629
6633
  if (x0 > x1 || y0 > y1)
6630
6634
  return;
6631
- int radiusX = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
6632
- int radiusY = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
6633
- filterBlurScreenRadii(node, (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0), &radiusX, &radiusY);
6635
+ int radiusX = (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
6636
+ int radiusY = (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
6637
+ filterBlurScreenRadii(node, (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0), &radiusX, &radiusY);
6634
6638
  const int spreadX = sourceLayerBlur ? 0 : std::max(0, radiusX) * kFilterBlurPasses;
6635
6639
  const int spreadY = sourceLayerBlur ? 0 : std::max(0, radiusY) * kFilterBlurPasses;
6636
6640
  x0 -= spreadX;
@@ -6646,7 +6650,7 @@ int gLastScrollUiFrame = -1000;
6646
6650
  cmd->bw = static_cast<int16_t>(clampInt(x1 - x0 + 1, 0, 32767));
6647
6651
  cmd->bh = static_cast<int16_t>(clampInt(y1 - y0 + 1, 0, 32767));
6648
6652
  cmd->filterBlur.nodeId = static_cast<int16_t>(id);
6649
- cmd->filterBlur.radius = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
6653
+ cmd->filterBlur.radius = (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
6650
6654
  cmd->filterBlur.radiusX = static_cast<int16_t>(clampInt(radiusX, 0, 32767));
6651
6655
  cmd->filterBlur.radiusY = static_cast<int16_t>(clampInt(radiusY, 0, 32767));
6652
6656
  cmd->filterBlur.sourceAlphaCap = static_cast<int16_t>(filterBlurSourceAlphaCap(node, parentAlpha));
@@ -6689,12 +6693,12 @@ int gLastScrollUiFrame = -1000;
6689
6693
  return;
6690
6694
  }
6691
6695
  Node *n = &Tree::instance().nodes()[id];
6692
- if (n->style.display == 1 || isCollapsedFlexSubtree(*n) || ViewRenderer::backfaceSubtreeHidden(*n))
6696
+ if (n->computedStyle().display == 1 || isCollapsedFlexSubtree(*n) || ViewRenderer::backfaceSubtreeHidden(*n))
6693
6697
  {
6694
6698
  state.clearNodeRange(id);
6695
6699
  return;
6696
6700
  }
6697
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
6701
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
6698
6702
  {
6699
6703
  state.clearNodeRange(id);
6700
6704
  return;
@@ -6712,17 +6716,17 @@ int gLastScrollUiFrame = -1000;
6712
6716
  // dirty rect — same semantics as display:none, without forcing app
6713
6717
  // code to choose between the two patterns.
6714
6718
  bool contributesTextMask = false;
6715
- if (n->style.opacity == 0) {
6719
+ if (n->computedStyle().opacity == 0) {
6716
6720
  const auto *nodes = Tree::instance().nodes();
6717
6721
  for (int ancestor = id; ancestor >= 0; ancestor = nodes[ancestor].parent) {
6718
- if (isOutOfFlowPosition(nodes[ancestor].style.position)) break;
6722
+ if (isOutOfFlowPosition(nodes[ancestor].computedStyle().position)) break;
6719
6723
  const int parent = nodes[ancestor].parent;
6720
- if (parent >= 0 && StyleValues::hasTextBackgroundClip(nodes[parent].style)) {
6724
+ if (parent >= 0 && StyleValues::hasTextBackgroundClip(nodes[parent].computedStyle())) {
6721
6725
  contributesTextMask = true; break;
6722
6726
  }
6723
6727
  }
6724
6728
  }
6725
- if (n->style.opacity == 0 && !contributesTextMask)
6729
+ if (n->computedStyle().opacity == 0 && !contributesTextMask)
6726
6730
  {
6727
6731
  state.clearNodeRange(id);
6728
6732
  return;
@@ -6738,7 +6742,7 @@ int gLastScrollUiFrame = -1000;
6738
6742
  cy1 = (canvas ? canvas->height() : treeState().mountedHeight) - 1;
6739
6743
  }
6740
6744
  int overlaps_clip = isDocumentCanvasRoot(*n) || ClipMath::nodeOverlapsClip(*n, cx0, cy0, cx1, cy1);
6741
- if (!overlaps_clip && (!isViewLikeNodeType(n->type) || (overflowX(n->style) && overflowY(n->style))) &&
6745
+ if (!overlaps_clip && (!isViewLikeNodeType(n->type) || (overflowX(n->computedStyle()) && overflowY(n->computedStyle()))) &&
6742
6746
  !LayoutEngine::containsViewportFixed(id))
6743
6747
  {
6744
6748
  state.clearNodeRange(id);
@@ -6758,9 +6762,9 @@ int gLastScrollUiFrame = -1000;
6758
6762
  uint8_t cur_alpha = parent_alpha;
6759
6763
  const Node *active_mask = mask_node;
6760
6764
 
6761
- if (n->style.opacity < 255)
6765
+ if (n->computedStyle().opacity < 255)
6762
6766
  {
6763
- cur_alpha = (parent_alpha * n->style.opacity) / 255;
6767
+ cur_alpha = (parent_alpha * n->computedStyle().opacity) / 255;
6764
6768
  DisplayCommand *cmd = list.append();
6765
6769
  if (cmd)
6766
6770
  {
@@ -6775,16 +6779,16 @@ int gLastScrollUiFrame = -1000;
6775
6779
  }
6776
6780
  }
6777
6781
 
6778
- if (n->style.mask_right_fade_width > 0)
6782
+ if (n->computedStyle().mask_right_fade_width > 0)
6779
6783
  active_mask = n;
6780
6784
 
6781
6785
  int draw_start = state.commandCount;
6782
- const bool paintsOwnBox = overlaps_clip && n->style.visibility == 0;
6786
+ const bool paintsOwnBox = overlaps_clip && n->computedStyle().visibility == 0;
6783
6787
  const bool nativeTextInput = isNativeTextInputView(*n);
6784
- const bool filtered = overlaps_clip && (GEA_CSS_FILTERS ? rstyle(n->style).filter_blur_radius : 0) > 0;
6788
+ const bool filtered = overlaps_clip && (GEA_CSS_FILTERS ? rstyle(n->computedStyle()).filter_blur_radius : 0) > 0;
6785
6789
  uint8_t draw_alpha = cur_alpha;
6786
6790
  bool pushed_mask_alpha = false;
6787
- if (active_mask && active_mask->style.mask_right_fade_width > 0)
6791
+ if (active_mask && active_mask->computedStyle().mask_right_fade_width > 0)
6788
6792
  {
6789
6793
  draw_alpha = multiplyAlpha(cur_alpha, rightFadeMaskAlphaForChild(*active_mask, *n));
6790
6794
  if (draw_alpha != cur_alpha)
@@ -6857,7 +6861,7 @@ int gLastScrollUiFrame = -1000;
6857
6861
  bool dirty = insideDirty || n->render.dirty;
6858
6862
  for (int p = nodes[child].parent; p >= 0 && p != id; p = nodes[p].parent) {
6859
6863
  dirty |= nodes[p].render.dirty;
6860
- if (nodes[p].style.overflow != 0) ancestors.push_back(p);
6864
+ if (nodes[p].computedStyle().overflow != 0) ancestors.push_back(p);
6861
6865
  }
6862
6866
  std::vector<RecordClipFrame> frames;
6863
6867
  frames.reserve(ancestors.size());
@@ -6885,7 +6889,7 @@ int gLastScrollUiFrame = -1000;
6885
6889
  if (filtered && !nativeTextInput)
6886
6890
  recordFilterBlur(id, *n, DisplayCommandType::ApplyFilterBlur, cur_alpha);
6887
6891
 
6888
- if (n->style.opacity < 255)
6892
+ if (n->computedStyle().opacity < 255)
6889
6893
  {
6890
6894
  DisplayCommand *cmd = list.append();
6891
6895
  if (cmd)
@@ -6950,9 +6954,9 @@ int gLastScrollUiFrame = -1000;
6950
6954
  const std::int64_t t0 = refreshPerfNowUs();
6951
6955
  gea::platform::display::Display::fillRoundedRectBoxesRgb565(xs, ys, count, w, h, tl, tr, br, bl, colors);
6952
6956
  auto &perf = refreshPerfStatsMutable();
6953
- perf.treeReplayFillUs += refreshPerfNowUs() - t0;
6954
- perf.treeReplayRoundedRectCommands += roundedCount;
6955
- perf.treeReplayTransformedRoundedRectCommands += transformedRoundedCount;
6957
+ GEA_REFRESH_PERF(perf.treeReplayFillUs += refreshPerfNowUs() - t0);
6958
+ GEA_REFRESH_PERF(perf.treeReplayRoundedRectCommands += roundedCount);
6959
+ GEA_REFRESH_PERF(perf.treeReplayTransformedRoundedRectCommands += transformedRoundedCount);
6956
6960
  count = 0;
6957
6961
  roundedCount = 0;
6958
6962
  transformedRoundedCount = 0;
@@ -7316,7 +7320,7 @@ int gLastScrollUiFrame = -1000;
7316
7320
  if (region.x0 <= region.x1 && region.y0 <= region.y1)
7317
7321
  restoreRetainedBackgroundInRegion(region.x0, region.y0, region.x1, region.y1);
7318
7322
  }
7319
- refreshPerfStatsMutable().treeReplayBgRestoreUs += refreshPerfNowUs() - t0;
7323
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayBgRestoreUs += refreshPerfNowUs() - t0);
7320
7324
  }
7321
7325
 
7322
7326
  struct ReplayNodeWalkTimer
@@ -7324,7 +7328,7 @@ int gLastScrollUiFrame = -1000;
7324
7328
  std::int64_t start = refreshPerfNowUs();
7325
7329
  ~ReplayNodeWalkTimer()
7326
7330
  {
7327
- refreshPerfStatsMutable().treeReplayNodeWalkUs += refreshPerfNowUs() - start;
7331
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayNodeWalkUs += refreshPerfNowUs() - start);
7328
7332
  }
7329
7333
  };
7330
7334
 
@@ -7433,7 +7437,7 @@ int gLastScrollUiFrame = -1000;
7433
7437
  {
7434
7438
  DisplayCommand *c = &state.commands[ci];
7435
7439
  auto &perf = refreshPerfStatsMutable();
7436
- perf.treeReplayCommandChecks++;
7440
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
7437
7441
  if (commandMayPaintRegion(*c, x0, y0, x1, y1))
7438
7442
  return true;
7439
7443
  }
@@ -7468,7 +7472,7 @@ int gLastScrollUiFrame = -1000;
7468
7472
  if (node_id < 0 || node_id >= nodeCount)
7469
7473
  return false;
7470
7474
  const Node &node = nodes[node_id];
7471
- if (!isViewLikeNodeType(node.type) || node.style.overflow == 0)
7475
+ if (!isViewLikeNodeType(node.type) || node.computedStyle().overflow == 0)
7472
7476
  return false;
7473
7477
  if (node.first_child < 0)
7474
7478
  return false;
@@ -7488,7 +7492,7 @@ int gLastScrollUiFrame = -1000;
7488
7492
  int alpha = 255;
7489
7493
  for (int i = count - 1; i >= 0; i--)
7490
7494
  {
7491
- alpha = (alpha * static_cast<int>(nodes[chain[i]].style.opacity)) / 255;
7495
+ alpha = (alpha * static_cast<int>(nodes[chain[i]].computedStyle().opacity)) / 255;
7492
7496
  }
7493
7497
  if (alpha < 0)
7494
7498
  return 0;
@@ -7531,7 +7535,7 @@ int gLastScrollUiFrame = -1000;
7531
7535
  {
7532
7536
  DisplayCommand *c = &state.commands[ci];
7533
7537
  auto &perf = refreshPerfStatsMutable();
7534
- perf.treeReplayCommandChecks++;
7538
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
7535
7539
  // SetAlpha is a stateful scope command: it sets the alpha for the
7536
7540
  // following draws in this node's range and is restored by a matching
7537
7541
  // SetAlpha at the end of the range. It must be applied regardless of
@@ -7547,8 +7551,8 @@ int gLastScrollUiFrame = -1000;
7547
7551
  }
7548
7552
  const std::int64_t filterStartUs = refreshPerfNowUs();
7549
7553
  const bool mayPaint = commandMayPaintRegion(*c, x0, y0, x1, y1);
7550
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs;
7551
- perf.treeReplayCommandFilterCalls++;
7554
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs);
7555
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
7552
7556
  if (!mayPaint)
7553
7557
  continue;
7554
7558
  if (retainedBackgroundCommandCanBeSkippedInRegion(*c, x0, y0, x1, y1))
@@ -7571,7 +7575,7 @@ int gLastScrollUiFrame = -1000;
7571
7575
  for (int ci = start; ci < end; ci++)
7572
7576
  {
7573
7577
  DisplayCommand *c = &state.commands[ci];
7574
- refreshPerfStatsMutable().treeReplayCommandChecks++;
7578
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayCommandChecks++);
7575
7579
  if (c->type == DisplayCommandType::PushClip || c->type == DisplayCommandType::PopClip)
7576
7580
  continue;
7577
7581
  if (!commandOverlapsAnyRegion(*c, regions, count))
@@ -7642,11 +7646,11 @@ int gLastScrollUiFrame = -1000;
7642
7646
  for (int i = 0; i < nodeCount; i++)
7643
7647
  {
7644
7648
  const Node &node = nodes[i];
7645
- if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0)
7649
+ if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0)
7646
7650
  { SRDBG("blur node", i); return false; }
7647
- if (node.style.opacity != 255 && node.style.opacity != 0)
7651
+ if (node.computedStyle().opacity != 255 && node.computedStyle().opacity != 0)
7648
7652
  { SRDBG("opacity node", i); return false; }
7649
- if (node.style.mask_right_fade_width > 0)
7653
+ if (node.computedStyle().mask_right_fade_width > 0)
7650
7654
  { SRDBG("mask node", i); return false; }
7651
7655
  if (hasRetainedTransformState(node))
7652
7656
  { SRDBG("transform node", i); return false; }
@@ -7695,9 +7699,9 @@ int gLastScrollUiFrame = -1000;
7695
7699
  if (retainedBackgroundNodeCanBeSkippedInRegions(node_id, regions, count))
7696
7700
  continue;
7697
7701
  const Node &node = nodes[node_id];
7698
- if (node.style.display == 1)
7702
+ if (node.computedStyle().display == 1)
7699
7703
  continue;
7700
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7704
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7701
7705
  continue;
7702
7706
  const int start = state.nodeDrawStart[node_id];
7703
7707
  const int end = state.nodeDrawEnd[node_id];
@@ -7735,9 +7739,9 @@ int gLastScrollUiFrame = -1000;
7735
7739
  if (node_id < 0 || node_id >= nodeCount)
7736
7740
  return;
7737
7741
  const Node &node = nodes[node_id];
7738
- if (node.style.display == 1)
7742
+ if (node.computedStyle().display == 1)
7739
7743
  return;
7740
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7744
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7741
7745
  return;
7742
7746
 
7743
7747
  if (requireLayoutOverlap)
@@ -7801,9 +7805,9 @@ int gLastScrollUiFrame = -1000;
7801
7805
  if (node_id < 0 || node_id >= nodeCount)
7802
7806
  continue;
7803
7807
  const Node &node = nodes[node_id];
7804
- if (node.style.display == 1)
7808
+ if (node.computedStyle().display == 1)
7805
7809
  continue;
7806
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7810
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7807
7811
  continue;
7808
7812
 
7809
7813
  const int start = state.nodeDrawStart[node_id];
@@ -7836,9 +7840,9 @@ int gLastScrollUiFrame = -1000;
7836
7840
  roundedRects.flush();
7837
7841
  __rasterUs += refreshPerfNowUs() - __r1;
7838
7842
  auto &perf = refreshPerfStatsMutable();
7839
- perf.treeReplaySplitRasterUs += __rasterUs;
7840
- perf.treeReplaySplitDynUs += __dynUs;
7841
- perf.treeReplaySplitBgUs += (refreshPerfNowUs() - __fastStart) - __rasterUs - __dynUs;
7843
+ GEA_REFRESH_PERF(perf.treeReplaySplitRasterUs += __rasterUs);
7844
+ GEA_REFRESH_PERF(perf.treeReplaySplitDynUs += __dynUs);
7845
+ GEA_REFRESH_PERF(perf.treeReplaySplitBgUs += (refreshPerfNowUs() - __fastStart) - __rasterUs - __dynUs);
7842
7846
  }
7843
7847
 
7844
7848
  static bool simpleReplayNodeInAncestorChain(int node_id, const int *chain, int chainLen)
@@ -7872,9 +7876,9 @@ int gLastScrollUiFrame = -1000;
7872
7876
  if (simpleReplayNodeInAncestorChain(node_id, chain, chainLen))
7873
7877
  continue;
7874
7878
  const Node &node = nodes[node_id];
7875
- if (node.style.display == 1)
7879
+ if (node.computedStyle().display == 1)
7876
7880
  continue;
7877
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7881
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7878
7882
  continue;
7879
7883
  const int start = state.nodeDrawStart[node_id];
7880
7884
  const int end = state.nodeDrawEnd[node_id];
@@ -7886,7 +7890,7 @@ int gLastScrollUiFrame = -1000;
7886
7890
 
7887
7891
  static void replaySimpleClippedDirtyRegion(int x0, int y0, int x1, int y1, int origin = -1, bool allowSplit = true)
7888
7892
  {
7889
- refreshPerfStatsMutable().treeReplaySimpleRegionCalls++;
7893
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySimpleRegionCalls++);
7890
7894
  // Coarse 2-core band split, mirroring replayDirectDirtyRegion's: the
7891
7895
  // per-origin simple replay is the path a single full-screen dirty rect
7892
7896
  // takes every frame (e.g. the bouncing-balls field on a small panel),
@@ -7916,10 +7920,10 @@ int gLastScrollUiFrame = -1000;
7916
7920
  const Band *b = static_cast<const Band *>(p);
7917
7921
  replaySimpleClippedDirtyRegion(b->x0, by0, b->x1, by1, b->origin, /*allowSplit=*/false);
7918
7922
  };
7919
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
7923
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
7920
7924
  if (gea_render_parallel_submit(run, &band, mid + 1, y1))
7921
7925
  {
7922
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
7926
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
7923
7927
  replaySimpleClippedDirtyRegion(x0, y0, x1, mid, origin, /*allowSplit=*/false); // top band, this core
7924
7928
  gea_render_parallel_wait();
7925
7929
  gea_render_parallel_merge_dirty();
@@ -7958,17 +7962,17 @@ int gLastScrollUiFrame = -1000;
7958
7962
  const std::int64_t __bgStart = refreshPerfNowUs();
7959
7963
  for (int i = chainLen - 1; i >= 0; --i)
7960
7964
  replaySimpleNodeCommandsInRect(chain[i], x0, y0, x1, y1, roundedRects, false);
7961
- refreshPerfStatsMutable().treeReplaySplitBgUs += refreshPerfNowUs() - __bgStart;
7965
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitBgUs += refreshPerfNowUs() - __bgStart);
7962
7966
  const std::int64_t __dynStart = refreshPerfNowUs();
7963
7967
  if (originOrder >= 0)
7964
7968
  {
7965
7969
  for (int oi = originOrder + 1; oi < state.drawNodeOrderCount; ++oi)
7966
7970
  replaySimpleNodeCommandsInRect(state.drawNodeOrder[oi], x0, y0, x1, y1, roundedRects, true);
7967
7971
  }
7968
- refreshPerfStatsMutable().treeReplaySplitDynUs += refreshPerfNowUs() - __dynStart;
7972
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitDynUs += refreshPerfNowUs() - __dynStart);
7969
7973
  const std::int64_t __rasterStart = refreshPerfNowUs();
7970
7974
  roundedRects.flush();
7971
- refreshPerfStatsMutable().treeReplaySplitRasterUs += refreshPerfNowUs() - __rasterStart;
7975
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitRasterUs += refreshPerfNowUs() - __rasterStart);
7972
7976
  return;
7973
7977
  }
7974
7978
  }
@@ -7989,9 +7993,9 @@ int gLastScrollUiFrame = -1000;
7989
7993
  if (retainedBackgroundNodeCanBeSkippedInRegion(node_id, x0, y0, x1, y1))
7990
7994
  continue;
7991
7995
  const Node &node = nodes[node_id];
7992
- if (node.style.display == 1)
7996
+ if (node.computedStyle().display == 1)
7993
7997
  continue;
7994
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7998
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7995
7999
  continue;
7996
8000
 
7997
8001
  const int nx0 = node.layout.x;
@@ -8009,13 +8013,13 @@ int gLastScrollUiFrame = -1000;
8009
8013
  {
8010
8014
  DisplayCommand *c = &state.commands[ci];
8011
8015
  auto &perf = refreshPerfStatsMutable();
8012
- perf.treeReplayCommandChecks++;
8016
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
8013
8017
  if (c->type == DisplayCommandType::PushClip || c->type == DisplayCommandType::PopClip)
8014
8018
  continue;
8015
8019
  const std::int64_t filterStartUs = refreshPerfNowUs();
8016
8020
  const bool mayPaint = commandMayPaintRegion(*c, x0, y0, x1, y1);
8017
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs;
8018
- perf.treeReplayCommandFilterCalls++;
8021
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs);
8022
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
8019
8023
  if (!mayPaint)
8020
8024
  continue;
8021
8025
  if (retainedBackgroundCommandCanBeSkippedInRegion(*c, x0, y0, x1, y1))
@@ -8110,9 +8114,9 @@ int gLastScrollUiFrame = -1000;
8110
8114
  if (node_id < 0 || node_id >= tree.nodeCount())
8111
8115
  continue;
8112
8116
  Node *n = &nodes[node_id];
8113
- if (n->style.display == 1)
8117
+ if (n->computedStyle().display == 1)
8114
8118
  continue;
8115
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8119
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8116
8120
  continue;
8117
8121
  const int start = state.nodeDrawStart[node_id];
8118
8122
  const int end = state.nodeDrawEnd[node_id];
@@ -8166,9 +8170,9 @@ int gLastScrollUiFrame = -1000;
8166
8170
  if (node_id < 0 || node_id >= tree.nodeCount())
8167
8171
  continue;
8168
8172
  Node *n = &nodes[node_id];
8169
- if (n->style.display == 1)
8173
+ if (n->computedStyle().display == 1)
8170
8174
  continue;
8171
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8175
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8172
8176
  continue;
8173
8177
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8174
8178
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -8231,9 +8235,9 @@ int gLastScrollUiFrame = -1000;
8231
8235
  if (node_id < 0 || node_id >= tree.nodeCount())
8232
8236
  continue;
8233
8237
  Node *n = &nodes[node_id];
8234
- if (n->style.display == 1)
8238
+ if (n->computedStyle().display == 1)
8235
8239
  continue;
8236
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8240
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8237
8241
  continue;
8238
8242
  if (nodeOrAncestorRenderDirty(node_id, nodes, tree.nodeCount()))
8239
8243
  continue; // dynamic — not baked
@@ -8262,7 +8266,7 @@ int gLastScrollUiFrame = -1000;
8262
8266
 
8263
8267
  static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegion(int x0, int y0, int x1, int y1, int origin = -1, bool allowSplit = true)
8264
8268
  {
8265
- refreshPerfStatsMutable().treeReplayDirectRegionCalls++;
8269
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayDirectRegionCalls++);
8266
8270
  // Coarse 2-core split (ONE dispatch/frame). The worker core replays the bottom
8267
8271
  // row-band into its own band-canvas (private clip + dirty over the SAME
8268
8272
  // framebuffer — all DisplayBackend draw methods route through replayCanvas() so
@@ -8290,11 +8294,11 @@ int gLastScrollUiFrame = -1000;
8290
8294
  const Band *b = static_cast<const Band *>(p);
8291
8295
  replayDirectDirtyRegion(b->x0, by0, b->x1, by1, b->origin, /*allowSplit=*/false);
8292
8296
  };
8293
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
8297
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
8294
8298
  const bool __submitOk = gea_render_parallel_submit(run, &band, mid + 1, y1);
8295
8299
  if (__submitOk)
8296
8300
  {
8297
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
8301
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
8298
8302
  replayDirectDirtyRegion(x0, y0, x1, mid, origin, /*allowSplit=*/false); // top band, this core
8299
8303
  gea_render_parallel_wait();
8300
8304
  gea_render_parallel_merge_dirty();
@@ -8353,9 +8357,9 @@ int gLastScrollUiFrame = -1000;
8353
8357
  if (node_id < 0 || node_id >= nodeCount)
8354
8358
  continue;
8355
8359
  Node *n = &nodes[node_id];
8356
- if (n->style.display == 1)
8360
+ if (n->computedStyle().display == 1)
8357
8361
  continue;
8358
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8362
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8359
8363
  continue;
8360
8364
  if (!state.hasNodeScratchFor(node_id))
8361
8365
  continue;
@@ -8436,11 +8440,6 @@ int gLastScrollUiFrame = -1000;
8436
8440
  const int node_id = state.drawNodeOrder[oi];
8437
8441
  if (node_id < 0 || node_id >= nodeCount)
8438
8442
  continue;
8439
- Node *n = &nodes[node_id];
8440
- if (n->style.display == 1)
8441
- continue;
8442
- if (n->style.blink_interval_ms > 0)
8443
- continue;
8444
8443
  if (!state.hasNodeScratchFor(node_id))
8445
8444
  continue;
8446
8445
  const int start = state.nodeDrawStart[node_id];
@@ -8463,6 +8462,12 @@ int gLastScrollUiFrame = -1000;
8463
8462
  // any recording that paints less than the command rect suggests).
8464
8463
  if (c.bx > x0 || c.by > y0 || c.bx + c.bw - 1 < x1 || c.by + c.bh - 1 < y1)
8465
8464
  continue;
8465
+ // Read node state only for a command large enough to cover the region.
8466
+ Node *n = &nodes[node_id];
8467
+ if (n->computedStyle().display == 1)
8468
+ continue;
8469
+ if (n->computedStyle().blink_interval_ms > 0)
8470
+ continue;
8466
8471
  if (effectiveAlphaForNode(node_id, nodes, nodeCount) != 255)
8467
8472
  continue;
8468
8473
  bool clipped = false;
@@ -8514,9 +8519,9 @@ int gLastScrollUiFrame = -1000;
8514
8519
  if (node_id < 0 || node_id >= tree.nodeCount())
8515
8520
  continue;
8516
8521
  Node *n = &nodes[node_id];
8517
- if (n->style.display == 1)
8522
+ if (n->computedStyle().display == 1)
8518
8523
  continue;
8519
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8524
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8520
8525
  continue;
8521
8526
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8522
8527
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -8553,16 +8558,16 @@ int gLastScrollUiFrame = -1000;
8553
8558
  {
8554
8559
  const std::int64_t t0 = refreshPerfNowUs();
8555
8560
  auto &perf = refreshPerfStatsMutable();
8556
- perf.treeReplayCommandFilterCalls++;
8561
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
8557
8562
  for (int ri = 0; ri < count; ri++)
8558
8563
  {
8559
8564
  if (commandOverlapsRegion(c, regions[ri]))
8560
8565
  {
8561
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8566
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8562
8567
  return true;
8563
8568
  }
8564
8569
  }
8565
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8570
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8566
8571
  return false;
8567
8572
  }
8568
8573
 
@@ -8570,16 +8575,16 @@ int gLastScrollUiFrame = -1000;
8570
8575
  {
8571
8576
  const std::int64_t t0 = refreshPerfNowUs();
8572
8577
  auto &perf = refreshPerfStatsMutable();
8573
- perf.treeReplayCommandFilterCalls++;
8578
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
8574
8579
  for (int ri = 0; ri < count; ri++)
8575
8580
  {
8576
8581
  if (commandContainedInRegion(c, regions[ri]))
8577
8582
  {
8578
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8583
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8579
8584
  return true;
8580
8585
  }
8581
8586
  }
8582
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8587
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8583
8588
  return false;
8584
8589
  }
8585
8590
 
@@ -8602,7 +8607,7 @@ int gLastScrollUiFrame = -1000;
8602
8607
  y1 = region.y1;
8603
8608
  if (x0 > x1 || y0 > y1)
8604
8609
  return true;
8605
- refreshPerfStatsMutable().treeReplayFillRectCommands++;
8610
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayFillRectCommands++);
8606
8611
  gea::platform::display::Display::fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, c.fill.color);
8607
8612
  return true;
8608
8613
  }
@@ -8614,7 +8619,7 @@ int gLastScrollUiFrame = -1000;
8614
8619
  return false;
8615
8620
  if (!regionInsideRetainedBackground(c, x0, y0, x1, y1))
8616
8621
  return false;
8617
- refreshPerfStatsMutable().treeReplayRoundedRectCommands++;
8622
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayRoundedRectCommands++);
8618
8623
  gea::platform::display::Display::fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, c.fillRoundedRect.color);
8619
8624
  return true;
8620
8625
  }
@@ -8623,32 +8628,32 @@ int gLastScrollUiFrame = -1000;
8623
8628
  {
8624
8629
  const std::int64_t t0 = refreshPerfNowUs();
8625
8630
  auto &perf = refreshPerfStatsMutable();
8626
- perf.treeReplayCommandClipCalls++;
8631
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipCalls++);
8627
8632
  if (!commandOverlapsRegion(c, region))
8628
8633
  {
8629
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8634
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8630
8635
  return;
8631
8636
  }
8632
8637
  if (retainedBackgroundCommandCanBeSkippedInRegion(c, region.x0, region.y0, region.x1, region.y1))
8633
8638
  {
8634
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8639
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8635
8640
  return;
8636
8641
  }
8637
8642
  if (replayFillRectInRegion(c, region))
8638
8643
  {
8639
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8644
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8640
8645
  return;
8641
8646
  }
8642
8647
  if (replayContainedRoundedRectFillInRegion(c, region.x0, region.y0, region.x1, region.y1))
8643
8648
  {
8644
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8649
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8645
8650
  return;
8646
8651
  }
8647
8652
  gea::platform::display::Display::pushClip(region.x0, region.y0,
8648
8653
  region.x1 - region.x0 + 1, region.y1 - region.y0 + 1);
8649
8654
  DisplayCommandDrawer::replay(c);
8650
8655
  gea::platform::display::Display::popClip();
8651
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8656
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8652
8657
  }
8653
8658
 
8654
8659
  static bool commandRangeOverlapsAnyRegion(int start, int end, const DisplayReplayRegion *regions, int count)
@@ -8700,7 +8705,7 @@ int gLastScrollUiFrame = -1000;
8700
8705
  for (int ci = start; ci < end; ci++)
8701
8706
  {
8702
8707
  DisplayCommand *c = &state.commands[ci];
8703
- refreshPerfStatsMutable().treeReplayCommandChecks++;
8708
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayCommandChecks++);
8704
8709
  if (c->type == DisplayCommandType::SetAlpha)
8705
8710
  {
8706
8711
  roundedRects.flush();
@@ -8734,7 +8739,7 @@ int gLastScrollUiFrame = -1000;
8734
8739
 
8735
8740
  static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count, bool allowSplit = true)
8736
8741
  {
8737
- refreshPerfStatsMutable().treeReplayDirectRegionsCalls++;
8742
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayDirectRegionsCalls++);
8738
8743
  if (!regions || count <= 0)
8739
8744
  return;
8740
8745
  auto *canvas = gea::platform::display::Display::canvas();
@@ -8830,10 +8835,10 @@ int gLastScrollUiFrame = -1000;
8830
8835
  const Ctx *c = static_cast<const Ctx *>(p);
8831
8836
  replayDirectDirtyRegions(c->regions, c->count, /*allowSplit=*/false);
8832
8837
  };
8833
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
8838
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
8834
8839
  if (gea_render_parallel_submit(run, &ctx, mid + 1, maxY))
8835
8840
  {
8836
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
8841
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
8837
8842
  replayDirectDirtyRegions(topR, count, /*allowSplit=*/false); // top band, this core
8838
8843
  gea_render_parallel_wait();
8839
8844
  gea_render_parallel_merge_dirty();
@@ -8879,9 +8884,9 @@ int gLastScrollUiFrame = -1000;
8879
8884
  if (!useBackdrop && retainedBackgroundNodeCanBeSkippedInRegions(node_id, regions, count))
8880
8885
  continue;
8881
8886
  Node *n = &nodes[node_id];
8882
- if (n->style.display == 1)
8887
+ if (n->computedStyle().display == 1)
8883
8888
  continue;
8884
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8889
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8885
8890
  continue;
8886
8891
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8887
8892
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -9076,10 +9081,10 @@ int gLastScrollUiFrame = -1000;
9076
9081
  {
9077
9082
  const auto *nodes = Tree::instance().nodes();
9078
9083
  const auto &n = nodes[id];
9079
- const bool item = n.parent >= 0 && !isOutOfFlowPosition(n.style.position) &&
9080
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
9081
- return n.parent < 0 || n.style.position == kPositionFixed || ChildZSorter::effectGroup(n) ||
9082
- (!n.style.z_index_auto && (n.style.position != 0 || item));
9084
+ const bool item = n.parent >= 0 && !isOutOfFlowPosition(n.computedStyle().position) &&
9085
+ (nodes[n.parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[n.parent].computedStyle()));
9086
+ return n.parent < 0 || n.computedStyle().position == kPositionFixed || ChildZSorter::effectGroup(n) ||
9087
+ (!n.computedStyle().z_index_auto && (n.computedStyle().position != 0 || item));
9083
9088
  }
9084
9089
 
9085
9090
  bool PaintOrder::isGroup(int id)
@@ -9087,8 +9092,8 @@ int gLastScrollUiFrame = -1000;
9087
9092
  const auto *nodes = Tree::instance().nodes();
9088
9093
  const auto &n = nodes[id];
9089
9094
  const bool item = n.parent >= 0 &&
9090
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
9091
- return isContext(id) || n.style.position != 0 || n.style.float_side || item;
9095
+ (nodes[n.parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[n.parent].computedStyle()));
9096
+ return isContext(id) || n.computedStyle().position != 0 || n.computedStyle().float_side || item;
9092
9097
  }
9093
9098
 
9094
9099
  std::vector<int> PaintOrder::collectChildren(int root, bool groupRoot, bool includePositioned)
@@ -9104,18 +9109,18 @@ int gLastScrollUiFrame = -1000;
9104
9109
  auto walk = [&](auto &&self, int parent, bool withinGroup) -> void {
9105
9110
  std::vector<int> children;
9106
9111
  for (int child = nodes[parent].first_child; child >= 0; child = nodes[child].next_sibling)
9107
- if (!isDisplayNone(nodes[child].style)) children.push_back(child);
9108
- if (nodes[parent].style.display == kDisplayFlex || isDisplayGrid(nodes[parent].style)) {
9112
+ if (!isDisplayNone(nodes[child].computedStyle())) children.push_back(child);
9113
+ if (nodes[parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[parent].computedStyle())) {
9109
9114
  std::stable_sort(children.begin(), children.end(), [&](int a, int b) {
9110
- const int oa = isOutOfFlowPosition(nodes[a].style.position) ? 0 : nodes[a].style.order;
9111
- const int ob = isOutOfFlowPosition(nodes[b].style.position) ? 0 : nodes[b].style.order;
9115
+ const int oa = isOutOfFlowPosition(nodes[a].computedStyle().position) ? 0 : nodes[a].computedStyle().order;
9116
+ const int ob = isOutOfFlowPosition(nodes[b].computedStyle().position) ? 0 : nodes[b].computedStyle().order;
9112
9117
  return oa < ob;
9113
9118
  });
9114
9119
  }
9115
9120
  for (int child : children) {
9116
9121
  const auto &n = nodes[child];
9117
- if (n.style.blink_interval_ms > 0 && !n.style.blink_visible) continue;
9118
- const bool context = isContext(child), positioned = n.style.position != 0 || context;
9122
+ if (n.computedStyle().blink_interval_ms > 0 && !n.computedStyle().blink_visible) continue;
9123
+ const bool context = isContext(child), positioned = n.computedStyle().position != 0 || context;
9119
9124
  const bool group = isGroup(child);
9120
9125
  if (positioned) {
9121
9126
  if (includePositioned) result.push_back(child);
@@ -9507,7 +9512,7 @@ int gLastScrollUiFrame = -1000;
9507
9512
  for (int i = 0; i < state.drawNodeOrderCount; ++i)
9508
9513
  if (state.drawNodeOrder[i] < 0 || state.drawNodeOrder[i] >= nodeCount) return false;
9509
9514
  for (int id = 0; id < nodeCount; ++id) {
9510
- if (!nodes[id].style.backface_hidden || !ViewRenderer::isTransformableBox(nodes[id]) || preserves3D(nodes[id].style)) continue;
9515
+ if (!nodes[id].computedStyle().backface_hidden || !ViewRenderer::isTransformableBox(nodes[id]) || preserves3D(nodes[id].computedStyle())) continue;
9511
9516
  const bool wasRecorded = state.nodeDrawStart[id] >= 0;
9512
9517
  if (wasRecorded == ViewRenderer::backfaceSubtreeHidden(nodes[id])) return false;
9513
9518
  }
@@ -9868,9 +9873,9 @@ int gLastScrollUiFrame = -1000;
9868
9873
 
9869
9874
  for (int i = 0; i < tree.nodeCount(); i++)
9870
9875
  {
9871
- if ((GEA_CSS_FILTERS ? rstyle(nodes[i].style).filter_blur_radius : 0) > 0)
9876
+ if ((GEA_CSS_FILTERS ? rstyle(nodes[i].computedStyle()).filter_blur_radius : 0) > 0)
9872
9877
  return false;
9873
- if (nodes[i].style.overflow == 2)
9878
+ if (nodes[i].computedStyle().overflow == 2)
9874
9879
  return false;
9875
9880
  }
9876
9881
  (void)width;
@@ -9987,12 +9992,18 @@ int gLastScrollUiFrame = -1000;
9987
9992
  for (int ci = start; ci < end; ci++)
9988
9993
  DisplayCommandTranslator::translate(&state.commands[ci], dx, dy);
9989
9994
  }
9995
+ // recordClipBegin never emits a scope for a leaf. Avoid scanning the
9996
+ // entire command list for every independently moving leaf.
9997
+ if (Tree::instance().nodes()[node].first_child < 0) return;
9990
9998
  // PushClip/PopClip wrap the node's descendants, so recordNode deliberately
9991
9999
  // emits them outside [nodeDrawStart,nodeDrawEnd]. Move those retained scope
9992
10000
  // commands explicitly; otherwise a translated overflow:hidden subtree is
9993
10001
  // intersected with the clip at its old position.
9994
10002
  for (int ci = 0; ci < state.commandCount; ci++)
9995
10003
  {
10004
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
10005
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeTranslateClipChecks++);
10006
+ #endif
9996
10007
  DisplayCommand &command = state.commands[ci];
9997
10008
  if ((command.type == DisplayCommandType::PushClip || command.type == DisplayCommandType::PopClip) &&
9998
10009
  command.clip.nodeId == node)
@@ -10120,7 +10131,7 @@ int gLastScrollUiFrame = -1000;
10120
10131
  for (int a = LayoutEngine::isViewportFixed(nodes[id]) ? -1 : nodes[id].parent; a >= 0 && a < nodeCount; a = nodes[a].parent)
10121
10132
  {
10122
10133
  const Node &ancestor = nodes[a];
10123
- if (!isViewLikeNodeType(ancestor.type) || ancestor.style.overflow == 0 || ancestor.first_child < 0)
10134
+ if (!isViewLikeNodeType(ancestor.type) || ancestor.computedStyle().overflow == 0 || ancestor.first_child < 0)
10124
10135
  {
10125
10136
  if (LayoutEngine::isViewportFixed(ancestor)) break;
10126
10137
  continue;
@@ -10186,8 +10197,8 @@ int gLastScrollUiFrame = -1000;
10186
10197
  continue;
10187
10198
  const Node &probe = nodes[id];
10188
10199
  const bool paintsBox =
10189
- (probe.style.has_bg && (probe.style.bg_alpha > 0 || styleHasBackgroundImage(probe.style))) ||
10190
- (GEA_CSS_BOX_SHADOW ? rstyle(probe.style).box_shadow_alpha : 0) > 0;
10200
+ (probe.computedStyle().has_bg && (probe.computedStyle().bg_alpha > 0 || styleHasBackgroundImage(probe.computedStyle()))) ||
10201
+ (GEA_CSS_BOX_SHADOW ? rstyle(probe.computedStyle()).box_shadow_alpha : 0) > 0;
10191
10202
  if (!paintsBox)
10192
10203
  continue;
10193
10204
  }
@@ -10213,8 +10224,8 @@ int gLastScrollUiFrame = -1000;
10213
10224
  for (int cursor = id; cursor >= 0 && cursor < tree.nodeCount(); cursor = nodes[cursor].parent)
10214
10225
  {
10215
10226
  const Node &a = nodes[cursor];
10216
- if (a.style.display == 1 || a.style.opacity == 0 ||
10217
- (a.style.blink_interval_ms > 0 && !a.style.blink_visible))
10227
+ if (a.computedStyle().display == 1 || a.computedStyle().opacity == 0 ||
10228
+ (a.computedStyle().blink_interval_ms > 0 && !a.computedStyle().blink_visible))
10218
10229
  {
10219
10230
  hiddenOrOutside = true;
10220
10231
  break;
@@ -10235,11 +10246,23 @@ int gLastScrollUiFrame = -1000;
10235
10246
  bool DisplayList::patchNodeAlpha(int node, uint8_t opacity)
10236
10247
  {
10237
10248
  // The OPEN SetAlpha wrapping a node's subtree lives OUTSIDE the node's
10238
- // [drawStart,drawEnd] range, so scan by the nodeId tag recordNode stamped on
10239
- // it. Recompute from the record-time parent alpha so nested scopes stay
10249
+ // [drawStart,drawEnd] range, immediately before drawStart. Recompute
10250
+ // from the record-time parent alpha so nested scopes stay
10240
10251
  // correct: alpha = recordParentAlpha * opacity / 255.
10241
10252
  if (!state.commands || node < 0 || node >= Tree::instance().nodeCount())
10242
10253
  return false;
10254
+ // Reuse the existing range index. Scanning the entire retained list for
10255
+ // each fading leaf makes an N-lamp animation quadratic in command count.
10256
+ if (state.hasNodeScratchFor(node)) {
10257
+ const int ci = state.nodeDrawStart[node] - 1;
10258
+ if (ci >= 0 && ci < state.commandCount) {
10259
+ auto &command = state.commands[ci];
10260
+ if (command.type == DisplayCommandType::SetAlpha && command.alpha.nodeId == node) {
10261
+ command.alpha.alpha = static_cast<uint8_t>((static_cast<int>(command.alpha.recordParentAlpha) * opacity) / 255);
10262
+ return true;
10263
+ }
10264
+ }
10265
+ }
10243
10266
  for (int ci = 0; ci < state.commandCount; ci++)
10244
10267
  {
10245
10268
  DisplayCommand *c = &state.commands[ci];
@@ -10382,9 +10405,9 @@ int gLastScrollUiFrame = -1000;
10382
10405
  if (paintNode < 0 || paintNode >= nodeCount)
10383
10406
  continue;
10384
10407
  const Node &paint = nodes[paintNode];
10385
- if (paint.style.display == 1)
10408
+ if (paint.computedStyle().display == 1)
10386
10409
  continue;
10387
- if (paint.style.blink_interval_ms > 0 && !paint.style.blink_visible)
10410
+ if (paint.computedStyle().blink_interval_ms > 0 && !paint.computedStyle().blink_visible)
10388
10411
  continue;
10389
10412
  DisplayCommandReplayer::replayNodeCommandRangeInRegions(paintNode, &region, 1, roundedRects);
10390
10413
  }
@@ -11207,9 +11230,9 @@ int gLastScrollUiFrame = -1000;
11207
11230
  if (nodeId < 0 || nodeId >= tree.nodeCount())
11208
11231
  continue;
11209
11232
  const Node &node = nodes[nodeId];
11210
- if (node.style.display == 1)
11233
+ if (node.computedStyle().display == 1)
11211
11234
  continue;
11212
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
11235
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
11213
11236
  continue;
11214
11237
  if (!state.hasNodeScratchFor(nodeId))
11215
11238
  continue;
@@ -11902,9 +11925,9 @@ int gLastScrollUiFrame = -1000;
11902
11925
  const int dirtyY0 = dMain.y0;
11903
11926
  const int dirtyX1 = dMain.x1;
11904
11927
  const int dirtyY1 = dMain.y1;
11905
- refreshPerfStatsMutable().treeBgRecolorFastPixels += dMain.fastPixels;
11906
- refreshPerfStatsMutable().treeBgRecolorFillUs += dMain.fillUs;
11907
- refreshPerfStatsMutable().treeBgRecolorEdgeUs += dMain.edgeUs;
11928
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorFastPixels += dMain.fastPixels);
11929
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorFillUs += dMain.fillUs);
11930
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorEdgeUs += dMain.edgeUs);
11908
11931
  if (dirtyX0 > dirtyX1 || dirtyY0 > dirtyY1)
11909
11932
  return false;
11910
11933
  canvas->markDirty(dirtyX0, dirtyY0, dirtyX1, dirtyY1);
@@ -11917,9 +11940,9 @@ int gLastScrollUiFrame = -1000;
11917
11940
  if (!replayLaterOverlappingCommands(node, region))
11918
11941
  return false;
11919
11942
  replayUs = refreshPerfNowUs() - replayStartUs;
11920
- refreshPerfStatsMutable().treeBgRecolorReplayUs += replayUs;
11943
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorReplayUs += replayUs);
11921
11944
  }
11922
- refreshPerfStatsMutable().treeBgRecolorUs += refreshPerfNowUs() - totalStartUs;
11945
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorUs += refreshPerfNowUs() - totalStartUs);
11923
11946
  if (outX0)
11924
11947
  *outX0 = dirtyX0;
11925
11948
  if (outY0)
@@ -12223,9 +12246,9 @@ int gLastScrollUiFrame = -1000;
12223
12246
  if (nodeId < 0 || nodeId >= tree.nodeCount())
12224
12247
  continue;
12225
12248
  const Node &n = nodes[nodeId];
12226
- if (n.style.display == 1)
12249
+ if (n.computedStyle().display == 1)
12227
12250
  continue;
12228
- if (n.style.blink_interval_ms > 0 && !n.style.blink_visible)
12251
+ if (n.computedStyle().blink_interval_ms > 0 && !n.computedStyle().blink_visible)
12229
12252
  continue;
12230
12253
  if (!state.hasNodeScratchFor(nodeId))
12231
12254
  continue;
@@ -12318,10 +12341,10 @@ int gLastScrollUiFrame = -1000;
12318
12341
  // an empty range, which `old_len == 0 && tmp_len > 0` below (correctly) refuses
12319
12342
  // to splice — and the refusal cost the whole frame its retained display list.
12320
12343
  const bool outsideRecordClip = !isDocumentCanvasRoot(*n) && nodeOutsideRecordClip(node, tree.mountedWidth(), tree.mountedHeight());
12321
- if (!outsideRecordClip && n->style.visibility == 0 && !isCollapsedFlexSubtree(*n) && !ViewRenderer::backfaceSubtreeHidden(*n) &&
12322
- n->style.display != 1 &&
12323
- n->style.opacity != 0 &&
12324
- !(n->style.blink_interval_ms > 0 && !n->style.blink_visible) &&
12344
+ if (!outsideRecordClip && n->computedStyle().visibility == 0 && !isCollapsedFlexSubtree(*n) && !ViewRenderer::backfaceSubtreeHidden(*n) &&
12345
+ n->computedStyle().display != 1 &&
12346
+ n->computedStyle().opacity != 0 &&
12347
+ !(n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible) &&
12325
12348
  !isNativeTextInputView(*n))
12326
12349
  {
12327
12350
  ViewRenderer::recordBox(*n);
@@ -12389,7 +12412,7 @@ int gLastScrollUiFrame = -1000;
12389
12412
 
12390
12413
  // Mirror of ViewRenderer::recordScrollbar's geometry. Cases where no
12391
12414
  // thumb is ever recorded are a successful no-op, not a failure.
12392
- if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->style)))
12415
+ if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->computedStyle())))
12393
12416
  return true;
12394
12417
  if (n->layout.height <= 0 || n->layout.scroll_content_height <= n->layout.height)
12395
12418
  return true;
@@ -12459,7 +12482,10 @@ int gLastScrollUiFrame = -1000;
12459
12482
  const int root = tree.mountedRoot();
12460
12483
  if (root >= 0 && root < tree.nodeCount() && isDocumentCanvasRoot(tree.nodes()[root]))
12461
12484
  DisplayCommandReplayer::restoreClearBaseInRegion(x0, y0, x1, y1);
12462
- DisplayCommandReplayer::replaySimpleClippedDirtyRegion(x0, y0, x1, y1, origin);
12485
+ // The caller owns the active clip and may have rebound the canvas onto a DMA
12486
+ // chunk. The worker canvas has neither that binding nor the clip, so this
12487
+ // already-clipped entry must stay on the submitting canvas.
12488
+ DisplayCommandReplayer::replaySimpleClippedDirtyRegion(x0, y0, x1, y1, origin, /*allowSplit=*/false);
12463
12489
  }
12464
12490
 
12465
12491
  void DisplayList::maybeBakeStaticBackdrop(int width, int height, bool stableThisFrame, bool directReplay,