@geastack/engine 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ui/render.cpp CHANGED
@@ -1,4 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
+ #include "renderer_features.h"
2
3
  #include "internal.h"
3
4
  #include "state_init.h"
4
5
  #include "canvas.h"
@@ -268,14 +269,14 @@ int gLastScrollUiFrame = -1000;
268
269
  #define GEA_EMBEDDED_RECOLOR_PIXEL_CACHE_SIZE 512
269
270
  #endif
270
271
 
271
- constexpr int kTransformedGradientLutSlots = GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_SLOTS;
272
+ constexpr int kTransformedGradientLutSlots = (GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS) ? GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_SLOTS : 1;
272
273
  static_assert(kTransformedGradientLutSlots > 0);
273
- constexpr int kTransformedGradientLutBanks = GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_BANKS;
274
+ constexpr int kTransformedGradientLutBanks = (GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS) ? GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_BANKS : 1;
274
275
  static_assert(kTransformedGradientLutBanks > 0);
275
276
  constexpr bool kTransformedGradientA5Mirror = GEA_EMBEDDED_TRANSFORMED_GRADIENT_A5_MIRROR != 0;
276
- 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,
277
278
  "GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER requires the transformed-gradient a5 mirror");
278
- constexpr int kProjectedTextCacheBanks = GEA_EMBEDDED_PROJECTED_TEXT_CACHE_BANKS;
279
+ constexpr int kProjectedTextCacheBanks = GEA_EMBEDDED_RENDERER_TRANSFORMS ? GEA_EMBEDDED_PROJECTED_TEXT_CACHE_BANKS : 1;
279
280
  static_assert(kProjectedTextCacheBanks > 0);
280
281
  constexpr int kScratchDepth = 16;
281
282
  constexpr int kFilterBlurPasses = 5;
@@ -849,7 +850,7 @@ int gLastScrollUiFrame = -1000;
849
850
 
850
851
  uint8_t rightFadeMaskAlphaForChild(const Node &parent, const Node &child)
851
852
  {
852
- const int fade = parent.style.mask_right_fade_width;
853
+ const int fade = parent.computedStyle().mask_right_fade_width;
853
854
  if (fade <= 0 || parent.layout.width <= 0)
854
855
  return 255;
855
856
  if (child.layout.width <= 0 || child.layout.height <= 0)
@@ -1346,9 +1347,9 @@ int gLastScrollUiFrame = -1000;
1346
1347
  {
1347
1348
  return node.first_child < 0 &&
1348
1349
  node.type == NodeType::View &&
1349
- node.style.has_bg &&
1350
- !styleHasBackgroundImage(node.style) && rstyle(node.style).bg_clip == 0 &&
1351
- !hasAnyBorder(node.style);
1350
+ node.computedStyle().has_bg &&
1351
+ !styleHasBackgroundImage(node.computedStyle()) && rstyle(node.computedStyle()).bg_clip == 0 &&
1352
+ !hasAnyBorder(node.computedStyle());
1352
1353
  }
1353
1354
 
1354
1355
  bool isFullyRoundedFilterShape(const Node &node)
@@ -1356,10 +1357,10 @@ int gLastScrollUiFrame = -1000;
1356
1357
  const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
1357
1358
  const int minRadius = std::max(1, halfMin - 1);
1358
1359
  return halfMin > 0 &&
1359
- node.style.border_radius[0] >= minRadius &&
1360
- node.style.border_radius[1] >= minRadius &&
1361
- node.style.border_radius[2] >= minRadius &&
1362
- node.style.border_radius[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;
1363
1364
  }
1364
1365
 
1365
1366
  bool screenToNodeRectHomography(const Node &node, double out[8])
@@ -1640,8 +1641,8 @@ int gLastScrollUiFrame = -1000;
1640
1641
  const std::int64_t t0 = refreshPerfNowUs();
1641
1642
  gea::platform::display::Display::fillCircle(cx, cy, radius, color);
1642
1643
  auto &perf = refreshPerfStatsMutable();
1643
- perf.treeReplayCircleCommands++;
1644
- perf.treeReplayCircleUs += refreshPerfNowUs() - t0;
1644
+ GEA_REFRESH_PERF(perf.treeReplayCircleCommands++);
1645
+ GEA_REFRESH_PERF(perf.treeReplayCircleUs += refreshPerfNowUs() - t0);
1645
1646
  return true;
1646
1647
  }
1647
1648
 
@@ -2010,8 +2011,8 @@ int gLastScrollUiFrame = -1000;
2010
2011
  return nx * nx + ny * ny <= 1.0;
2011
2012
  }
2012
2013
 
2013
- const double radius = static_cast<double>(std::min(std::min(node.style.border_radius[0], node.style.border_radius[1]),
2014
- std::min(node.style.border_radius[2], node.style.border_radius[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)])));
2015
2016
  const double r = std::max(0.0, std::min(radius, std::min(w, h) * 0.5));
2016
2017
  if (r <= 0.0)
2017
2018
  return true;
@@ -2125,7 +2126,7 @@ int gLastScrollUiFrame = -1000;
2125
2126
  const double ry = h * 0.5;
2126
2127
  if (rx <= 0.0 || ry <= 0.0)
2127
2128
  return 0;
2128
- const double blur = std::max(1.0, static_cast<double>(rstyle(node.style).filter_blur_radius));
2129
+ const double blur = std::max(1.0, static_cast<double>((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0)));
2129
2130
  const double dx = std::fabs(sx - (x + rx));
2130
2131
  const double dy = std::fabs(sy - (y + ry));
2131
2132
  const double alphaX = 1.0 - smoothStep(rx, rx + blur * 2.0, dx);
@@ -2219,7 +2220,7 @@ int gLastScrollUiFrame = -1000;
2219
2220
  continue;
2220
2221
  const int index = row * screenW + col;
2221
2222
  cache.alpha[index] = static_cast<std::uint8_t>(alpha);
2222
- cache.pixels[index] = node.style.bg_color;
2223
+ cache.pixels[index] = node.computedStyle().bg_color;
2223
2224
  }
2224
2225
  }
2225
2226
 
@@ -2342,7 +2343,7 @@ int gLastScrollUiFrame = -1000;
2342
2343
  continue;
2343
2344
  const int index = row * w + col;
2344
2345
  cache.alpha[index] = static_cast<std::uint8_t>((coverage * sourceAlpha + 127) / 255);
2345
- cache.pixels[index] = node.style.bg_color;
2346
+ cache.pixels[index] = node.computedStyle().bg_color;
2346
2347
  }
2347
2348
  }
2348
2349
 
@@ -2743,9 +2744,10 @@ int gLastScrollUiFrame = -1000;
2743
2744
  // thread). Falls back to the per-pixel scan if the label is implausibly large.
2744
2745
  const int srcW = command.projectedText.srcW;
2745
2746
  const int srcH = command.projectedText.srcH;
2746
- const bool useBuffer = static_cast<long long>(srcW) * static_cast<long long>(srcH) <= (1LL << 19);
2747
2747
  const std::uint8_t *cb = nullptr;
2748
2748
  int inkX0 = 0, inkY0 = 0, inkX1 = srcW - 1, inkY1 = srcH - 1;
2749
+ const bool useBuffer = static_cast<long long>(srcW) * static_cast<long long>(srcH) <= (1LL << 19);
2750
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS
2749
2751
  if (useBuffer)
2750
2752
  {
2751
2753
  // Coverage buffer is text-space (independent of the 3D projection), so it's
@@ -2796,9 +2798,9 @@ int gLastScrollUiFrame = -1000;
2796
2798
  const int ttf = command.projectedText.textTransform;
2797
2799
  const int needBytes = srcW * srcH;
2798
2800
  auto &perf = refreshPerfStatsMutable();
2799
- perf.projectedTextCacheCalls++;
2800
- if (needBytes > perf.projectedTextCacheMaxEntryBytes)
2801
- 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);
2802
2804
  CoverageCacheEntry *hit = nullptr;
2803
2805
  for (auto &e : cache)
2804
2806
  {
@@ -2811,7 +2813,7 @@ int gLastScrollUiFrame = -1000;
2811
2813
  }
2812
2814
  if (!hit)
2813
2815
  {
2814
- perf.projectedTextCacheMisses++;
2816
+ GEA_REFRESH_PERF(perf.projectedTextCacheMisses++);
2815
2817
  // Prefer an empty slot (8 slots > the handful of distinct labels in a
2816
2818
  // scene), else evict the hash-mapped slot.
2817
2819
  int evict = textHash & 7;
@@ -2867,8 +2869,9 @@ int gLastScrollUiFrame = -1000;
2867
2869
  }
2868
2870
  else
2869
2871
  {
2870
- perf.projectedTextCacheHits++;
2872
+ GEA_REFRESH_PERF(perf.projectedTextCacheHits++);
2871
2873
  }
2874
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
2872
2875
  int cachedBytes = 0;
2873
2876
  int sramBytes = 0;
2874
2877
  for (const auto &e : cache)
@@ -2879,17 +2882,18 @@ int gLastScrollUiFrame = -1000;
2879
2882
  sramBytes += e.bytes;
2880
2883
  }
2881
2884
  if (cachedBytes > perf.projectedTextCacheBytes)
2882
- perf.projectedTextCacheBytes = cachedBytes;
2885
+ GEA_REFRESH_PERF(perf.projectedTextCacheBytes = cachedBytes);
2883
2886
  if (sramBytes > perf.projectedTextCacheSramBytes)
2884
- perf.projectedTextCacheSramBytes = sramBytes;
2887
+ GEA_REFRESH_PERF(perf.projectedTextCacheSramBytes = sramBytes);
2888
+ #endif
2885
2889
  if (hit->inSram)
2886
2890
  {
2887
- perf.projectedTextCacheSramUses++;
2891
+ GEA_REFRESH_PERF(perf.projectedTextCacheSramUses++);
2888
2892
  cb = hit->sramBuf;
2889
2893
  }
2890
2894
  else
2891
2895
  {
2892
- perf.projectedTextCachePsramUses++;
2896
+ GEA_REFRESH_PERF(perf.projectedTextCachePsramUses++);
2893
2897
  cb = hit->buf.data();
2894
2898
  }
2895
2899
  // A label with no ink at all draws nothing — skip the projected loop.
@@ -2901,8 +2905,23 @@ int gLastScrollUiFrame = -1000;
2901
2905
  inkY1 = hit->ink[3];
2902
2906
  }
2903
2907
  else
2908
+ #else
2909
+ // A native/dynamic instruction missed by source analysis still uses the
2910
+ // identical coverage rasterization and Q8 sampling. Only this call owns
2911
+ // the scratch; no transform-free app reserves a bank or retains a bitmap.
2912
+ std::vector<std::uint8_t> uncachedCoverage;
2913
+ if (useBuffer) {
2914
+ uncachedCoverage.resize(static_cast<std::size_t>(srcW) * srcH);
2915
+ int ink[4];
2916
+ buildProjectedTextAlpha(command, font, uncachedCoverage.data(), srcW, srcH, ink);
2917
+ if (ink[2] < ink[0]) return;
2918
+ cb = uncachedCoverage.data();
2919
+ inkX0 = ink[0]; inkY0 = ink[1]; inkX1 = ink[2]; inkY1 = ink[3];
2920
+ }
2921
+ else
2922
+ #endif
2904
2923
  {
2905
- refreshPerfStatsMutable().projectedTextCacheFallbacks++;
2924
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().projectedTextCacheFallbacks++);
2906
2925
  }
