@geastack/engine 0.1.14 → 0.1.16

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.
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "absolute_leaf_refresh.h"
3
3
  #include "dirty_regions.h"
4
+ #include "debugger_overlay.h"
5
+ #include "canvas_element.h"
4
6
  #include "display.h"
5
7
  #include "display_underlay.h"
6
8
  #include "document.h"
@@ -1669,6 +1671,7 @@ namespace gea::embedded::ui
1669
1671
  state.canvases.forEach([](CanvasSurfaceState &surface)
1670
1672
  {
1671
1673
  if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
1674
+ CanvasRenderingContext2D::clearRetainedCanvasDamage();
1672
1675
  GEA_REFRESH_PERF(refreshPerfStatsMutable().treePanReplayCalls++);
1673
1676
  if (directRegions > 0)
1674
1677
  GEA_REFRESH_PERF(refreshPerfStatsMutable().treeDirectReplayCalls++);
@@ -1694,10 +1697,32 @@ namespace gea::embedded::ui
1694
1697
  }
1695
1698
  #endif
1696
1699
 
1700
+ bool gSnapshotRasterActive = false;
1701
+
1697
1702
  bool renderRetainedSnapshotRgb565(std::uint16_t *dst, int width, int height)
1698
1703
  {
1699
1704
  if (!dst || width <= 0 || height <= 0)
1700
1705
  return false;
1706
+ struct SnapshotRasterScope
1707
+ {
1708
+ bool previous = gSnapshotRasterActive;
1709
+ bool rebound = false;
1710
+ #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1711
+ bool previousBanded = gBandedRasterActive;
1712
+ #endif
1713
+
1714
+ SnapshotRasterScope() { gSnapshotRasterActive = true; }
1715
+
1716
+ ~SnapshotRasterScope()
1717
+ {
1718
+ if (rebound)
1719
+ gea::platform::display::Display::rebindCanvasToFramebuffer();
1720
+ gSnapshotRasterActive = previous;
1721
+ #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1722
+ gBandedRasterActive = previousBanded;
1723
+ #endif
1724
+ }
1725
+ } scope;
1701
1726
  #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1702
1727
  // A banded frame lives only on the panel: render it again the way the
1703
1728
  // bands did — black base, the underlay, then the whole display list.
@@ -1710,6 +1735,7 @@ namespace gea::embedded::ui
1710
1735
  PixT *base = reinterpret_cast<PixT *>(dst);
1711
1736
  std::fill_n(base, static_cast<std::size_t>(width) * static_cast<std::size_t>(height),
1712
1737
  gea::framework::graphics::pixel::fromRgb565(0x0000));
1738
+ scope.rebound = true;
1713
1739
  bandCanvas->bindPixels(base, width, height, width);
1714
1740
  gea::platform::display::Display::resetClip();
1715
1741
  gea::platform::display::Display::setAlpha(255);
@@ -1718,7 +1744,6 @@ namespace gea::embedded::ui
1718
1744
  bandedReplayRegion(0, 0, width - 1, height - 1, /*direct=*/false);
1719
1745
  gBandedRasterActive = false;
1720
1746
  gea::platform::display::Display::popClip();
1721
- gea::platform::display::Display::rebindCanvasToFramebuffer();
1722
1747
  const int pixels = width * height;
1723
1748
  for (int i = 0; i < pixels; i++)
1724
1749
  dst[i] = gea::framework::graphics::pixel::toRgb565(base[i]);
@@ -1732,6 +1757,9 @@ namespace gea::embedded::ui
1732
1757
  return false;
1733
1758
  using PixT = gea::framework::graphics::pixel::native_t;
1734
1759
  PixT *base = reinterpret_cast<PixT *>(dst);
1760
+ std::fill_n(base, static_cast<std::size_t>(width) * static_cast<std::size_t>(height),
1761
+ gea::framework::graphics::pixel::fromRgb565(0x0000));
1762
+ scope.rebound = true;
1735
1763
  canvas->bindPixels(base, width, height, width);
1736
1764
  gea::platform::display::Display::resetClip();
1737
1765
  gea::platform::display::Display::setAlpha(255);
@@ -1743,12 +1771,19 @@ namespace gea::embedded::ui
1743
1771
  // (rows recorded beyond the scroll viewport printed above it in every
1744
1772
  // snapshot, reading as a phantom on-screen ghost during debugging).
1745
1773
  {
1746
- const DisplayReplayRegion region{0, 0, width - 1, height - 1, -1};
1747
- DisplayList::instance().replayDirectDirtyRegions(&region, 1);
1774
+ #if defined(GEA_NATIVE_DEBUGGER) && GEA_NATIVE_DEBUGGER
1775
+ // Highlights append commands outside node paint ranges. Their forced
1776
+ // full record includes ancestor clips, so replay that complete stream.
1777
+ if (debuggerOverlay.slot >= 0)
1778
+ DisplayList::instance().replay();
1779
+ else
1780
+ #endif
1781
+ {
1782
+ const DisplayReplayRegion region{0, 0, width - 1, height - 1, -1};
1783
+ DisplayList::instance().replayDirectDirtyRegions(&region, 1);
1784
+ }
1748
1785
  }
1749
1786
  gea::platform::display::Display::popClip();
1750
- // Restore the shared canvas onto the real framebuffer before the frame task resumes.
1751
- gea::platform::display::Display::rebindCanvasToFramebuffer();
1752
1787
  const int pixels = width * height;
1753
1788
  for (int i = 0; i < pixels; i++)
1754
1789
  dst[i] = gea::framework::graphics::pixel::toRgb565(base[i]);
@@ -1856,6 +1891,7 @@ namespace gea::embedded::ui
1856
1891
  state.canvases.forEach([](CanvasSurfaceState &surface)
1857
1892
  {
1858
1893
  if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
1894
+ CanvasRenderingContext2D::clearRetainedCanvasDamage();
1859
1895
  LayoutSnapshot::capture();
1860
1896
  }
1861
1897
 
@@ -2014,6 +2050,24 @@ namespace gea::embedded::ui
2014
2050
  }
2015
2051
  return -1;
2016
2052
  }
2053
+ // A transformed parent re-records its whole subtree (its descendants'
2054
+ // corners all move). When no descendant paints anything -- the empty slot
2055
+ // of `{done ? <img/> : null}` inside a pulsing dot -- there is nothing to
2056
+ // move, and the node's own commands re-record in place like a leaf's. A
2057
+ // descendant that starts painting cannot splice into its empty range, so
2058
+ // rerecordNodeCommands refuses and the frame still falls back to a full
2059
+ // record. Ember's flow dot otherwise rebuilt the whole list every frame.
2060
+ bool descendantsPaintNothing(TreeState &state, int node)
2061
+ {
2062
+ for (int child = state.nodes[node].first_child; child >= 0; child = state.nodes[child].next_sibling)
2063
+ {
2064
+ if (DisplayList::instance().nodeCommandCount(child) != 0)
2065
+ return false;
2066
+ if (!descendantsPaintNothing(state, child))
2067
+ return false;
2068
+ }
2069
+ return true;
2070
+ }
2017
2071
  } // namespace