2907
2926
  const float srcXf = static_cast<float>(command.projectedText.srcX);
2908
2927
  const float srcYf = static_cast<float>(command.projectedText.srcY);
@@ -3384,6 +3403,7 @@ int gLastScrollUiFrame = -1000;
3384
3403
  // so an app that never fills a transformed gradient reserves ZERO RAM for
3385
3404
  // this ~26 KB LUT bank scratch — it used to sit in .bss unconditionally for
3386
3405
  // every app. Allocated on the first transformed-gradient fill; never freed.
3406
+ #if GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
3387
3407
  using FaceLutBank = FaceLutSlot[kTransformedGradientLutSlots];
3388
3408
  static FaceLutBank *const slotsByBank = []() -> FaceLutBank *
3389
3409
  {
@@ -3413,6 +3433,16 @@ int gLastScrollUiFrame = -1000;
3413
3433
  auto &slots = slotsByBank[lutBank];
3414
3434
  int &slotRR = slotRRByBank[lutBank];
3415
3435
  std::uint8_t *const slotConstAlpha = slotConstAlphaByBank[lutBank];
3436
+
3437
+ #else
3438
+ FaceLutSlot slots[1]{};
3439
+ int slotRR = 0;
3440
+ std::uint8_t slotConstAlpha[1]{};
3441
+ #if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
3442
+ volatile unsigned char slotLockByBank[1]{};
3443
+ constexpr int lutBank = 0;
3444
+ #endif
3445
+ #endif
3416
3446
  #if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
3417
3447
  volatile unsigned char &slotLock = slotLockByBank[lutBank];
3418
3448
  auto lockSlots = [&slotLock]()
@@ -3526,7 +3556,7 @@ int gLastScrollUiFrame = -1000;
3526
3556
  std::memcpy(slot->keyA, keyA, sizeof keyA);
3527
3557
  slot->valid = true;
3528
3558
  }
3529
- const bool slotIsConstAlpha = slotConstAlpha[slot - slots] != 0;
3559
+ [[maybe_unused]] const bool slotIsConstAlpha = slotConstAlpha[slot - slots] != 0;
3530
3560
  #if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
3531
3561
  unlockSlots();
3532
3562
  #endif
@@ -3669,7 +3699,9 @@ int gLastScrollUiFrame = -1000;
3669
3699
  #if GEA_EMBEDDED_PIXEL_FORMAT == GEA_PIXEL_RGB565
3670
3700
  const bool rgb565LutBlendAvail = kTransformedGradientA5Mirror && gea_rgb565_lut_blend_available();
3671
3701
  const bool rgb565LutBlendConstAlphaAvail = gea_rgb565_lut_blend_const_alpha_available();
3672
- #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.
3673
3705
  // SIMD-blend scratch for the aligned middle of each span: gathered LUT colors
3674
3706
  // (panel->normal) + per-pixel alpha. PER-CORE: with the 2-core coarse split the
3675
3707
  // worker fills the bottom band concurrently with this core's top band, so a
@@ -3822,7 +3854,7 @@ int gLastScrollUiFrame = -1000;
3822
3854
  row[x] = gea::framework::graphics::pixel::fromRgb565(rn);
3823
3855
  };
3824
3856
  int x = xL;
3825
- #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER
3857
+ #if GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER && GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
3826
3858
  // The PIE kernel uses 16-byte-aligned vector load/store, so &row[aStart]
3827
3859
  // must be 16-byte (8-px) aligned at its ABSOLUTE framebuffer address — not
3828
3860
  // just at a row-local multiple of 8. The framebuffer stride is packed
@@ -4708,7 +4740,7 @@ int gLastScrollUiFrame = -1000;
4708
4740
 
4709
4741
  bool hasRetainedTransformState(const Node &node)
4710
4742
  {
4711
- const RareStyle &rs = rstyle(node.style); // one pool lookup, not 11
4743
+ const RareStyle &rs = rstyle(node.computedStyle()); // one pool lookup, not 11
4712
4744
  const bool currentTransformable = ViewRenderer::isTransformableBox(node);
4713
4745
  return (currentTransformable && hasIndividualLinearTransform(rs)) ||
4714
4746
  (node.render.previous_transformable_box && hadIndividualLinearTransform(node.render)) ||
@@ -4760,7 +4792,7 @@ int gLastScrollUiFrame = -1000;
4760
4792
  struct Key { int phase, level; };
4761
4793
  static bool effectGroup(const Node &node)
4762
4794
  {
4763
- const auto &s = node.style;
4795
+ const auto &s = node.computedStyle();
4764
4796
  const auto &rs = rstyle(s);
4765
4797
  const bool transformable = ViewRenderer::isTransformableBox(node);
4766
4798
  return s.opacity < 255 || s.mask_right_fade_width > 0 || rs.filter_present || rs.filter_blur_radius ||
@@ -4774,10 +4806,10 @@ int gLastScrollUiFrame = -1000;
4774
4806
  {
4775
4807
  const Node *nodes = Tree::instance().nodes();
4776
4808
  const Node &n = nodes[id];
4777
- const auto &s = n.style;
4809
+ const auto &s = n.computedStyle();
4778
4810
  const bool positioned = s.position != 0;
4779
4811
  const bool item = n.parent >= 0 && !isOutOfFlowPosition(s.position) &&
4780
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
4812
+ (nodes[n.parent].computedStyle().display == kDisplayFlex || isDisplayGrid(nodes[n.parent].computedStyle()));
4781
4813
  const int level = !s.z_index_auto && (positioned || item) ? s.z_index : 0;
4782
4814
  if (level < 0) return {0, level};
4783
4815
  if (level > 0) return {5, level};
@@ -4796,7 +4828,7 @@ int gLastScrollUiFrame = -1000;
4796
4828
  static bool participatesIn3DContext(int node, int contextRoot)
4797
4829
  {
4798
4830
  const Node *nodes = Tree::instance().nodes();
4799
- if (contextRoot < 0 || !ViewRenderer::isTransformableBox(nodes[contextRoot]) || !preserves3D(nodes[contextRoot].style))
4831
+ if (contextRoot < 0 || !ViewRenderer::isTransformableBox(nodes[contextRoot]) || !preserves3D(nodes[contextRoot].computedStyle()))
4800
4832
  return false;
4801
4833
  // A 3D rendering context follows DOM ancestry, not containing-block
4802
4834
  // ancestry. Every parent between a participant and the context root
@@ -4804,7 +4836,7 @@ int gLastScrollUiFrame = -1000;
4804
4836
  // single plane and prevents abs/fixed descendants from being hoisted
4805
4837
  // into this context.
4806
4838
  for (int parent = nodes[node].parent; parent >= 0 && parent != contextRoot; parent = nodes[parent].parent)
4807
- if (!ViewRenderer::isTransformableBox(nodes[parent]) || !preserves3D(nodes[parent].style))
4839
+ if (!ViewRenderer::isTransformableBox(nodes[parent]) || !preserves3D(nodes[parent].computedStyle()))
4808
4840
  return false;
4809
4841
  for (int parent = nodes[node].parent; parent >= 0; parent = nodes[parent].parent)
4810
4842
  if (parent == contextRoot)
@@ -4866,7 +4898,7 @@ int gLastScrollUiFrame = -1000;
4866
4898
  // each node costs 5 double-precision projections, so this avoids it
4867
4899
  // entirely for 2D trees.
4868
4900
  const bool transforms = contextRoot >= 0 && ViewRenderer::isTransformableBox(Tree::instance().nodes()[contextRoot]) &&
4869
- preserves3D(Tree::instance().nodes()[contextRoot].style) &&
4901
+ preserves3D(Tree::instance().nodes()[contextRoot].computedStyle()) &&
4870
4902
  ViewRenderer::anyTransformActive();
4871
4903
  if (!transforms)
4872
4904
  {
@@ -4924,9 +4956,9 @@ int gLastScrollUiFrame = -1000;
4924
4956
  case DisplayCommandType::PushClip: {
4925
4957
  const int id = c->clip.nodeId;
4926
4958
  const Node *owner = id >= 0 && id < Tree::instance().nodeCount() ? &Tree::instance().nodes()[id] : nullptr;
4927
- if (!owner || overflowX(owner->style)) c->clip.x += dx;
4959
+ if (!owner || overflowX(owner->computedStyle())) c->clip.x += dx;
4928
4960
  else c->bx -= dx;
4929
- if (!owner || overflowY(owner->style)) c->clip.y += dy;
4961
+ if (!owner || overflowY(owner->computedStyle())) c->clip.y += dy;
4930
4962
  else c->by -= dy;
4931
4963
  break;
4932
4964
  }
@@ -5285,6 +5317,29 @@ int gLastScrollUiFrame = -1000;
5285
5317
  gea::framework::graphics::pixel::native_t color;
5286
5318
  };
5287
5319
 
5320
+ static DitherStop ditherStop(int r, int g, int b, uint8_t alpha)
5321
+ {
5322
+ DitherStop stop{};
5323
+ auto split = [](int value, int levels, uint8_t &q, uint8_t &rem) {
5324
+ const int scaled = std::clamp(value, 0, 255) * levels;
5325
+ q = static_cast<uint8_t>(scaled / 255);
5326
+ rem = static_cast<uint8_t>(scaled % 255);
5327
+ };
5328
+ split(r, 31, stop.qR, stop.remR);
5329
+ split(g, 63, stop.qG, stop.remG);
5330
+ split(b, 31, stop.qB, stop.remB);
5331
+ stop.color = gea::framework::graphics::pixel::packNative8(r, g, b);
5332
+ stop.alpha = alpha;
5333
+ return stop;
5334
+ }
5335
+
5336
+ static DitherStop ditherAt(const DisplayCommand &c, int p)
5337
+ {
5338
+ int r, g, b;
5339
+ rgb888At(c, p, &r, &g, &b);
5340
+ return ditherStop(r, g, b, alphaAt(c, p));
5341
+ }
5342
+
5288
5343
  // Un-dithered RGB888 color at a gradient position. Carries every integer
5289
5344
  // divide in the gradient (mid-stop remap, RGB565->888 unpack, channel
5290
5345
  // interpolation). The S3 has no fast integer divide, so calling this per
@@ -5457,6 +5512,7 @@ int gLastScrollUiFrame = -1000;
5457
5512
  // flush's expected per-row dirty pattern and hung the panel TX. Going through
5458
5513
  // blitImage() keeps the cache provably equivalent to the stable path.) Gated on
5459
5514
  // opaque + large + stable so animated/small/alpha gradients render normally.
5515
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
5460
5516
  auto *bgCanvas = gea::platform::display::Display::canvas();
5461
5517
  int bgCap = 0;
5462
5518
  gea::framework::graphics::pixel::native_t *bgBuf = gea_bg_cache(&bgCap);
@@ -5520,6 +5576,8 @@ int gLastScrollUiFrame = -1000;
5520
5576
  if (transCacheable && transCache.blit(transKey, 14, x0, y0, x1, y1, scrW, scrH, transSpan))
5521
5577
  return;
5522
5578
 
5579
+ #endif
5580
+
5523
5581
  const double angleRadians = (static_cast<double>(c.gradient.angle) * kPi) / 1800.0;
5524
5582
  double dx = std::sin(angleRadians);
5525
5583
  double dy = -std::cos(angleRadians);
@@ -5586,6 +5644,7 @@ int gLastScrollUiFrame = -1000;
5586
5644
  #ifndef GEA_EMBEDDED_LAZY_GRADIENT_LUTS
5587
5645
  #define GEA_EMBEDDED_LAZY_GRADIENT_LUTS 0
5588
5646
  #endif
5647
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
5589
5648
  struct LutSlot
5590
5649
  {
5591
5650
  DitherStop lut[1001];
@@ -5641,32 +5700,7 @@ int gLastScrollUiFrame = -1000;
5641
5700
  {
5642
5701
  for (int p = 0; p <= 1000; p++)
5643
5702
  {
5644
- int r, g, b;
5645
- rgb888At(c, p, &r, &g, &b);
5646
- auto split = [](int value, int levels, uint8_t *q, uint8_t *rem)
5647
- {
5648
- if (value <= 0)
5649
- {
5650
- *q = 0;
5651
- *rem = 0;
5652
- return;
5653
- }
5654
- if (value >= 255)
5655
- {
5656
- *q = static_cast<uint8_t>(levels);
5657
- *rem = 0;
5658
- return;
5659
- }
5660
- const int scaled = value * levels;
5661
- const int qq = scaled / 255;
5662
- *q = static_cast<uint8_t>(qq);
5663
- *rem = static_cast<uint8_t>(scaled - qq * 255);
5664
- };
5665
- split(r, 31, &lut[p].qR, &lut[p].remR);
5666
- split(g, 63, &lut[p].qG, &lut[p].remG);
5667
- split(b, 31, &lut[p].qB, &lut[p].remB);
5668
- lut[p].color = gea::framework::graphics::pixel::packNative8(r, g, b);
5669
- lut[p].alpha = alphaAt(c, p);
5703
+ lut[p] = ditherAt(c, p);
5670
5704
  }
5671
5705
  lutKey[0] = c.gradient.fromColor;
5672
5706
  lutKey[1] = c.gradient.midColor;
@@ -5678,6 +5712,13 @@ int gLastScrollUiFrame = -1000;
5678
5712
  lutKeyA[2] = c.gradient.toAlpha;
5679
5713
  lutKeyA[3] = c.gradient.hasMid;
5680
5714
  }
5715
+ #else
5716
+ struct UncachedLut {
5717
+ const DisplayCommand &command;
5718
+ DitherStop operator[](int p) const { return ditherAt(command, p); }
5719
+ } lut{c};
5720
+ #endif
5721
+
5681
5722
  static constexpr uint8_t bayer4[4][4] = {
5682
5723
  {0, 8, 2, 10},
5683
5724
  {12, 4, 14, 6},
@@ -5702,8 +5743,14 @@ int gLastScrollUiFrame = -1000;
5702
5743
  const float stepY = static_cast<float>(dy);
5703
5744
  const float fMinProjection = static_cast<float>(minProjection);
5704
5745
  const float invSpanPermille = 1000.0f / static_cast<float>(projectionSpan);
5705
- static gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
5706
- static uint8_t rowAlpha[gea::platform::display::kWidth];
5746
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
5747
+ static
5748
+ #endif
5749
+ gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
5750
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
5751
+ static
5752
+ #endif
5753
+ uint8_t rowAlpha[gea::platform::display::kWidth];
5707
5754
  for (int y = y0; y <= y1; y++)
5708
5755
  {
5709
5756
  int rowX0 = x0;
@@ -5772,6 +5819,7 @@ int gLastScrollUiFrame = -1000;
5772
5819
  }
5773
5820
  }
5774
5821
 
5822
+ #if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
5775
5823
  // Once the gradient has been identical for 2 frames, render it in full into
5776
5824
  // the cache buffer (reusing the LUT/projection just computed); subsequent
5777
5825
  // frames hit the blit fast-path above. One-time ~full-screen render; writes
@@ -5895,6 +5943,7 @@ int gLastScrollUiFrame = -1000;
5895
5943
  }
5896
5944
  });
5897
5945
  }
5946
+ #endif
5898
5947
  }
5899
5948
  };
5900
5949
 
@@ -5989,6 +6038,16 @@ int gLastScrollUiFrame = -1000;
5989
6038
  localPermille(c, permille));
5990
6039
  }
5991
6040
 
6041
+ static LinearGradientDrawer::DitherStop ditherAt(const DisplayCommand &c, int p)
6042
+ {
6043
+ const int lp = localPermille(c, p);
6044
+ int r, g, b;
6045
+ LinearGradientDrawer::interpolatePremultipliedRgb888(c.radialGradient.fromColor, c.radialGradient.fromAlpha,
6046
+ c.radialGradient.toColor, c.radialGradient.toAlpha, lp, &r, &g, &b);
6047
+ return LinearGradientDrawer::ditherStop(r, g, b,
6048
+ LinearGradientDrawer::interpolateAlpha(c.radialGradient.fromAlpha, c.radialGradient.toAlpha, lp));
6049
+ }
6050
+
5992
6051
  static void replay(const DisplayCommand &c)
5993
6052
  {
5994
6053
  int cx0, cy0, cx1, cy1;
@@ -6015,6 +6074,7 @@ int gLastScrollUiFrame = -1000;
6015
6074
  // warm-glow radial is static — fixed colors + box, identical across themes
6016
6075
  // (only the base linear layer changes) — so cache it once and blit instead of
6017
6076
  // recomputing sqrt + dither per pixel. Gated to reasonably large boxes.
6077
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6018
6078
  auto *rcanvas = gea::platform::display::Display::canvas();
6019
6079
  const int scrW = rcanvas ? rcanvas->width() : 0;
6020
6080
  const int scrH = rcanvas ? rcanvas->height() : 0;
@@ -6036,9 +6096,12 @@ int gLastScrollUiFrame = -1000;
6036
6096
  if (cacheable && cache.blit(keyNow, 17, x0, y0, x1, y1, scrW, scrH, span))
6037
6097
  return;
6038
6098
 
6099
+ #endif
6100
+
6039
6101
  // Divide-free dither LUT indexed by local permille (0..1000), cached across
6040
6102
  // calls keyed by the color stops (mirrors LinearGradientDrawer). The per-pixel
6041
6103
  // dither becomes a table read + 3 threshold compares — no divides.
6104
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6042
6105
  #if GEA_EMBEDDED_LAZY_GRADIENT_LUTS
6043
6106
  static auto lutStorage = std::make_unique<std::array<LinearGradientDrawer::DitherStop, 1001>>();
6044
6107
  auto &lut = *lutStorage;
@@ -6058,34 +6121,7 @@ int gLastScrollUiFrame = -1000;
6058
6121
  // clamps to 1000, which localPermille also maps to 1000).
6059
6122
  for (int p = 0; p <= 1000; ++p)
6060
6123
  {
6061
- const int lp = localPermille(c, p);
6062
- int r = 0, g = 0, b = 0;
6063
- LinearGradientDrawer::interpolatePremultipliedRgb888(c.radialGradient.fromColor, c.radialGradient.fromAlpha,
6064
- c.radialGradient.toColor, c.radialGradient.toAlpha, lp, &r, &g, &b);
6065
- auto split = [](int value, int levels, uint8_t *q, uint8_t *rem)
6066
- {
6067
- if (value <= 0)
6068
- {
6069
- *q = 0;
6070
- *rem = 0;
6071
- return;
6072
- }
6073
- if (value >= 255)
6074
- {
6075
- *q = static_cast<uint8_t>(levels);
6076
- *rem = 0;
6077
- return;
6078
- }
6079
- const int scaled = value * levels;
6080
- const int qq = scaled / 255;
6081
- *q = static_cast<uint8_t>(qq);
6082
- *rem = static_cast<uint8_t>(scaled - qq * 255);
6083
- };
6084
- split(r, 31, &lut[p].qR, &lut[p].remR);
6085
- split(g, 63, &lut[p].qG, &lut[p].remG);
6086
- split(b, 31, &lut[p].qB, &lut[p].remB);
6087
- lut[p].color = gea::framework::graphics::pixel::packNative8(r, g, b);
6088
- lut[p].alpha = LinearGradientDrawer::interpolateAlpha(c.radialGradient.fromAlpha, c.radialGradient.toAlpha, lp);
6124
+ lut[p] = ditherAt(c, p);
6089
6125
  }
6090
6126
  lutKeyFrom = c.radialGradient.fromColor;
6091
6127
  lutKeyTo = c.radialGradient.toColor;
@@ -6093,6 +6129,13 @@ int gLastScrollUiFrame = -1000;
6093
6129
  lutKeyToA = c.radialGradient.toAlpha;
6094
6130
  lutKeyStop = c.radialGradient.stopPermille;
6095
6131
  }
6132
+ #else
6133
+ struct UncachedLut {
6134
+ const DisplayCommand &command;
6135
+ LinearGradientDrawer::DitherStop operator[](int p) const { return ditherAt(command, p); }
6136
+ } lut{c};
6137
+ #endif
6138
+
6096
6139
  static constexpr uint8_t bayer4[4][4] = {
6097
6140
  {0, 8, 2, 10},
6098
6141
  {12, 4, 14, 6},
@@ -6104,8 +6147,14 @@ int gLastScrollUiFrame = -1000;
6104
6147
  // row into ~1px writes (each paying a clip + framebuffer read-back + dirty-list
6105
6148
  // scan) — the radial's real cost, just like the linear drawer. blitImage clips
6106
6149
  // and marks dirty once per row. (baseAlpha is read from Display::alpha() inside.)
6107
- static gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
6108
- static uint8_t rowAlpha[gea::platform::display::kWidth];
6150
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6151
+ static
6152
+ #endif
6153
+ gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
6154
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6155
+ static
6156
+ #endif
6157
+ uint8_t rowAlpha[gea::platform::display::kWidth];
6109
6158
  // Mirror gate: a pixel xx and its mirror (mirrorSum - xx) have dx values
6110
6159
  // that are exact float negations of each other when 2*centerX lands on an
6111
6160
  // integer grid (e.g. the shell glow's `at 50%`), so dx*dx — and therefore
@@ -6115,7 +6164,10 @@ int gLastScrollUiFrame = -1000;
6115
6164
  const float mirrorSumF = 2.0f * centerX - 1.0f;
6116
6165
  const int mirrorSum = static_cast<int>(mirrorSumF);
6117
6166
  const bool mirrorable = mirrorSumF == static_cast<float>(mirrorSum);
6118
- static std::uint16_t rowPermille[gea::platform::display::kWidth];
6167
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6168
+ static
6169
+ #endif
6170
+ std::uint16_t rowPermille[gea::platform::display::kWidth];
6119
6171
  for (int y = y0; y <= y1; ++y)
6120
6172
  {
6121
6173
  int rowX0 = x0;
@@ -6163,6 +6215,7 @@ int gLastScrollUiFrame = -1000;
6163
6215
  }
6164
6216
  }
6165
6217
 