2018
2072
 
2019
2073
  void Tree::refresh(int root, int width, int height)
@@ -2024,6 +2078,9 @@ namespace gea::embedded::ui
2024
2078
  auto &state = treeState();
2025
2079
  if (root < 0 || root >= state.nodeCount)
2026
2080
  return;
2081
+ #if defined(GEA_NATIVE_DEBUGGER) && GEA_NATIVE_DEBUGGER
2082
+ debuggerOverlay.prepare();
2083
+ #endif
2027
2084
  const bool viewportChanged = gLayoutViewportRoot != root ||
2028
2085
  gLayoutViewportWidth != width || gLayoutViewportHeight != height;
2029
2086
  if (viewportChanged) {
@@ -2046,7 +2103,7 @@ namespace gea::embedded::ui
2046
2103
  // that must take the framebuffer path after banded ones first repaints the
2047
2104
  // whole viewport into it: a structural rebuild does exactly that.
2048
2105
  const bool banded = bandedUiEligible();
2049
- const bool framebufferReadable = !banded && !gBandedFramebufferStaleFlag;
2106
+ const bool framebufferReadable = !GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH && !banded && !gBandedFramebufferStaleFlag;
2050
2107
  if (!banded && gBandedFramebufferStaleFlag)
2051
2108
  {
2052
2109
  state.displayListDirty = true;
@@ -2057,7 +2114,7 @@ namespace gea::embedded::ui
2057
2114
  }
2058
2115
  #else
2059
2116
  constexpr bool banded = false;
2060
- constexpr bool framebufferReadable = true;
2117
+ constexpr bool framebufferReadable = !GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH;
2061
2118
  #endif
2062
2119
  const bool textClipDependencies = DisplayList::instance().hasTextClippedBackgrounds();
2063
2120
  if (textClipDependencies) {
@@ -2076,6 +2133,27 @@ namespace gea::embedded::ui
2076
2133
  if (framebufferReadable && !textClipDependencies && state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
2077
2134
  return;
2078
2135
 
2136
+ bool scrollFallbackRepaint = false;
2137
+ #if GEA_CSS_SCROLLING
2138
+ // A rejected scroll blit still moves every descendant's geometry during
2139
+ // layout. The reflow guard deliberately leaves those descendants clean
2140
+ // when their movement equals the ancestor scroll delta, so their retained
2141
+ // commands cannot be left unchanged on this fallback path. Re-record the
2142
+ // existing tree and repaint its underlay: a transparent scroller has no
2143
+ // background command capable of erasing the previous content. Fused flush
2144
+ // also cannot blit its stale PSRAM framebuffer; it draws directly into DMA.
2145
+ for (int i = 0; i < state.nodeCount; ++i) {
2146
+ const Node &node = state.nodes[i];
2147
+ if (node.render.scroll_dirty &&
2148
+ (node.layout.scroll_x != node.layout.previous_scroll_x ||
2149
+ node.layout.scroll_y != node.layout.previous_scroll_y)) {
2150
+ markDisplayListContentDirty();
2151
+ scrollFallbackRepaint = true;
2152
+ break;
2153
+ }
2154
+ }
2155
+ #endif
2156
+
2079
2157
  // This frame is NOT a pure scroll, so the software scroll register's
2080
2158
  // circular row rotation (engaged by Display::scrollRect during the fast
2081
2159
  // path above) must not survive into it: content drawn now would mix
@@ -2411,7 +2489,8 @@ namespace gea::embedded::ui
2411
2489
  continue;
2412
2490
  if (layoutSizeChangeNeedsCommandRerecord(*n))
2413
2491
  state.nodeCommandDirty[i] = 1;
2414
- if (state.nodeCommandDirty[i] && n->render.transform_dirty && n->first_child >= 0)
2492
+ if (state.nodeCommandDirty[i] && n->render.transform_dirty && n->first_child >= 0 &&
2493
+ !descendantsPaintNothing(state, i))
2415
2494
  {
2416
2495
  rebuild_for_transform = 1;
2417
2496
  continue;
@@ -2542,6 +2621,10 @@ namespace gea::embedded::ui
2542
2621
  GEA_REFRESH_PERF(perf.treeRecordedNodes += state.nodeCount);
2543
2622
  GEA_REFRESH_PERF(perf.treeRecordedCommands += DisplayList::instance().commandCount());
2544
2623
  }
2624
+ #if defined(GEA_NATIVE_DEBUGGER) && GEA_NATIVE_DEBUGGER
2625
+ if (displayListFullRecord)
2626
+ debuggerOverlay.record(root, width, height);
2627
+ #endif
2545
2628
  if (displayListFullRecord)
2546
2629
  GEA_REFRESH_PERF(perf.treeFullRecords++);
2547
2630
  if (reprojected)
@@ -2564,6 +2647,12 @@ namespace gea::embedded::ui
2564
2647
  int flush_rect_count = 0;
2565
2648
  bool preserveFlushOnlyRecolorRegions = false;
2566
2649
  const std::int64_t dirtyCollectStartUs = refreshPerfNowUs();
2650
+ // A fresh content-only recording is just as replayable as retained
2651
+ // commands. Re-evaluate the compositing guard after recording rather
2652
+ // than forcing unrelated static content into the general path merely
2653
+ // because an empty image range needed its first command.
2654
+ if (displayListFullRecord && !display_list_was_structural)
2655
+ direct_replay = DisplayList::instance().canReplayDirectDirtyRegions(width, height);
2567
2656
  if (framebuffer_was_dirty)
2568
2657
  direct_replay = 0;
2569
2658
  const int transformedShapeCount = transformedLeafDirtyShapeCount();
@@ -2606,9 +2695,67 @@ namespace gea::embedded::ui
2606
2695
  int canvas_x0 = 0, canvas_y0 = 0, canvas_x1 = -1, canvas_y1 = -1;
2607
2696
  const auto *canvas_surface = n->type == NodeType::Canvas ? state.canvases.find(i) : nullptr;
2608
2697
  const auto *canvas = canvas_surface ? canvas_surface->canvas() : nullptr;
2609
- const bool canvas_dirty = canvas_surface &&
2610
- canvas &&
2611
- canvas->dirty(&canvas_x0, &canvas_y0, &canvas_x1, &canvas_y1);
2698
+ const bool bitmap_canvas_dirty =
2699
+ canvas_surface && canvas && canvas->dirty(&canvas_x0, &canvas_y0, &canvas_x1, &canvas_y1);
2700
+ int retained_x0, retained_y0, retained_x1, retained_y1;
2701
+ const bool retained_canvas_dirty =
2702
+ n->type == NodeType::Canvas && CanvasRenderingContext2D::retainedCanvasDamage(
2703
+ i, retained_x0, retained_y0, retained_x1, retained_y1);
2704
+ bool canvas_dirty = bitmap_canvas_dirty || retained_canvas_dirty;
2705
+
2706
+ // Drawing into an unchanged owned bitmap cannot spill beyond its pixels.
2707
+ // CSS antialiasing guards belong to style/geometry changes, not this damage.
2708
+ bool exactCanvasPixelDamage =
2709
+ canvas_dirty &&
2710
+ (retained_canvas_dirty || (canvas_surface && !canvas_surface->displayBacked())) &&
2711
+ n->render.canvas_pixels_only_dirty && !n->render.layout_dirty && !n->render.transform_dirty &&
2712
+ n->first_child < 0 && n->layout.x == n->layout.previous_x &&
2713
+ n->layout.y == n->layout.previous_y && n->layout.width == n->layout.previous_width &&
2714
+ n->layout.height == n->layout.previous_height &&
2715
+ (retained_canvas_dirty ||
2716
+ (canvas && canvas->width() == n->layout.width && canvas->height() == n->layout.height)) &&
2717
+ !ViewRenderer::anyTransformActive();
2718
+ int canvasAncestorSteps = 0;
2719
+ for (int ancestor = i; exactCanvasPixelDamage && ancestor >= 0;
2720
+ ancestor = state.nodes[ancestor].parent)
2721
+ {
2722
+ if (ancestor >= state.nodeCount || ++canvasAncestorSteps > state.nodeCount)
2723
+ {
2724
+ exactCanvasPixelDamage = false;
2725
+ break;
2726
+ }
2727
+ const auto &owner = state.nodes[ancestor];
2728
+ const auto &style = owner.computedStyle();
2729
+ exactCanvasPixelDamage = !hasAnyBorder(style) && style.mask_right_fade_width == 0 &&
2730
+ (GEA_CSS_FILTERS ? rstyle(style).filter_blur_radius : 0) <= 0 &&
2731
+ owner.render.previous_filter_blur_radius <= 0 &&
2732
+ (GEA_CSS_BOX_SHADOW ? rstyle(style).box_shadow_alpha : 0) == 0;
2733
+ }
2734
+
2735
+ if (retained_canvas_dirty && exactCanvasPixelDamage)
2736
+ {
2737
+ if (bitmap_canvas_dirty)
2738
+ {
2739
+ canvas_x0 = std::min(canvas_x0, retained_x0);
2740
+ canvas_y0 = std::min(canvas_y0, retained_y0);
2741
+ canvas_x1 = std::max(canvas_x1, retained_x1);
2742
+ canvas_y1 = std::max(canvas_y1, retained_y1);
2743
+ }
2744
+ else
2745
+ {
2746
+ canvas_x0 = retained_x0;
2747
+ canvas_y0 = retained_y0;
2748
+ canvas_x1 = retained_x1;
2749
+ canvas_y1 = retained_y1;
2750
+ }
2751
+ }
2752
+ if (canvas_dirty && !exactCanvasPixelDamage)
2753
+ {
2754
+ // A style/geometry invalidation is not a content-only repaint. Both
2755
+ // bitmap and retained hints must yield to full previous/current boxes;
2756
+ // otherwise a moved canvas leaves its old fringe behind.
2757
+ canvas_dirty = false;
2758
+ }
2612
2759
 
2613
2760
  // Glyph-incremental text dirty: setText found that only a middle run of glyphs
2614
2761
  // changed within an unchanged box. Flush just that run across the node's height
@@ -2878,13 +3025,15 @@ namespace gea::embedded::ui
2878
3025
  // replaying overlapping siblings, such as overlay labels, in the
2879
3026
  // original draw order.
2880
3027
  const DirtyRegions::Rect dirtyRect =
2881
- dirtyRectWithRasterGuard(*n, DirtyRegions::Rect{dr_x0, dr_y0, dr_x1, dr_y1, i});
3028
+ exactCanvasPixelDamage ? DirtyRegions::Rect{dr_x0, dr_y0, dr_x1, dr_y1, i}
3029
+ : dirtyRectWithRasterGuard(*n, DirtyRegions::Rect{dr_x0, dr_y0, dr_x1, dr_y1, i});
2882
3030
  addDirtyRegion(rects, &rect_count, dirtyRect, width, height);
2883
3031
  if (!unifiedRectPath)
2884
3032
  addDirtyRegion(flush_rects, &flush_rect_count, dirtyRect, width, height);
2885
3033
  }
2886
- if (display_list_was_dirty && display_list_was_structural && width > 0 && height > 0)
3034
+ if (((display_list_was_dirty && display_list_was_structural) || scrollFallbackRepaint) && width > 0 && height > 0)
2887
3035
  {
3036
+ // A scroll fallback must erase old content through its root underlay.
2888
3037
  // A STRUCTURAL command-list rebuild can change draw order, alpha scopes,
2889
3038
  // or which commands exist. Repaint the viewport once so the framebuffer
2890
3039
  // matches the rebuilt scene instead of relying on stale incremental
@@ -3015,8 +3164,14 @@ namespace gea::embedded::ui
3015
3164
  }
3016
3165
  #endif
3017
3166
  const bool hasFlushOnlyRecolorRegions = preserveFlushOnlyRecolorRegions && flush_rect_count > 0;
3167
+ DisplayReplayRegion simpleTransferRegions[DirtyRegions::kMaxRects];
3168
+ for (int i = 0; i < flush_rect_count; ++i)
3169
+ {
3170
+ const auto &r = flush_rects[i];
3171
+ simpleTransferRegions[i] = DisplayReplayRegion{r.x0, r.y0, r.x1, r.y1, -1};
3172
+ }
3018
3173
  const bool simpleDirtyReplayAvailable =
3019
- direct_replay && unifiedRectPath && DisplayList::instance().canReplaySimpleDirtyRegions(width, height);
3174
+ direct_replay && unifiedRectPath && DisplayList::instance().canReplaySimpleDirtyRegions(width, height, simpleTransferRegions, flush_rect_count);
3020
3175
  const bool simpleUnifiedReplay = simpleDirtyReplayAvailable && rect_count > 0 && !hasFlushOnlyRecolorRegions;
3021
3176
  const bool interleavedUnifiedFlush =
3022
3177
  direct_replay && unifiedRectPath && rect_count > 0 && !simpleDirtyReplayAvailable && !hasFlushOnlyRecolorRegions;
@@ -3349,6 +3504,7 @@ namespace gea::embedded::ui
3349
3504
  state.canvases.forEach([](CanvasSurfaceState &surface)
3350
3505
  {
3351
3506
  if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
3507
+ CanvasRenderingContext2D::clearRetainedCanvasDamage();
3352
3508
  #if !defined(GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT) || !GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT
3353
3509
  // displayCanvas is only declared when the direct-canvas context is off (see the
3354
3510
  // guard at its declaration above); with direct canvas it is always null, so the
@@ -3378,6 +3534,9 @@ namespace gea::embedded::ui
3378
3534
  if (timestamp_ms < 0)
3379
3535
  timestamp_ms = 0;
3380
3536
  state.lastFrameMs = timestamp_ms;
3537
+ #if defined(GEA_NATIVE_DEBUGGER) && GEA_NATIVE_DEBUGGER
3538
+ debuggerOverlay.prepare();
3539
+ #endif
3381
3540
 
3382
3541
  if (state.inputTickRequired)
3383
3542
  tickInput(timestamp_ms);
package/ui/tree_style.cpp CHANGED
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "display_invalidation.h"
3
+ #include <image.h>
3
4
  #include "internal.h"
4
5
  #include "node_lifecycle.h"
5
6
  #include "refresh_perf.h"
@@ -1052,7 +1053,15 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
1052
1053
  }
1053
1054
  #endif
1054
1055
  #if GEA_UI_IMAGE_NODES
1055
- case Property::ImageId: if (n->image_id != value) { n->image_id = value; changed = 1; } break;
1056
+ case Property::ImageId:
1057
+ if (n->image_id != value) {
1058
+ auto &images = gea::framework::graphics::ImageStore::instance();
1059
+ images.retain(value);
1060
+ images.release(n->image_id);
1061
+ n->image_id = value;
1062
+ changed = 1;
1063
+ }
1064
+ break;
1056
1065
  #endif
1057
1066
  #if GEA_CSS_IMAGE_FIT
1058
1067
  case Property::ImageFit: if (style.image_fit != value) { style.image_fit = value; changed = 1; } break;
@@ -1155,6 +1164,7 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
1155
1164
  GEA_REFRESH_PERF(perf.treeSetStylePaintChanged++);
1156
1165
  if (state.styleInvalidationSuppressionDepth > 0) return;
1157
1166
  if (!nodeParticipatesInMountedTree(state, node)) return;
1167
+ n->render.canvas_pixels_only_dirty = 0;
1158
1168
  const bool hadRecolor = n->render.bg_recolor_pending;
1159
1169
  const bool canRecolor = !n->render.dirty || hadRecolor;
1160
1170
  n->render.text_partial_dirty = 0;
@@ -1238,7 +1248,13 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
1238
1248
  // and recreating it during a fade. patchNodeAlpha returns false when
1239
1249
  // no scope exists (for example, an initially opaque or culled node),
1240
1250
  // so those cases still take the ordinary recording path below.
1241
- if (stayLocal &&
1251
+ const auto *textCommand = n->type == NodeType::Text && n->first_child < 0 &&
1252
+ DisplayList::instance().nodeCommandCount(node) == 1
1253
+ ? DisplayList::instance().nodeCommandAt(node, 0) : nullptr;
1254
+ const bool plainText = textCommand && textCommand->type == DisplayCommandType::DrawText &&
1255
+ n->layout.height >= std::max(16, static_cast<int>(style.font_size)) &&
1256
+ n->layout.height >= style.line_height;
1257
+ if ((stayLocal || plainText) &&
1242
1258
  DisplayList::instance().patchNodeAlpha(node, static_cast<uint8_t>(style.opacity)))
1243
1259
  return;
1244
1260
  // Crossing the 255 boundary (scope appears/disappears) or a non-leaf:
@@ -1264,7 +1280,12 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
1264
1280
  // full-viewport repaint). Display toggles (visibility/order) and
1265
1281
  // filter/box-shadow (pixel spillover past the node box) keep the
1266
1282
  // conservative full repaint.
1267
- if (prop == Property::Opacity)
1283
+ // Undersized text boxes can paint glyphs outside their layout damage
1284
+ // region. Their opacity fallback must clear that overflow as well.
1285
+ const bool overflowingText = n->type == NodeType::Text &&
1286
+ (n->layout.height < std::max(16, static_cast<int>(style.font_size)) ||
1287
+ n->layout.height < style.line_height);
1288
+ if (prop == Property::Opacity && !overflowingText)
1268
1289
  tree.markDisplayListContentDirty();
1269
1290
  else
1270
1291
  tree.markDisplayListDirty();
@@ -1315,6 +1336,7 @@ void Tree::resetStyleForClassRecompute(int node)
1315
1336
 
1316
1337
  state.nodes[node].resetComputedStyle();
1317
1338
  #if GEA_UI_IMAGE_NODES
1339
+ gea::framework::graphics::ImageStore::instance().release(state.nodes[node].image_id);
1318
1340
  state.nodes[node].image_id = -1;
1319
1341
  #endif
1320
1342
  if (state.styleInvalidationSuppressionDepth > 0) return;
package/ui/view.cpp CHANGED
@@ -1012,8 +1012,8 @@ public:
1012
1012
  {
1013
1013
  const RareStyle &r = rstyle(node.computedStyle());
1014
1014
  e.x = node.layout.x; e.y = node.layout.y; e.w = node.layout.width; e.h = node.layout.height;
1015
- e.ox = e.x + e.w * r.transform_origin_x * kInv1000f;
1016
- e.oy = e.y + e.h * r.transform_origin_y * kInv1000f;
1015
+ e.ox = e.x + resolveOriginOffset(r.transform_origin_x, e.w);
1016
+ e.oy = e.y + resolveOriginOffset(r.transform_origin_y, e.h);
1017
1017
  if (!hasTransformableBox(node)) {
1018
1018
  std::fill(std::begin(e.matrix), std::end(e.matrix), 0.0f);
1019
1019
  e.matrix[0] = e.matrix[4] = e.matrix[8] = 1.0f;
@@ -1043,8 +1043,8 @@ public:
1043
1043
  return;
1044
1044
  }
1045
1045
  const float w = node.layout.previous_width, h = node.layout.previous_height;
1046
- e.pOx = node.layout.previous_x + w*r.previous_transform_origin_x*kInv1000f;
1047
- e.pOy = node.layout.previous_y + h*r.previous_transform_origin_y*kInv1000f;
1046
+ e.pOx = node.layout.previous_x + resolveOriginOffset(r.previous_transform_origin_x, w);
1047
+ e.pOy = node.layout.previous_y + resolveOriginOffset(r.previous_transform_origin_y, h);
1048
1048
  fillLinear(e.previousMatrix, r.previous_transform_rotate_x, r.previous_transform_rotate_y, r.previous_transform_rotate,
1049
1049
  r.previous_transform_scale_x, r.previous_transform_scale_y, r.previous_transform_scale_z);
1050
1050
  auto shift = listTranslation({r.previous_transform_translate_x - r.previous_translate_x + w*(r.previous_transform_translate_x_percent-r.previous_translate_x_percent)*kInv1000f,
@@ -1168,8 +1168,8 @@ public:
1168
1168
  const auto &parent = state.nodes[id];
1169
1169
  const auto &rare = rstyle(parent.computedStyle());
1170
1170
  if (hasTransformableBox(parent) && rare.perspective > 0) {
1171
- const float ox = parent.layout.x + parent.layout.width * rare.perspective_origin_x * 0.001f;
1172
- const float oy = parent.layout.y + parent.layout.height * rare.perspective_origin_y * 0.001f;
1171
+ const float ox = parent.layout.x + resolveOriginOffset(rare.perspective_origin_x, parent.layout.width);
1172
+ const float oy = parent.layout.y + resolveOriginOffset(rare.perspective_origin_y, parent.layout.height);
1173
1173
  normal.z += (offset + normal.x * ox + normal.y * oy) / rare.perspective;
1174
1174
  }
1175
1175
  if (!hasTransformableBox(parent) || !preserves3D(parent.computedStyle())) break;
@@ -1272,8 +1272,8 @@ public:
1272
1272
  const int originX = usePrevious ? node.render.previous_perspective_origin_x : rs.perspective_origin_x;
1273
1273
  const int originY = usePrevious ? node.render.previous_perspective_origin_y : rs.perspective_origin_y;
1274
1274
  if (perspective <= 0) return;
1275
- const float poX = static_cast<float>(x) + static_cast<float>(w) * static_cast<float>(originX) * kInv1000f;
1276
- const float poY = static_cast<float>(y) + static_cast<float>(h) * static_cast<float>(originY) * kInv1000f;
1275
+ const float poX = static_cast<float>(x) + resolveOriginOffset(originX, w);
1276
+ const float poY = static_cast<float>(y) + resolveOriginOffset(originY, h);
1277
1277
  float scale = static_cast<float>(perspective) / (static_cast<float>(perspective) - p.z);
1278
1278
  if (!std::isfinite(scale)) scale = 1.0f;
1279
1279
  if (scale < 0.05f) scale = 0.05f;
@@ -1299,6 +1299,20 @@ public:
1299
1299
  long s = std::lroundf(v * 8.0f);
1300
1300
  return (int16_t)(s < -32768 ? -32768 : (s > 32767 ? 32767 : s));
1301
1301
  };
1302
+ // No transform or perspective anywhere up the chain: every ancestor's
1303
+ // coefficients are the identity about its origin, which returns integer
1304
+ // corners exactly. Skip gathering them -- a cache probe and coefficient
1305
+ // fill per ancestor, ~80 us for a 6-deep chain on the ESP32-S31, paid by
1306
+ // every untransformed image and text box re-recorded while anything else
1307
+ // on screen animates a transform.
1308
+ if (!hasTransformChain(node, usePrevious)) {
1309
+ for (int i = 0; i < 4; i++) {
1310
+ xs[i] = (int16_t)std::lroundf(points[i].x);
1311
+ ys[i] = (int16_t)std::lroundf(points[i].y);
1312
+ if (xs8) { xs8[i] = fx8(points[i].x); ys8[i] = fx8(points[i].y); }
1313
+ }
1314
+ return;
1315
+ }
1302
1316
  auto &state = treeState();
1303
1317
  const int perspectiveNode = nearestPerspectiveNode(node, usePrevious);
1304
1318
  const NodeTransformCache *chain[kMaxChainDepth];