6218
+ #if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
6166
6219
  // Bake the full box into the cache once params are stable for 2 frames.
6167
6220
  if (cacheable)
6168
6221
  {
@@ -6184,6 +6237,7 @@ int gLastScrollUiFrame = -1000;
6184
6237
  *alp = e.alpha;
6185
6238
  });
6186
6239
  }
6240
+ #endif
6187
6241
  }
6188
6242
  };
6189
6243
 
@@ -6200,8 +6254,8 @@ int gLastScrollUiFrame = -1000;
6200
6254
  auto &tree = Tree::instance();
6201
6255
  if (id < 0 || id >= tree.nodeCount()) return;
6202
6256
  const auto &node = tree.nodes()[id];
6203
- if (node.style.display == 1 || (id != owner && isOutOfFlowPosition(node.style.position))) return;
6204
- 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) {
6205
6259
  const int begin = state.nodeDrawStart[id], end = state.nodeDrawEnd[id];
6206
6260
  for (int ci = std::max(0, begin); ci < end && ci < state.commandCount; ++ci) {
6207
6261
  const auto &c = state.commands[ci];
@@ -6282,23 +6336,23 @@ int gLastScrollUiFrame = -1000;
6282
6336
  switch (c.type)
6283
6337
  {
6284
6338
  case DisplayCommandType::FillRect:
6285
- perf.treeReplayFillRectCommands++;
6339
+ GEA_REFRESH_PERF(perf.treeReplayFillRectCommands++);
6286
6340
  break;
6287
6341
  case DisplayCommandType::FillCircle:
6288
- perf.treeReplayCircleCommands++;
6342
+ GEA_REFRESH_PERF(perf.treeReplayCircleCommands++);
6289
6343
  break;
6290
6344
  case DisplayCommandType::FillRoundedRect:
6291
- perf.treeReplayRoundedRectCommands++;
6345
+ GEA_REFRESH_PERF(perf.treeReplayRoundedRectCommands++);
6292
6346
  break;
6293
6347
  case DisplayCommandType::FillTransformedRoundedRect:
6294
- perf.treeReplayTransformedRoundedRectCommands++;
6348
+ GEA_REFRESH_PERF(perf.treeReplayTransformedRoundedRectCommands++);
6295
6349
  break;
6296
6350
  case DisplayCommandType::DrawText:
6297
6351
  case DisplayCommandType::DrawProjectedText:
6298
- perf.treeReplayTextCommands++;
6352
+ GEA_REFRESH_PERF(perf.treeReplayTextCommands++);
6299
6353
  break;
6300
6354
  default:
6301
- perf.treeReplayOtherCommands++;
6355
+ GEA_REFRESH_PERF(perf.treeReplayOtherCommands++);
6302
6356
  break;
6303
6357
  }
6304
6358
  }
@@ -6466,26 +6520,26 @@ int gLastScrollUiFrame = -1000;
6466
6520
  case DisplayCommandType::FillRoundedRect:
6467
6521
  case DisplayCommandType::FillQuad:
6468
6522
  case DisplayCommandType::FillTransformedRoundedRect:
6469
- __perf.treeReplayFillUs += __replayDt;
6523
+ GEA_REFRESH_PERF(__perf.treeReplayFillUs += __replayDt);
6470
6524
  break;
6471
6525
  case DisplayCommandType::FillCircle:
6472
- __perf.treeReplayCircleUs += __replayDt;
6526
+ GEA_REFRESH_PERF(__perf.treeReplayCircleUs += __replayDt);
6473
6527
  break;
6474
6528
  case DisplayCommandType::DrawText:
6475
6529
  case DisplayCommandType::DrawProjectedText:
6476
- __perf.treeReplayTextUs += __replayDt;
6530
+ GEA_REFRESH_PERF(__perf.treeReplayTextUs += __replayDt);
6477
6531
  break;
6478
6532
  case DisplayCommandType::FillLinearGradient:
6479
6533
  case DisplayCommandType::FillTransformedLinearGradient:
6480
6534
  case DisplayCommandType::FillRadialGradient:
6481
- __perf.treeReplayGradientUs += __replayDt;
6535
+ GEA_REFRESH_PERF(__perf.treeReplayGradientUs += __replayDt);
6482
6536
  break;
6483
6537
  case DisplayCommandType::BlitImage:
6484
6538
  case DisplayCommandType::BlitImageScaled:
6485
- __perf.treeReplayImageUs += __replayDt;
6539
+ GEA_REFRESH_PERF(__perf.treeReplayImageUs += __replayDt);
6486
6540
  break;
6487
6541
  default:
6488
- __perf.treeReplayOtherUs += __replayDt;
6542
+ GEA_REFRESH_PERF(__perf.treeReplayOtherUs += __replayDt);
6489
6543
  break;
6490
6544
  }
6491
6545
  }
@@ -6537,22 +6591,22 @@ int gLastScrollUiFrame = -1000;
6537
6591
  {
6538
6592
  const bool simpleBackgroundLeaf = node.first_child < 0 &&
6539
6593
  node.type == NodeType::View &&
6540
- node.style.has_bg &&
6541
- !styleHasBackgroundImage(node.style) && rstyle(node.style).bg_clip == 0 &&
6542
- !hasAnyBorder(node.style);
6594
+ node.computedStyle().has_bg &&
6595
+ !styleHasBackgroundImage(node.computedStyle()) && rstyle(node.computedStyle()).bg_clip == 0 &&
6596
+ !hasAnyBorder(node.computedStyle());
6543
6597
  if (!simpleBackgroundLeaf)
6544
6598
  return -1;
6545
- 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;
6546
6600
  }
6547
6601
 
6548
6602
  static void recordFilterBlur(int id, const Node &node, DisplayCommandType type, uint8_t parentAlpha)
6549
6603
  {
6550
- if (rstyle(node.style).filter_blur_radius <= 0)
6604
+ if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) <= 0)
6551
6605
  return;
6552
6606
  if (node.layout.width <= 0 || node.layout.height <= 0)
6553
6607
  return;
6554
6608
  const bool sourceLayerBlur = filterBlurSourceAlphaCap(node, parentAlpha) >= 0;
6555
- const int localSpread = sourceLayerBlur ? std::max(0, static_cast<int>(rstyle(node.style).filter_blur_radius)) * 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;
6556
6610
  int16_t xs[4] = {};
6557
6611
  int16_t ys[4] = {};
6558
6612
  ViewRenderer::transformedRectCorners(node, false,
@@ -6578,9 +6632,9 @@ int gLastScrollUiFrame = -1000;
6578
6632
  }
6579
6633
  if (x0 > x1 || y0 > y1)
6580
6634
  return;
6581
- int radiusX = rstyle(node.style).filter_blur_radius;
6582
- int radiusY = rstyle(node.style).filter_blur_radius;
6583
- filterBlurScreenRadii(node, rstyle(node.style).filter_blur_radius, &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);
6584
6638
  const int spreadX = sourceLayerBlur ? 0 : std::max(0, radiusX) * kFilterBlurPasses;
6585
6639
  const int spreadY = sourceLayerBlur ? 0 : std::max(0, radiusY) * kFilterBlurPasses;
6586
6640
  x0 -= spreadX;
@@ -6596,7 +6650,7 @@ int gLastScrollUiFrame = -1000;
6596
6650
  cmd->bw = static_cast<int16_t>(clampInt(x1 - x0 + 1, 0, 32767));
6597
6651
  cmd->bh = static_cast<int16_t>(clampInt(y1 - y0 + 1, 0, 32767));
6598
6652
  cmd->filterBlur.nodeId = static_cast<int16_t>(id);
6599
- cmd->filterBlur.radius = rstyle(node.style).filter_blur_radius;
6653
+ cmd->filterBlur.radius = (GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0);
6600
6654
  cmd->filterBlur.radiusX = static_cast<int16_t>(clampInt(radiusX, 0, 32767));
6601
6655
  cmd->filterBlur.radiusY = static_cast<int16_t>(clampInt(radiusY, 0, 32767));
6602
6656
  cmd->filterBlur.sourceAlphaCap = static_cast<int16_t>(filterBlurSourceAlphaCap(node, parentAlpha));
@@ -6639,12 +6693,12 @@ int gLastScrollUiFrame = -1000;
6639
6693
  return;
6640
6694
  }
6641
6695
  Node *n = &Tree::instance().nodes()[id];
6642
- if (n->style.display == 1 || isCollapsedFlexSubtree(*n) || ViewRenderer::backfaceSubtreeHidden(*n))
6696
+ if (n->computedStyle().display == 1 || isCollapsedFlexSubtree(*n) || ViewRenderer::backfaceSubtreeHidden(*n))
6643
6697
  {
6644
6698
  state.clearNodeRange(id);
6645
6699
  return;
6646
6700
  }
6647
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
6701
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
6648
6702
  {
6649
6703
  state.clearNodeRange(id);
6650
6704
  return;
@@ -6662,17 +6716,17 @@ int gLastScrollUiFrame = -1000;
6662
6716
  // dirty rect — same semantics as display:none, without forcing app
6663
6717
  // code to choose between the two patterns.
6664
6718
  bool contributesTextMask = false;
6665
- if (n->style.opacity == 0) {
6719
+ if (n->computedStyle().opacity == 0) {
6666
6720
  const auto *nodes = Tree::instance().nodes();
6667
6721
  for (int ancestor = id; ancestor >= 0; ancestor = nodes[ancestor].parent) {
6668
- if (isOutOfFlowPosition(nodes[ancestor].style.position)) break;
6722
+ if (isOutOfFlowPosition(nodes[ancestor].computedStyle().position)) break;
6669
6723
  const int parent = nodes[ancestor].parent;
6670
- if (parent >= 0 && StyleValues::hasTextBackgroundClip(nodes[parent].style)) {
6724
+ if (parent >= 0 && StyleValues::hasTextBackgroundClip(nodes[parent].computedStyle())) {
6671
6725
  contributesTextMask = true; break;
6672
6726
  }
6673
6727
  }
6674
6728
  }
6675
- if (n->style.opacity == 0 && !contributesTextMask)
6729
+ if (n->computedStyle().opacity == 0 && !contributesTextMask)
6676
6730
  {
6677
6731
  state.clearNodeRange(id);
6678
6732
  return;
@@ -6688,7 +6742,7 @@ int gLastScrollUiFrame = -1000;
6688
6742
  cy1 = (canvas ? canvas->height() : treeState().mountedHeight) - 1;
6689
6743
  }
6690
6744
  int overlaps_clip = isDocumentCanvasRoot(*n) || ClipMath::nodeOverlapsClip(*n, cx0, cy0, cx1, cy1);
6691
- 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()))) &&
6692
6746
  !LayoutEngine::containsViewportFixed(id))
6693
6747
  {
6694
6748
  state.clearNodeRange(id);
@@ -6708,9 +6762,9 @@ int gLastScrollUiFrame = -1000;
6708
6762
  uint8_t cur_alpha = parent_alpha;
6709
6763
  const Node *active_mask = mask_node;
6710
6764
 
6711
- if (n->style.opacity < 255)
6765
+ if (n->computedStyle().opacity < 255)
6712
6766
  {
6713
- cur_alpha = (parent_alpha * n->style.opacity) / 255;
6767
+ cur_alpha = (parent_alpha * n->computedStyle().opacity) / 255;
6714
6768
  DisplayCommand *cmd = list.append();
6715
6769
  if (cmd)
6716
6770
  {
@@ -6725,16 +6779,16 @@ int gLastScrollUiFrame = -1000;
6725
6779
  }
6726
6780
  }
6727
6781
 
6728
- if (n->style.mask_right_fade_width > 0)
6782
+ if (n->computedStyle().mask_right_fade_width > 0)
6729
6783
  active_mask = n;
6730
6784
 
6731
6785
  int draw_start = state.commandCount;
6732
- const bool paintsOwnBox = overlaps_clip && n->style.visibility == 0;
6786
+ const bool paintsOwnBox = overlaps_clip && n->computedStyle().visibility == 0;
6733
6787
  const bool nativeTextInput = isNativeTextInputView(*n);
6734
- const bool filtered = overlaps_clip && rstyle(n->style).filter_blur_radius > 0;
6788
+ const bool filtered = overlaps_clip && (GEA_CSS_FILTERS ? rstyle(n->computedStyle()).filter_blur_radius : 0) > 0;
6735
6789
  uint8_t draw_alpha = cur_alpha;
6736
6790
  bool pushed_mask_alpha = false;
6737
- if (active_mask && active_mask->style.mask_right_fade_width > 0)
6791
+ if (active_mask && active_mask->computedStyle().mask_right_fade_width > 0)
6738
6792
  {
6739
6793
  draw_alpha = multiplyAlpha(cur_alpha, rightFadeMaskAlphaForChild(*active_mask, *n));
6740
6794
  if (draw_alpha != cur_alpha)
@@ -6807,7 +6861,7 @@ int gLastScrollUiFrame = -1000;
6807
6861
  bool dirty = insideDirty || n->render.dirty;
6808
6862
  for (int p = nodes[child].parent; p >= 0 && p != id; p = nodes[p].parent) {
6809
6863
  dirty |= nodes[p].render.dirty;
6810
- if (nodes[p].style.overflow != 0) ancestors.push_back(p);
6864
+ if (nodes[p].computedStyle().overflow != 0) ancestors.push_back(p);
6811
6865
  }
6812
6866
  std::vector<RecordClipFrame> frames;
6813
6867
  frames.reserve(ancestors.size());
@@ -6835,7 +6889,7 @@ int gLastScrollUiFrame = -1000;
6835
6889
  if (filtered && !nativeTextInput)
6836
6890
  recordFilterBlur(id, *n, DisplayCommandType::ApplyFilterBlur, cur_alpha);
6837
6891
 
6838
- if (n->style.opacity < 255)
6892
+ if (n->computedStyle().opacity < 255)
6839
6893
  {
6840
6894
  DisplayCommand *cmd = list.append();
6841
6895
  if (cmd)
@@ -6900,9 +6954,9 @@ int gLastScrollUiFrame = -1000;
6900
6954
  const std::int64_t t0 = refreshPerfNowUs();
6901
6955
  gea::platform::display::Display::fillRoundedRectBoxesRgb565(xs, ys, count, w, h, tl, tr, br, bl, colors);
6902
6956
  auto &perf = refreshPerfStatsMutable();
6903
- perf.treeReplayFillUs += refreshPerfNowUs() - t0;
6904
- perf.treeReplayRoundedRectCommands += roundedCount;
6905
- 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);
6906
6960
  count = 0;
6907
6961
  roundedCount = 0;
6908
6962
  transformedRoundedCount = 0;
@@ -7266,7 +7320,7 @@ int gLastScrollUiFrame = -1000;
7266
7320
  if (region.x0 <= region.x1 && region.y0 <= region.y1)
7267
7321
  restoreRetainedBackgroundInRegion(region.x0, region.y0, region.x1, region.y1);
7268
7322
  }
7269
- refreshPerfStatsMutable().treeReplayBgRestoreUs += refreshPerfNowUs() - t0;
7323
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayBgRestoreUs += refreshPerfNowUs() - t0);
7270
7324
  }
7271
7325
 
7272
7326
  struct ReplayNodeWalkTimer
@@ -7274,7 +7328,7 @@ int gLastScrollUiFrame = -1000;
7274
7328
  std::int64_t start = refreshPerfNowUs();
7275
7329
  ~ReplayNodeWalkTimer()
7276
7330
  {
7277
- refreshPerfStatsMutable().treeReplayNodeWalkUs += refreshPerfNowUs() - start;
7331
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayNodeWalkUs += refreshPerfNowUs() - start);
7278
7332
  }
7279
7333
  };
7280
7334
 
@@ -7383,7 +7437,7 @@ int gLastScrollUiFrame = -1000;
7383
7437
  {
7384
7438
  DisplayCommand *c = &state.commands[ci];
7385
7439
  auto &perf = refreshPerfStatsMutable();
7386
- perf.treeReplayCommandChecks++;
7440
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
7387
7441
  if (commandMayPaintRegion(*c, x0, y0, x1, y1))
7388
7442
  return true;
7389
7443
  }
@@ -7418,7 +7472,7 @@ int gLastScrollUiFrame = -1000;
7418
7472
  if (node_id < 0 || node_id >= nodeCount)
7419
7473
  return false;
7420
7474
  const Node &node = nodes[node_id];
7421
- if (!isViewLikeNodeType(node.type) || node.style.overflow == 0)
7475
+ if (!isViewLikeNodeType(node.type) || node.computedStyle().overflow == 0)
7422
7476
  return false;
7423
7477
  if (node.first_child < 0)
7424
7478
  return false;
@@ -7438,7 +7492,7 @@ int gLastScrollUiFrame = -1000;
7438
7492
  int alpha = 255;
7439
7493
  for (int i = count - 1; i >= 0; i--)
7440
7494
  {
7441
- alpha = (alpha * static_cast<int>(nodes[chain[i]].style.opacity)) / 255;
7495
+ alpha = (alpha * static_cast<int>(nodes[chain[i]].computedStyle().opacity)) / 255;
7442
7496
  }
7443
7497
  if (alpha < 0)
7444
7498
  return 0;
@@ -7481,7 +7535,7 @@ int gLastScrollUiFrame = -1000;
7481
7535
  {
7482
7536
  DisplayCommand *c = &state.commands[ci];
7483
7537
  auto &perf = refreshPerfStatsMutable();
7484
- perf.treeReplayCommandChecks++;
7538
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
7485
7539
  // SetAlpha is a stateful scope command: it sets the alpha for the
7486
7540
  // following draws in this node's range and is restored by a matching
7487
7541
  // SetAlpha at the end of the range. It must be applied regardless of
@@ -7497,8 +7551,8 @@ int gLastScrollUiFrame = -1000;
7497
7551
  }
7498
7552
  const std::int64_t filterStartUs = refreshPerfNowUs();
7499
7553
  const bool mayPaint = commandMayPaintRegion(*c, x0, y0, x1, y1);
7500
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs;
7501
- perf.treeReplayCommandFilterCalls++;
7554
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs);
7555
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
7502
7556
  if (!mayPaint)
7503
7557
  continue;
7504
7558
  if (retainedBackgroundCommandCanBeSkippedInRegion(*c, x0, y0, x1, y1))
@@ -7521,7 +7575,7 @@ int gLastScrollUiFrame = -1000;
7521
7575
  for (int ci = start; ci < end; ci++)
7522
7576
  {
7523
7577
  DisplayCommand *c = &state.commands[ci];
7524
- refreshPerfStatsMutable().treeReplayCommandChecks++;
7578
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayCommandChecks++);
7525
7579
  if (c->type == DisplayCommandType::PushClip || c->type == DisplayCommandType::PopClip)
7526
7580
  continue;
7527
7581
  if (!commandOverlapsAnyRegion(*c, regions, count))
@@ -7592,11 +7646,11 @@ int gLastScrollUiFrame = -1000;
7592
7646
  for (int i = 0; i < nodeCount; i++)
7593
7647
  {
7594
7648
  const Node &node = nodes[i];
7595
- if (rstyle(node.style).filter_blur_radius > 0)
7649
+ if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0)
7596
7650
  { SRDBG("blur node", i); return false; }
7597
- if (node.style.opacity != 255 && node.style.opacity != 0)
7651
+ if (node.computedStyle().opacity != 255 && node.computedStyle().opacity != 0)
7598
7652
  { SRDBG("opacity node", i); return false; }
7599
- if (node.style.mask_right_fade_width > 0)
7653
+ if (node.computedStyle().mask_right_fade_width > 0)
7600
7654
  { SRDBG("mask node", i); return false; }
7601
7655
  if (hasRetainedTransformState(node))
7602
7656
  { SRDBG("transform node", i); return false; }
@@ -7645,9 +7699,9 @@ int gLastScrollUiFrame = -1000;
7645
7699
  if (retainedBackgroundNodeCanBeSkippedInRegions(node_id, regions, count))
7646
7700
  continue;
7647
7701
  const Node &node = nodes[node_id];
7648
- if (node.style.display == 1)
7702
+ if (node.computedStyle().display == 1)
7649
7703
  continue;
7650
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7704
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7651
7705
  continue;
7652
7706
  const int start = state.nodeDrawStart[node_id];
7653
7707
  const int end = state.nodeDrawEnd[node_id];
@@ -7685,9 +7739,9 @@ int gLastScrollUiFrame = -1000;
7685
7739
  if (node_id < 0 || node_id >= nodeCount)
7686
7740
  return;
7687
7741
  const Node &node = nodes[node_id];
7688
- if (node.style.display == 1)
7742
+ if (node.computedStyle().display == 1)
7689
7743
  return;
7690
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7744
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7691
7745
  return;
7692
7746
 
7693
7747
  if (requireLayoutOverlap)
@@ -7751,9 +7805,9 @@ int gLastScrollUiFrame = -1000;
7751
7805
  if (node_id < 0 || node_id >= nodeCount)
7752
7806
  continue;
7753
7807
  const Node &node = nodes[node_id];
7754
- if (node.style.display == 1)
7808
+ if (node.computedStyle().display == 1)
7755
7809
  continue;
7756
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7810
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7757
7811
  continue;
7758
7812
 
7759
7813
  const int start = state.nodeDrawStart[node_id];
@@ -7786,9 +7840,9 @@ int gLastScrollUiFrame = -1000;
7786
7840
  roundedRects.flush();
7787
7841
  __rasterUs += refreshPerfNowUs() - __r1;
7788
7842
  auto &perf = refreshPerfStatsMutable();
7789
- perf.treeReplaySplitRasterUs += __rasterUs;
7790
- perf.treeReplaySplitDynUs += __dynUs;
7791
- 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);
7792
7846
  }
7793
7847
 
7794
7848
  static bool simpleReplayNodeInAncestorChain(int node_id, const int *chain, int chainLen)
@@ -7822,9 +7876,9 @@ int gLastScrollUiFrame = -1000;
7822
7876
  if (simpleReplayNodeInAncestorChain(node_id, chain, chainLen))
7823
7877
  continue;
7824
7878
  const Node &node = nodes[node_id];
7825
- if (node.style.display == 1)
7879
+ if (node.computedStyle().display == 1)
7826
7880
  continue;
7827
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7881
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7828
7882
  continue;
7829
7883
  const int start = state.nodeDrawStart[node_id];
7830
7884
  const int end = state.nodeDrawEnd[node_id];
@@ -7836,7 +7890,7 @@ int gLastScrollUiFrame = -1000;
7836
7890
 
7837
7891
  static void replaySimpleClippedDirtyRegion(int x0, int y0, int x1, int y1, int origin = -1, bool allowSplit = true)
7838
7892
  {
7839
- refreshPerfStatsMutable().treeReplaySimpleRegionCalls++;
7893
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySimpleRegionCalls++);
7840
7894
  // Coarse 2-core band split, mirroring replayDirectDirtyRegion's: the
7841
7895
  // per-origin simple replay is the path a single full-screen dirty rect
7842
7896
  // takes every frame (e.g. the bouncing-balls field on a small panel),
@@ -7866,10 +7920,10 @@ int gLastScrollUiFrame = -1000;
7866
7920
  const Band *b = static_cast<const Band *>(p);
7867
7921
  replaySimpleClippedDirtyRegion(b->x0, by0, b->x1, by1, b->origin, /*allowSplit=*/false);
7868
7922
  };
7869
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
7923
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
7870
7924
  if (gea_render_parallel_submit(run, &band, mid + 1, y1))
7871
7925
  {
7872
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
7926
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
7873
7927
  replaySimpleClippedDirtyRegion(x0, y0, x1, mid, origin, /*allowSplit=*/false); // top band, this core
7874
7928
  gea_render_parallel_wait();
7875
7929
  gea_render_parallel_merge_dirty();
@@ -7892,6 +7946,14 @@ int gLastScrollUiFrame = -1000;
7892
7946
  for (int id = origin; id >= 0 && chainLen < 32; id = nodes[id].parent)
7893
7947
  chain[chainLen++] = id;
7894
7948
  const int originOrder = drawOrderIndexForSimpleReplay(origin);
7949
+ // An opaque image can cover the origin's ancestors completely.
7950
+ // Use the ordered cull walk instead of repainting those ancestors
7951
+ // immediately before the image overwrites them.
7952
+ if (occlusionCullStartIndex(x0, y0, x1, y1, nodes, nodeCount) > 0)
7953
+ {
7954
+ replaySimpleClippedDirtyRegionFast(x0, y0, x1, y1);
7955
+ return;
7956
+ }
7895
7957
  if (!simpleOriginReplayCanSkipEarlierNodes(chain, chainLen, originOrder, x0, y0, x1, y1))
7896
7958
  {
7897
7959
  replaySimpleClippedDirtyRegionFast(x0, y0, x1, y1);
@@ -7900,17 +7962,17 @@ int gLastScrollUiFrame = -1000;
7900
7962
  const std::int64_t __bgStart = refreshPerfNowUs();
7901
7963
  for (int i = chainLen - 1; i >= 0; --i)
7902
7964
  replaySimpleNodeCommandsInRect(chain[i], x0, y0, x1, y1, roundedRects, false);
7903
- refreshPerfStatsMutable().treeReplaySplitBgUs += refreshPerfNowUs() - __bgStart;
7965
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitBgUs += refreshPerfNowUs() - __bgStart);
7904
7966
  const std::int64_t __dynStart = refreshPerfNowUs();
7905
7967
  if (originOrder >= 0)
7906
7968
  {
7907
7969
  for (int oi = originOrder + 1; oi < state.drawNodeOrderCount; ++oi)
7908
7970
  replaySimpleNodeCommandsInRect(state.drawNodeOrder[oi], x0, y0, x1, y1, roundedRects, true);
7909
7971
  }
7910
- refreshPerfStatsMutable().treeReplaySplitDynUs += refreshPerfNowUs() - __dynStart;
7972
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitDynUs += refreshPerfNowUs() - __dynStart);
7911
7973
  const std::int64_t __rasterStart = refreshPerfNowUs();
7912
7974
  roundedRects.flush();
7913
- refreshPerfStatsMutable().treeReplaySplitRasterUs += refreshPerfNowUs() - __rasterStart;
7975
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplaySplitRasterUs += refreshPerfNowUs() - __rasterStart);
7914
7976
  return;
7915
7977
  }
7916
7978
  }
@@ -7931,9 +7993,9 @@ int gLastScrollUiFrame = -1000;
7931
7993
  if (retainedBackgroundNodeCanBeSkippedInRegion(node_id, x0, y0, x1, y1))
7932
7994
  continue;
7933
7995
  const Node &node = nodes[node_id];
7934
- if (node.style.display == 1)
7996
+ if (node.computedStyle().display == 1)
7935
7997
  continue;
7936
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
7998
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
7937
7999
  continue;
7938
8000
 
7939
8001
  const int nx0 = node.layout.x;
@@ -7951,13 +8013,13 @@ int gLastScrollUiFrame = -1000;
7951
8013
  {
7952
8014
  DisplayCommand *c = &state.commands[ci];
7953
8015
  auto &perf = refreshPerfStatsMutable();
7954
- perf.treeReplayCommandChecks++;
8016
+ GEA_REFRESH_PERF(perf.treeReplayCommandChecks++);
7955
8017
  if (c->type == DisplayCommandType::PushClip || c->type == DisplayCommandType::PopClip)
7956
8018
  continue;
7957
8019
  const std::int64_t filterStartUs = refreshPerfNowUs();
7958
8020
  const bool mayPaint = commandMayPaintRegion(*c, x0, y0, x1, y1);
7959
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs;
7960
- perf.treeReplayCommandFilterCalls++;
8021
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - filterStartUs);
8022
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
7961
8023
  if (!mayPaint)
7962
8024
  continue;
7963
8025
  if (retainedBackgroundCommandCanBeSkippedInRegion(*c, x0, y0, x1, y1))
@@ -8052,9 +8114,9 @@ int gLastScrollUiFrame = -1000;
8052
8114
  if (node_id < 0 || node_id >= tree.nodeCount())
8053
8115
  continue;
8054
8116
  Node *n = &nodes[node_id];
8055
- if (n->style.display == 1)
8117
+ if (n->computedStyle().display == 1)
8056
8118
  continue;
8057
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8119
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8058
8120
  continue;
8059
8121
  const int start = state.nodeDrawStart[node_id];
8060
8122
  const int end = state.nodeDrawEnd[node_id];
@@ -8108,9 +8170,9 @@ int gLastScrollUiFrame = -1000;
8108
8170
  if (node_id < 0 || node_id >= tree.nodeCount())
8109
8171
  continue;
8110
8172
  Node *n = &nodes[node_id];
8111
- if (n->style.display == 1)
8173
+ if (n->computedStyle().display == 1)
8112
8174
  continue;
8113
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8175
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8114
8176
  continue;
8115
8177
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8116
8178
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -8173,9 +8235,9 @@ int gLastScrollUiFrame = -1000;
8173
8235
  if (node_id < 0 || node_id >= tree.nodeCount())
8174
8236
  continue;
8175
8237
  Node *n = &nodes[node_id];
8176
- if (n->style.display == 1)
8238
+ if (n->computedStyle().display == 1)
8177
8239
  continue;
8178
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8240
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8179
8241
  continue;
8180
8242
  if (nodeOrAncestorRenderDirty(node_id, nodes, tree.nodeCount()))
8181
8243
  continue; // dynamic — not baked
@@ -8204,7 +8266,7 @@ int gLastScrollUiFrame = -1000;
8204
8266
 
8205
8267
  static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegion(int x0, int y0, int x1, int y1, int origin = -1, bool allowSplit = true)
8206
8268
  {
8207
- refreshPerfStatsMutable().treeReplayDirectRegionCalls++;
8269
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayDirectRegionCalls++);
8208
8270
  // Coarse 2-core split (ONE dispatch/frame). The worker core replays the bottom
8209
8271
  // row-band into its own band-canvas (private clip + dirty over the SAME
8210
8272
  // framebuffer — all DisplayBackend draw methods route through replayCanvas() so
@@ -8232,11 +8294,11 @@ int gLastScrollUiFrame = -1000;
8232
8294
  const Band *b = static_cast<const Band *>(p);
8233
8295
  replayDirectDirtyRegion(b->x0, by0, b->x1, by1, b->origin, /*allowSplit=*/false);
8234
8296
  };
8235
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
8297
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
8236
8298
  const bool __submitOk = gea_render_parallel_submit(run, &band, mid + 1, y1);
8237
8299
  if (__submitOk)
8238
8300
  {
8239
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
8301
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
8240
8302
  replayDirectDirtyRegion(x0, y0, x1, mid, origin, /*allowSplit=*/false); // top band, this core
8241
8303
  gea_render_parallel_wait();
8242
8304
  gea_render_parallel_merge_dirty();
@@ -8295,9 +8357,9 @@ int gLastScrollUiFrame = -1000;
8295
8357
  if (node_id < 0 || node_id >= nodeCount)
8296
8358
  continue;
8297
8359
  Node *n = &nodes[node_id];
8298
- if (n->style.display == 1)
8360
+ if (n->computedStyle().display == 1)
8299
8361
  continue;
8300
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8362
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8301
8363
  continue;
8302
8364
  if (!state.hasNodeScratchFor(node_id))
8303
8365
  continue;
@@ -8363,12 +8425,12 @@ int gLastScrollUiFrame = -1000;
8363
8425
  }
8364
8426
 
8365
8427
  // Painter's-algorithm occlusion cull: the LAST node (in draw order) whose
8366
- // first command is an opaque FillRect fully covering the region occludes
8428
+ // first command is an opaque fill or image covering the region occludes
8367
8429
  // everything drawn before it — the replay walk can start there. A page-sized
8368
8430
  // UI (e-reader page turn) stacks several full-bleed paper fills under the
8369
8431
  // content; each is a full PSRAM write of the region, so skipping the covered
8370
8432
  // ones removes ~100 ms/turn on a 540×960 GRAY4 panel. Conservative: the
8371
- // cover must be untransformed (a plain FillRect), at full effective alpha,
8433
+ // cover must be untransformed, at full effective alpha,
8372
8434
  // its node's first command, never blinking, and not shrunk by any ancestor
8373
8435
  // overflow clip smaller than the region.
8374
8436
  static int GEA_RENDER_HOT_SRAM occlusionCullStartIndex(int x0, int y0, int x1, int y1, Node *nodes, int nodeCount)
@@ -8378,11 +8440,6 @@ int gLastScrollUiFrame = -1000;
8378
8440
  const int node_id = state.drawNodeOrder[oi];
8379
8441
  if (node_id < 0 || node_id >= nodeCount)
8380
8442
  continue;
8381
- Node *n = &nodes[node_id];
8382
- if (n->style.display == 1)
8383
- continue;
8384
- if (n->style.blink_interval_ms > 0)
8385
- continue;
8386
8443
  if (!state.hasNodeScratchFor(node_id))
8387
8444
  continue;
8388
8445
  const int start = state.nodeDrawStart[node_id];
@@ -8390,15 +8447,27 @@ int gLastScrollUiFrame = -1000;
8390
8447
  if (start < 0 || end <= start || end > state.commandCount)
8391
8448
  continue;
8392
8449
  const DisplayCommand &c = state.commands[start];
8393
- if (c.type != DisplayCommandType::FillRect)
8394
- continue;
8395
- if (c.fill.x > x0 || c.fill.y > y0 ||
8396
- c.fill.x + c.fill.w - 1 < x1 || c.fill.y + c.fill.h - 1 < y1)
8450
+ bool covers = false;
8451
+ if (c.type == DisplayCommandType::FillRect)
8452
+ covers = c.fill.x <= x0 && c.fill.y <= y0 &&
8453
+ c.fill.x + c.fill.w - 1 >= x1 && c.fill.y + c.fill.h - 1 >= y1;
8454
+ else if (c.type == DisplayCommandType::BlitImage)
8455
+ covers = c.blit.pixels && !c.blit.alpha &&
8456
+ c.blit.dx <= x0 && c.blit.dy <= y0 &&
8457
+ c.blit.dx + c.blit.sourceWidth - 1 >= x1 &&
8458
+ c.blit.dy + c.blit.sourceHeight - 1 >= y1;
8459
+ if (!covers || c.textClipOwner >= 0)
8397
8460
  continue;
8398
8461
  // The recorded paint bbox must also cover the region (guards against
8399
8462
  // any recording that paints less than the command rect suggests).
8400
8463
  if (c.bx > x0 || c.by > y0 || c.bx + c.bw - 1 < x1 || c.by + c.bh - 1 < y1)
8401
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;
8402
8471
  if (effectiveAlphaForNode(node_id, nodes, nodeCount) != 255)
8403
8472
  continue;
8404
8473
  bool clipped = false;
@@ -8450,9 +8519,9 @@ int gLastScrollUiFrame = -1000;
8450
8519
  if (node_id < 0 || node_id >= tree.nodeCount())
8451
8520
  continue;
8452
8521
  Node *n = &nodes[node_id];
8453
- if (n->style.display == 1)
8522
+ if (n->computedStyle().display == 1)
8454
8523
  continue;
8455
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8524
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8456
8525
  continue;
8457
8526
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8458
8527
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -8489,16 +8558,16 @@ int gLastScrollUiFrame = -1000;
8489
8558
  {
8490
8559
  const std::int64_t t0 = refreshPerfNowUs();
8491
8560
  auto &perf = refreshPerfStatsMutable();
8492
- perf.treeReplayCommandFilterCalls++;
8561
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
8493
8562
  for (int ri = 0; ri < count; ri++)
8494
8563
  {
8495
8564
  if (commandOverlapsRegion(c, regions[ri]))
8496
8565
  {
8497
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8566
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8498
8567
  return true;
8499
8568
  }
8500
8569
  }
8501
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8570
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8502
8571
  return false;
8503
8572
  }
8504
8573
 
@@ -8506,16 +8575,16 @@ int gLastScrollUiFrame = -1000;
8506
8575
  {
8507
8576
  const std::int64_t t0 = refreshPerfNowUs();
8508
8577
  auto &perf = refreshPerfStatsMutable();
8509
- perf.treeReplayCommandFilterCalls++;
8578
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterCalls++);
8510
8579
  for (int ri = 0; ri < count; ri++)
8511
8580
  {
8512
8581
  if (commandContainedInRegion(c, regions[ri]))
8513
8582
  {
8514
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8583
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8515
8584
  return true;
8516
8585
  }
8517
8586
  }
8518
- perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0;
8587
+ GEA_REFRESH_PERF(perf.treeReplayCommandFilterUs += refreshPerfNowUs() - t0);
8519
8588
  return false;
8520
8589
  }
8521
8590
 
@@ -8538,7 +8607,7 @@ int gLastScrollUiFrame = -1000;
8538
8607
  y1 = region.y1;
8539
8608
  if (x0 > x1 || y0 > y1)
8540
8609
  return true;
8541
- refreshPerfStatsMutable().treeReplayFillRectCommands++;
8610
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayFillRectCommands++);
8542
8611
  gea::platform::display::Display::fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, c.fill.color);
8543
8612
  return true;
8544
8613
  }
@@ -8550,7 +8619,7 @@ int gLastScrollUiFrame = -1000;
8550
8619
  return false;
8551
8620
  if (!regionInsideRetainedBackground(c, x0, y0, x1, y1))
8552
8621
  return false;
8553
- refreshPerfStatsMutable().treeReplayRoundedRectCommands++;
8622
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayRoundedRectCommands++);
8554
8623
  gea::platform::display::Display::fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, c.fillRoundedRect.color);
8555
8624
  return true;
8556
8625
  }
@@ -8559,32 +8628,32 @@ int gLastScrollUiFrame = -1000;
8559
8628
  {
8560
8629
  const std::int64_t t0 = refreshPerfNowUs();
8561
8630
  auto &perf = refreshPerfStatsMutable();
8562
- perf.treeReplayCommandClipCalls++;
8631
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipCalls++);
8563
8632
  if (!commandOverlapsRegion(c, region))
8564
8633
  {
8565
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8634
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8566
8635
  return;
8567
8636
  }
8568
8637
  if (retainedBackgroundCommandCanBeSkippedInRegion(c, region.x0, region.y0, region.x1, region.y1))
8569
8638
  {
8570
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8639
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8571
8640
  return;
8572
8641
  }
8573
8642
  if (replayFillRectInRegion(c, region))
8574
8643
  {
8575
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8644
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8576
8645
  return;
8577
8646
  }
8578
8647
  if (replayContainedRoundedRectFillInRegion(c, region.x0, region.y0, region.x1, region.y1))
8579
8648
  {
8580
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8649
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8581
8650
  return;
8582
8651
  }
8583
8652
  gea::platform::display::Display::pushClip(region.x0, region.y0,
8584
8653
  region.x1 - region.x0 + 1, region.y1 - region.y0 + 1);
8585
8654
  DisplayCommandDrawer::replay(c);
8586
8655
  gea::platform::display::Display::popClip();
8587
- perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0;
8656
+ GEA_REFRESH_PERF(perf.treeReplayCommandClipUs += refreshPerfNowUs() - t0);
8588
8657
  }
8589
8658
 
8590
8659
  static bool commandRangeOverlapsAnyRegion(int start, int end, const DisplayReplayRegion *regions, int count)
@@ -8636,7 +8705,7 @@ int gLastScrollUiFrame = -1000;
8636
8705
  for (int ci = start; ci < end; ci++)
8637
8706
  {
8638
8707
  DisplayCommand *c = &state.commands[ci];
8639
- refreshPerfStatsMutable().treeReplayCommandChecks++;
8708
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayCommandChecks++);
8640
8709
  if (c->type == DisplayCommandType::SetAlpha)
8641
8710
  {
8642
8711
  roundedRects.flush();
@@ -8670,7 +8739,7 @@ int gLastScrollUiFrame = -1000;
8670
8739
 
8671
8740
  static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count, bool allowSplit = true)
8672
8741
  {
8673
- refreshPerfStatsMutable().treeReplayDirectRegionsCalls++;
8742
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayDirectRegionsCalls++);
8674
8743
  if (!regions || count <= 0)
8675
8744
  return;
8676
8745
  auto *canvas = gea::platform::display::Display::canvas();
@@ -8766,10 +8835,10 @@ int gLastScrollUiFrame = -1000;
8766
8835
  const Ctx *c = static_cast<const Ctx *>(p);
8767
8836
  replayDirectDirtyRegions(c->regions, c->count, /*allowSplit=*/false);
8768
8837
  };
8769
- refreshPerfStatsMutable().treeReplayParallelAttempts++;
8838
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelAttempts++);
8770
8839
  if (gea_render_parallel_submit(run, &ctx, mid + 1, maxY))
8771
8840
  {
8772
- refreshPerfStatsMutable().treeReplayParallelSuccesses++;
8841
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayParallelSuccesses++);
8773
8842
  replayDirectDirtyRegions(topR, count, /*allowSplit=*/false); // top band, this core
8774
8843
  gea_render_parallel_wait();
8775
8844
  gea_render_parallel_merge_dirty();
@@ -8815,9 +8884,9 @@ int gLastScrollUiFrame = -1000;
8815
8884
  if (!useBackdrop && retainedBackgroundNodeCanBeSkippedInRegions(node_id, regions, count))
8816
8885
  continue;
8817
8886
  Node *n = &nodes[node_id];
8818
- if (n->style.display == 1)
8887
+ if (n->computedStyle().display == 1)
8819
8888
  continue;
8820
- if (n->style.blink_interval_ms > 0 && !n->style.blink_visible)
8889
+ if (n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible)
8821
8890
  continue;
8822
8891
  // Skip only nodes whose pixels the backdrop blit actually covers (baked at
8823
8892
  // bake time). Dirty nodes and bake-EXCLUDED nodes (recently-changed ticker
@@ -9012,10 +9081,10 @@ int gLastScrollUiFrame = -1000;
9012
9081
  {
9013
9082
  const auto *nodes = Tree::instance().nodes();
9014
9083
  const auto &n = nodes[id];
9015
- const bool item = n.parent >= 0 && !isOutOfFlowPosition(n.style.position) &&
9016
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
9017
- return n.parent < 0 || n.style.position == kPositionFixed || ChildZSorter::effectGroup(n) ||
9018
- (!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));
9019
9088
  }
9020
9089
 
9021
9090
  bool PaintOrder::isGroup(int id)
@@ -9023,8 +9092,8 @@ int gLastScrollUiFrame = -1000;
9023
9092
  const auto *nodes = Tree::instance().nodes();
9024
9093
  const auto &n = nodes[id];
9025
9094
  const bool item = n.parent >= 0 &&
9026
- (nodes[n.parent].style.display == kDisplayFlex || isDisplayGrid(nodes[n.parent].style));
9027
- 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;
9028
9097
  }
9029
9098
 
9030
9099
  std::vector<int> PaintOrder::collectChildren(int root, bool groupRoot, bool includePositioned)
@@ -9040,18 +9109,18 @@ int gLastScrollUiFrame = -1000;
9040
9109
  auto walk = [&](auto &&self, int parent, bool withinGroup) -> void {
9041
9110
  std::vector<int> children;
9042
9111
  for (int child = nodes[parent].first_child; child >= 0; child = nodes[child].next_sibling)
9043
- if (!isDisplayNone(nodes[child].style)) children.push_back(child);
9044
- 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())) {
9045
9114
  std::stable_sort(children.begin(), children.end(), [&](int a, int b) {
9046
- const int oa = isOutOfFlowPosition(nodes[a].style.position) ? 0 : nodes[a].style.order;
9047
- 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;
9048
9117
  return oa < ob;
9049
9118
  });
9050
9119
  }
9051
9120
  for (int child : children) {
9052
9121
  const auto &n = nodes[child];
9053
- if (n.style.blink_interval_ms > 0 && !n.style.blink_visible) continue;
9054
- 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;
9055
9124
  const bool group = isGroup(child);
9056
9125
  if (positioned) {
9057
9126
  if (includePositioned) result.push_back(child);
@@ -9443,7 +9512,7 @@ int gLastScrollUiFrame = -1000;
9443
9512
  for (int i = 0; i < state.drawNodeOrderCount; ++i)
9444
9513
  if (state.drawNodeOrder[i] < 0 || state.drawNodeOrder[i] >= nodeCount) return false;
9445
9514
  for (int id = 0; id < nodeCount; ++id) {
9446
- 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;
9447
9516
  const bool wasRecorded = state.nodeDrawStart[id] >= 0;
9448
9517
  if (wasRecorded == ViewRenderer::backfaceSubtreeHidden(nodes[id])) return false;
9449
9518
  }
@@ -9804,9 +9873,9 @@ int gLastScrollUiFrame = -1000;
9804
9873
 
9805
9874
  for (int i = 0; i < tree.nodeCount(); i++)
9806
9875
  {
9807
- if (rstyle(nodes[i].style).filter_blur_radius > 0)
9876
+ if ((GEA_CSS_FILTERS ? rstyle(nodes[i].computedStyle()).filter_blur_radius : 0) > 0)
9808
9877
  return false;
9809
- if (nodes[i].style.overflow == 2)
9878
+ if (nodes[i].computedStyle().overflow == 2)
9810
9879
  return false;
9811
9880
  }
9812
9881
  (void)width;
@@ -9923,12 +9992,18 @@ int gLastScrollUiFrame = -1000;
9923
9992
  for (int ci = start; ci < end; ci++)
9924
9993
  DisplayCommandTranslator::translate(&state.commands[ci], dx, dy);
9925
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;
9926
9998
  // PushClip/PopClip wrap the node's descendants, so recordNode deliberately
9927
9999
  // emits them outside [nodeDrawStart,nodeDrawEnd]. Move those retained scope
9928
10000
  // commands explicitly; otherwise a translated overflow:hidden subtree is
9929
10001
  // intersected with the clip at its old position.
9930
10002
  for (int ci = 0; ci < state.commandCount; ci++)
9931
10003
  {
10004
+ #if GEA_EMBEDDED_UI_REFRESH_PERF
10005
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeTranslateClipChecks++);
10006
+ #endif
9932
10007
  DisplayCommand &command = state.commands[ci];
9933
10008
  if ((command.type == DisplayCommandType::PushClip || command.type == DisplayCommandType::PopClip) &&
9934
10009
  command.clip.nodeId == node)
@@ -10056,7 +10131,7 @@ int gLastScrollUiFrame = -1000;
10056
10131
  for (int a = LayoutEngine::isViewportFixed(nodes[id]) ? -1 : nodes[id].parent; a >= 0 && a < nodeCount; a = nodes[a].parent)
10057
10132
  {
10058
10133
  const Node &ancestor = nodes[a];
10059
- 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)
10060
10135
  {
10061
10136
  if (LayoutEngine::isViewportFixed(ancestor)) break;
10062
10137
  continue;
@@ -10122,8 +10197,8 @@ int gLastScrollUiFrame = -1000;
10122
10197
  continue;
10123
10198
  const Node &probe = nodes[id];
10124
10199
  const bool paintsBox =
10125
- (probe.style.has_bg && (probe.style.bg_alpha > 0 || styleHasBackgroundImage(probe.style))) ||
10126
- rstyle(probe.style).box_shadow_alpha > 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;
10127
10202
  if (!paintsBox)
10128
10203
  continue;
10129
10204
  }
@@ -10149,8 +10224,8 @@ int gLastScrollUiFrame = -1000;
10149
10224
  for (int cursor = id; cursor >= 0 && cursor < tree.nodeCount(); cursor = nodes[cursor].parent)
10150
10225
  {
10151
10226
  const Node &a = nodes[cursor];
10152
- if (a.style.display == 1 || a.style.opacity == 0 ||
10153
- (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))
10154
10229
  {
10155
10230
  hiddenOrOutside = true;
10156
10231
  break;
@@ -10318,9 +10393,9 @@ int gLastScrollUiFrame = -1000;
10318
10393
  if (paintNode < 0 || paintNode >= nodeCount)
10319
10394
  continue;
10320
10395
  const Node &paint = nodes[paintNode];
10321
- if (paint.style.display == 1)
10396
+ if (paint.computedStyle().display == 1)
10322
10397
  continue;
10323
- if (paint.style.blink_interval_ms > 0 && !paint.style.blink_visible)
10398
+ if (paint.computedStyle().blink_interval_ms > 0 && !paint.computedStyle().blink_visible)
10324
10399
  continue;
10325
10400
  DisplayCommandReplayer::replayNodeCommandRangeInRegions(paintNode, &region, 1, roundedRects);
10326
10401
  }
@@ -11143,9 +11218,9 @@ int gLastScrollUiFrame = -1000;
11143
11218
  if (nodeId < 0 || nodeId >= tree.nodeCount())
11144
11219
  continue;
11145
11220
  const Node &node = nodes[nodeId];
11146
- if (node.style.display == 1)
11221
+ if (node.computedStyle().display == 1)
11147
11222
  continue;
11148
- if (node.style.blink_interval_ms > 0 && !node.style.blink_visible)
11223
+ if (node.computedStyle().blink_interval_ms > 0 && !node.computedStyle().blink_visible)
11149
11224
  continue;
11150
11225
  if (!state.hasNodeScratchFor(nodeId))
11151
11226
  continue;
@@ -11838,9 +11913,9 @@ int gLastScrollUiFrame = -1000;
11838
11913
  const int dirtyY0 = dMain.y0;
11839
11914
  const int dirtyX1 = dMain.x1;
11840
11915
  const int dirtyY1 = dMain.y1;
11841
- refreshPerfStatsMutable().treeBgRecolorFastPixels += dMain.fastPixels;
11842
- refreshPerfStatsMutable().treeBgRecolorFillUs += dMain.fillUs;
11843
- refreshPerfStatsMutable().treeBgRecolorEdgeUs += dMain.edgeUs;
11916
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorFastPixels += dMain.fastPixels);
11917
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorFillUs += dMain.fillUs);
11918
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorEdgeUs += dMain.edgeUs);
11844
11919
  if (dirtyX0 > dirtyX1 || dirtyY0 > dirtyY1)
11845
11920
  return false;
11846
11921
  canvas->markDirty(dirtyX0, dirtyY0, dirtyX1, dirtyY1);
@@ -11853,9 +11928,9 @@ int gLastScrollUiFrame = -1000;
11853
11928
  if (!replayLaterOverlappingCommands(node, region))
11854
11929
  return false;
11855
11930
  replayUs = refreshPerfNowUs() - replayStartUs;
11856
- refreshPerfStatsMutable().treeBgRecolorReplayUs += replayUs;
11931
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorReplayUs += replayUs);
11857
11932
  }
11858
- refreshPerfStatsMutable().treeBgRecolorUs += refreshPerfNowUs() - totalStartUs;
11933
+ GEA_REFRESH_PERF(refreshPerfStatsMutable().treeBgRecolorUs += refreshPerfNowUs() - totalStartUs);
11859
11934
  if (outX0)
11860
11935
  *outX0 = dirtyX0;
11861
11936
  if (outY0)
@@ -12159,9 +12234,9 @@ int gLastScrollUiFrame = -1000;
12159
12234
  if (nodeId < 0 || nodeId >= tree.nodeCount())
12160
12235
  continue;
12161
12236
  const Node &n = nodes[nodeId];
12162
- if (n.style.display == 1)
12237
+ if (n.computedStyle().display == 1)
12163
12238
  continue;
12164
- if (n.style.blink_interval_ms > 0 && !n.style.blink_visible)
12239
+ if (n.computedStyle().blink_interval_ms > 0 && !n.computedStyle().blink_visible)
12165
12240
  continue;
12166
12241
  if (!state.hasNodeScratchFor(nodeId))
12167
12242
  continue;
@@ -12254,10 +12329,10 @@ int gLastScrollUiFrame = -1000;
12254
12329
  // an empty range, which `old_len == 0 && tmp_len > 0` below (correctly) refuses
12255
12330
  // to splice — and the refusal cost the whole frame its retained display list.
12256
12331
  const bool outsideRecordClip = !isDocumentCanvasRoot(*n) && nodeOutsideRecordClip(node, tree.mountedWidth(), tree.mountedHeight());
12257
- if (!outsideRecordClip && n->style.visibility == 0 && !isCollapsedFlexSubtree(*n) && !ViewRenderer::backfaceSubtreeHidden(*n) &&
12258
- n->style.display != 1 &&
12259
- n->style.opacity != 0 &&
12260
- !(n->style.blink_interval_ms > 0 && !n->style.blink_visible) &&
12332
+ if (!outsideRecordClip && n->computedStyle().visibility == 0 && !isCollapsedFlexSubtree(*n) && !ViewRenderer::backfaceSubtreeHidden(*n) &&
12333
+ n->computedStyle().display != 1 &&
12334
+ n->computedStyle().opacity != 0 &&
12335
+ !(n->computedStyle().blink_interval_ms > 0 && !n->computedStyle().blink_visible) &&
12261
12336
  !isNativeTextInputView(*n))
12262
12337
  {
12263
12338
  ViewRenderer::recordBox(*n);
@@ -12316,6 +12391,7 @@ int gLastScrollUiFrame = -1000;
12316
12391
 
12317
12392
  bool DisplayList::patchScrollbarThumb(int node)
12318
12393
  {
12394
+ #if GEA_CSS_SCROLLING
12319
12395
  Tree &tree = Tree::instance();
12320
12396
  Node *nodes = tree.nodes();
12321
12397
  if (!state.commands || node < 0 || node >= tree.nodeCount())
@@ -12324,7 +12400,7 @@ int gLastScrollUiFrame = -1000;
12324
12400
 
12325
12401
  // Mirror of ViewRenderer::recordScrollbar's geometry. Cases where no
12326
12402
  // thumb is ever recorded are a successful no-op, not a failure.
12327
- if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->style)))
12403
+ if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->computedStyle())))
12328
12404
  return true;
12329
12405
  if (n->layout.height <= 0 || n->layout.scroll_content_height <= n->layout.height)
12330
12406
  return true;
@@ -12362,7 +12438,10 @@ int gLastScrollUiFrame = -1000;
12362
12438
  return true;
12363
12439
  }
12364
12440
  return false;
12365
- }
12441
+ #else
12442
+ (void)node; return true;
12443
+ #endif
12444
+ }
12366
12445
 
12367
12446
  void DisplayList::replayDirectDirtyRegion(int x0, int y0, int x1, int y1, int origin)
12368
12447
  {
@@ -12391,7 +12470,10 @@ int gLastScrollUiFrame = -1000;
12391
12470
  const int root = tree.mountedRoot();
12392
12471
  if (root >= 0 && root < tree.nodeCount() && isDocumentCanvasRoot(tree.nodes()[root]))
12393
12472
  DisplayCommandReplayer::restoreClearBaseInRegion(x0, y0, x1, y1);
12394
- DisplayCommandReplayer::replaySimpleClippedDirtyRegion(x0, y0, x1, y1, origin);
12473
+ // The caller owns the active clip and may have rebound the canvas onto a DMA
12474
+ // chunk. The worker canvas has neither that binding nor the clip, so this
12475
+ // already-clipped entry must stay on the submitting canvas.
12476
+ DisplayCommandReplayer::replaySimpleClippedDirtyRegion(x0, y0, x1, y1, origin, /*allowSplit=*/false);
12395
12477
  }
12396
12478
 
12397
12479
  void DisplayList::maybeBakeStaticBackdrop(int width, int height, bool stableThisFrame, bool directReplay,