@geastack/engine 0.1.12 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/engine",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/ui/render.cpp CHANGED
@@ -138,16 +138,6 @@ extern "C" __attribute__((weak)) void *gea_display_command_buffer(int *cap_comma
138
138
  return nullptr;
139
139
  }
140
140
 
141
- // Banded UI mode (GEA_EMBEDDED_DISPLAY_BANDED_UI) replays into a DMA staging
142
- // chunk the shared canvas is temporarily bound to; the worker core's canvas
143
- // still addresses the framebuffer, so no replay/fill may split across cores
144
- // while a band rasterizes. Constant true everywhere else.
145
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
146
- #define GEA_RENDER_SPLIT_ALLOWED (!gea::embedded::ui::gBandedRasterActive)
147
- #else
148
- #define GEA_RENDER_SPLIT_ALLOWED 1
149
- #endif
150
-
151
141
  // 2nd-core fill offload. The target may provide a worker pinned to the other CPU;
152
142
  // submit() hands it a row band (returns false if there's no worker), wait() joins.
153
143
  // Weak defaults = no worker, so the fill runs entirely on the calling core
@@ -3297,7 +3287,7 @@ int gLastScrollUiFrame = -1000;
3297
3287
  gSplitN = gInlineN = gSplitRows = gInlineRows = gMaxRows = 0;
3298
3288
  }
3299
3289
  };
3300
- if (GEA_RENDER_SPLIT_ALLOWED && rows >= kMinRowsToSplit)
3290
+ if (rows >= kMinRowsToSplit)
3301
3291
  {
3302
3292
  const int mid = (y0 + y1) >> 1;
3303
3293
  struct Trampoline
@@ -7921,7 +7911,7 @@ int gLastScrollUiFrame = -1000;
7921
7911
  constexpr int kMinPixelsToSplitFrame = GEA_EMBEDDED_RENDER_PARALLEL_MIN_PIXELS;
7922
7912
  const int regionW = x1 - x0 + 1;
7923
7913
  const int regionH = y1 - y0 + 1;
7924
- if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && GEA_RENDER_SPLIT_ALLOWED && allowSplit && regionW > 0 && regionH >= kMinRowsToSplitFrame &&
7914
+ if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && allowSplit && regionW > 0 && regionH >= kMinRowsToSplitFrame &&
7925
7915
  regionW * regionH >= kMinPixelsToSplitFrame)
7926
7916
  {
7927
7917
  int mainRows = (regionH * gea_render_parallel_main_share_permille()) / 1000;
@@ -8295,7 +8285,7 @@ int gLastScrollUiFrame = -1000;
8295
8285
  constexpr int kMinPixelsToSplitFrame = GEA_EMBEDDED_RENDER_PARALLEL_MIN_PIXELS;
8296
8286
  const int regionW = x1 - x0 + 1;
8297
8287
  const int regionH = y1 - y0 + 1;
8298
- if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && GEA_RENDER_SPLIT_ALLOWED && allowSplit && regionW > 0 && regionH >= kMinRowsToSplitFrame &&
8288
+ if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && allowSplit && regionW > 0 && regionH >= kMinRowsToSplitFrame &&
8299
8289
  regionW * regionH >= kMinPixelsToSplitFrame)
8300
8290
  {
8301
8291
  int mainRows = (regionH * gea_render_parallel_main_share_permille()) / 1000;
@@ -8811,7 +8801,7 @@ int gLastScrollUiFrame = -1000;
8811
8801
  constexpr int kMaxSplitRegions = 32;
8812
8802
  constexpr int kMinRowsToSplitFrame = GEA_EMBEDDED_RENDER_PARALLEL_MIN_ROWS;
8813
8803
  constexpr int kMinPixelsToSplitFrame = GEA_EMBEDDED_RENDER_PARALLEL_MIN_PIXELS;
8814
- if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && GEA_RENDER_SPLIT_ALLOWED && allowSplit && count <= kMaxSplitRegions)
8804
+ if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && allowSplit && count <= kMaxSplitRegions)
8815
8805
  {
8816
8806
  int minY = 0x7fffffff, maxY = -0x7fffffff;
8817
8807
  int totalArea = 0;
@@ -9,14 +9,6 @@
9
9
  #include <string>
10
10
  #include <string_view>
11
11
 
12
- // Framebuffer-free retained rendering: each dirty band is rasterized into the
13
- // display's internal-RAM DMA chunk and streamed to the panel while the next
14
- // band renders (tree_render.cpp). A board capability, set by the target's
15
- // CMake; off everywhere else, where it compiles out entirely.
16
- #ifndef GEA_EMBEDDED_DISPLAY_BANDED_UI
17
- #define GEA_EMBEDDED_DISPLAY_BANDED_UI 0
18
- #endif
19
-
20
12
  namespace gea::embedded::ui {
21
13
 
22
14
  class Tree {
@@ -215,17 +207,4 @@ void releaseRareData(int node); // frees the block back to the pool
215
207
  // Caller must hold AppState::lock(). Returns false for canvas/present apps.
216
208
  bool renderRetainedSnapshotRgb565(std::uint16_t *dst, int width, int height);
217
209
 
218
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
219
- // Banded UI mode: the retained tree renders each dirty band straight into the
220
- // display's DMA staging buffers, so the PSRAM framebuffer does not hold the
221
- // frame on the panel. True once a banded frame has been presented (until a
222
- // full repaint into the framebuffer makes it current again) — a screenshot
223
- // must then re-render instead of copying the framebuffer.
224
- bool retainedFramebufferStale();
225
- // Set while a banded raster callback replays into a staging chunk. The 2-core
226
- // replay split must not engage then: the worker core's canvas is bound to the
227
- // framebuffer, not to the chunk.
228
- extern bool gBandedRasterActive;
229
- #endif
230
-
231
210
  } // namespace gea::embedded::ui
@@ -141,119 +141,6 @@ namespace gea::embedded::ui
141
141
  }
142
142
  #endif
143
143
 
144
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
145
- // Banded (framebuffer-free) retained rendering.
146
- //
147
- // Every frame that reaches the panel is rasterized band by band straight into
148
- // the display's internal-RAM DMA staging chunks: the chunk is cleared, the
149
- // native underlay (gea3d) paints it, the display list replays clipped to it,
150
- // and the display streams it while the next chunk renders. The PSRAM
151
- // framebuffer is neither written nor read back for these frames.
152
- //
153
- // Nothing may therefore depend on the framebuffer holding the last frame.
154
- // The paths that do are bypassed while banded: the root-scroll pixel shift,
155
- // the horizontal-pan memcpy, the in-place background recolor, and the
156
- // static-backdrop cache (never baked). Scenes that still need old pixels —
157
- // filter: blur() captures its backdrop from the framebuffer over the node's
158
- // whole bounds, and a display-backed <canvas> draws into it directly — fall
159
- // back to the framebuffer path, after one full repaint that makes the
160
- // framebuffer current again.
161
- bool gBandedFramebufferStaleFlag = false;
162
-
163
- bool bandedUiEligible()
164
- {
165
- if (Document::directCanvasContextUsed())
166
- return false;
167
- if (!gea::platform::display::Display::canvas())
168
- return false;
169
- auto &state = treeState();
170
- #if GEA_CSS_FILTERS
171
- for (int i = 0; i < state.nodeCount; i++)
172
- {
173
- if (rstyle(state.nodes[i].computedStyle()).filter_blur_radius > 0)
174
- return false;
175
- }
176
- #endif
177
- bool displayBackedCanvas = false;
178
- state.canvases.forEach([&](const CanvasSurfaceState &surface)
179
- { displayBackedCanvas = displayBackedCanvas || surface.displayBacked(); });
180
- return !displayBackedCanvas;
181
- }
182
-
183
- struct BandedRasterCtx
184
- {
185
- int screenW;
186
- int screenH;
187
- // The frame may use the direct dirty-region replay (same gate as the
188
- // framebuffer path's direct_replay). Otherwise the conservative full
189
- // replay runs, clipped to the band.
190
- bool direct;
191
- };
192
-
193
- // Replays [x0,x1] x [y0,y1] into the bound canvas, whose clip is already that
194
- // region. The underlay is painted first so the tree lands on top of it; the
195
- // direct replay restores its own clear base, which would paint over an
196
- // underlay, so a frame with one always takes the full replay.
197
- void bandedReplayRegion(int x0, int y0, int x1, int y1, bool direct)
198
- {
199
- if (direct && !gea::framework::display::Underlay::active())
200
- {
201
- const DisplayReplayRegion region{x0, y0, x1, y1, -1};
202
- DisplayList::instance().replayDirectDirtyRegions(&region, 1);
203
- return;
204
- }
205
- gea::framework::display::Underlay::paint(x0, y0, x1, y1);
206
- DisplayList::instance().replay();
207
- }
208
-
209
- // Display::flushRectsRasterized callback: `pixels` holds rows [oy, oy+height)
210
- // x columns [ox, ox+width) with stride `width`. The canvas is bound onto it
211
- // through an offset base pointer so absolute screen coordinates land in the
212
- // chunk; the clip keeps every write inside it.
213
- void bandedRaster(gea::framework::graphics::pixel::native_t *pixels, int width, int height, int ox, int oy, void *user)
214
- {
215
- auto *ctx = static_cast<BandedRasterCtx *>(user);
216
- auto *canvas = gea::platform::display::Display::canvas();
217
- if (!canvas || !ctx)
218
- return;
219
- using PixT = gea::framework::graphics::pixel::native_t;
220
- const std::int64_t replayStartUs = refreshPerfNowUs();
221
- // The framebuffer path starts from Display::clearNoFlush()'s black; so
222
- // does every band (a scene that leaves pixels uncovered shows black, never
223
- // the previous band's bytes).
224
- std::fill_n(pixels, static_cast<std::size_t>(width) * static_cast<std::size_t>(height),
225
- gea::framework::graphics::pixel::fromRgb565(0x0000));
226
- PixT *base = pixels - (static_cast<std::ptrdiff_t>(oy) * width + ox);
227
- canvas->bindPixels(base, ctx->screenW, ctx->screenH, width);
228
- gea::platform::display::Display::resetClip();
229
- gea::platform::display::Display::setAlpha(255);
230
- gea::platform::display::Display::pushClip(ox, oy, width, height);
231
- gBandedRasterActive = true;
232
- bandedReplayRegion(ox, oy, ox + width - 1, oy + height - 1, ctx->direct);
233
- gBandedRasterActive = false;
234
- gea::platform::display::Display::popClip();
235
- GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayUs += refreshPerfNowUs() - replayStartUs);
236
- }
237
-
238
- void bandedFlush(const gea::platform::display::DisplayFlushRect *rects, int count, int width, int height, bool direct)
239
- {
240
- if (!rects || count <= 0)
241
- return;
242
- BandedRasterCtx ctx{width, height, direct};
243
- gea::platform::display::Display::flushRectsRasterized(rects, count, bandedRaster, &ctx, /*allowPerChunkDrain=*/false);
244
- gea::platform::display::Display::rebindCanvasToFramebuffer();
245
- gBandedFramebufferStaleFlag = true;
246
- }
247
-
248
- void bandedFlushFullScreen(int width, int height, bool direct)
249
- {
250
- if (width <= 0 || height <= 0)
251
- return;
252
- const gea::platform::display::DisplayFlushRect full{0, 0, width - 1, height - 1};
253
- bandedFlush(&full, 1, width, height, direct);
254
- }
255
- #endif
256
-
257
144
  #if GEA_CSS_SCROLLING
258
145
  struct PreservedScrollOffset
259
146
  {
@@ -1685,46 +1572,10 @@ namespace gea::embedded::ui
1685
1572
  // The caller must hold AppState::lock() so the frame task isn't using the shared canvas
1686
1573
  // or mutating the list. Returns false for non-retained (canvas/present) apps, whose
1687
1574
  // pixels aren't in the retained command list — the caller falls back to the present path.
1688
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1689
- bool gBandedRasterActive = false;
1690
-
1691
- bool retainedFramebufferStale()
1692
- {
1693
- return gBandedFramebufferStaleFlag;
1694
- }
1695
- #endif
1696
-
1697
1575
  bool renderRetainedSnapshotRgb565(std::uint16_t *dst, int width, int height)
1698
1576
  {
1699
1577
  if (!dst || width <= 0 || height <= 0)
1700
1578
  return false;
1701
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1702
- // A banded frame lives only on the panel: render it again the way the
1703
- // bands did — black base, the underlay, then the whole display list.
1704
- if (gBandedFramebufferStaleFlag && DisplayList::instance().commandCount() > 0)
1705
- {
1706
- auto *bandCanvas = gea::platform::display::Display::canvas();
1707
- if (!bandCanvas)
1708
- return false;
1709
- using PixT = gea::framework::graphics::pixel::native_t;
1710
- PixT *base = reinterpret_cast<PixT *>(dst);
1711
- std::fill_n(base, static_cast<std::size_t>(width) * static_cast<std::size_t>(height),
1712
- gea::framework::graphics::pixel::fromRgb565(0x0000));
1713
- bandCanvas->bindPixels(base, width, height, width);
1714
- gea::platform::display::Display::resetClip();
1715
- gea::platform::display::Display::setAlpha(255);
1716
- gea::platform::display::Display::pushClip(0, 0, width, height);
1717
- gBandedRasterActive = true;
1718
- bandedReplayRegion(0, 0, width - 1, height - 1, /*direct=*/false);
1719
- gBandedRasterActive = false;
1720
- gea::platform::display::Display::popClip();
1721
- gea::platform::display::Display::rebindCanvasToFramebuffer();
1722
- const int pixels = width * height;
1723
- for (int i = 0; i < pixels; i++)
1724
- dst[i] = gea::framework::graphics::pixel::toRgb565(base[i]);
1725
- return true;
1726
- }
1727
- #endif
1728
1579
  if (DisplayList::instance().commandCount() < 2)
1729
1580
  return false; // canvas/present app: nothing retained to replay
1730
1581
  auto *canvas = gea::platform::display::Display::canvas();
@@ -1825,25 +1676,10 @@ namespace gea::embedded::ui
1825
1676
  DisplayList::instance().clear();
1826
1677
  DisplayList::instance().recordNode(root, 255);
1827
1678
  DisplayList::instance().weldTransformedFaces();
1828
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1829
- if (!styleMountBatchActive() && bandedUiEligible())
1830
- {
1831
- state.displayListDirty = false;
1832
- state.displayListRebuildStructural = false;
1833
- bandedFlushFullScreen(width, height, /*direct=*/false);
1834
- // The framebuffer was cleared above but holds none of this frame.
1835
- gea::platform::display::Display::canvas()->resetDirty();
1836
- }
1837
- else
1838
- #endif
1839
- {
1840
1679
  gea::framework::display::Underlay::paint(0, 0, width - 1, height - 1);
1841
1680
  DisplayList::instance().replay();
1842
1681
  state.displayListDirty = false;
1843
1682
  state.displayListRebuildStructural = false; // this path already repainted everything
1844
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
1845
- gBandedFramebufferStaleFlag = false; // the framebuffer holds the whole frame again
1846
- #endif
1847
1683
 
1848
1684
  // Don't present the very first mount while the initial style batch is still
1849
1685
  // open: per-node class styles haven't been applied yet, so this frame is
@@ -1852,7 +1688,6 @@ namespace gea::embedded::ui
1852
1688
  // avoiding a flash of unstyled content (text + images, no CSS) at boot.
1853
1689
  if (!styleMountBatchActive())
1854
1690
  gea::platform::display::Display::flush();
1855
- }
1856
1691
  state.canvases.forEach([](CanvasSurfaceState &surface)
1857
1692
  {
1858
1693
  if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
@@ -2041,24 +1876,6 @@ namespace gea::embedded::ui
2041
1876
  GEA_REFRESH_PERF(perf.treeRefreshCalls++);
2042
1877
  DisplayList::instance().clearRetainedBackgroundRecolors();
2043
1878
 
2044
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
2045
- // Banded frames never touch the framebuffer (see bandedUiEligible). A frame
2046
- // that must take the framebuffer path after banded ones first repaints the
2047
- // whole viewport into it: a structural rebuild does exactly that.
2048
- const bool banded = bandedUiEligible();
2049
- const bool framebufferReadable = !banded && !gBandedFramebufferStaleFlag;
2050
- if (!banded && gBandedFramebufferStaleFlag)
2051
- {
2052
- state.displayListDirty = true;
2053
- state.displayListRebuildStructural = true;
2054
- state.nodes[root].render.dirty = true;
2055
- state.nodes[root].render.layout_dirty = true;
2056
- gBandedFramebufferStaleFlag = false;
2057
- }
2058
- #else
2059
- constexpr bool banded = false;
2060
- constexpr bool framebufferReadable = true;
2061
- #endif
2062
1879
  const bool textClipDependencies = DisplayList::instance().hasTextClippedBackgrounds();
2063
1880
  if (textClipDependencies) {
2064
1881
  bool changed = state.displayListDirty;
@@ -2073,7 +1890,7 @@ namespace gea::embedded::ui
2073
1890
  state.nodes[root].render.dirty = true;
2074
1891
  }
2075
1892
  }
2076
- if (framebufferReadable && !textClipDependencies && state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
1893
+ if (!textClipDependencies && state.pendingScrollIntoViewNode < 0 && RootScrollOnlyRefresh::refresh(root, width, height))
2077
1894
  return;
2078
1895
 
2079
1896
  // This frame is NOT a pure scroll, so the software scroll register's
@@ -2551,7 +2368,7 @@ namespace gea::embedded::ui
2551
2368
  // Horizontal-pan fast path: when a camera/world wrapper translated the viewport
2552
2369
  // this frame (and nothing structural changed), memcpy-shift the viewport instead
2553
2370
  // of re-replaying the whole panned scene. Handles the frame fully when it engages.
2554
- if (framebufferReadable && tryHorizontalPanRefresh(root, width, height, framebuffer_was_dirty,
2371
+ if (tryHorizontalPanRefresh(root, width, height, framebuffer_was_dirty,
2555
2372
  display_list_was_dirty, display_list_was_structural,
2556
2373
  displayListFullRecord))
2557
2374
  {
@@ -2640,8 +2457,7 @@ namespace gea::embedded::ui
2640
2457
  continue;
2641
2458
  }
2642
2459
 
2643
- if (framebufferReadable &&
2644
- !canvas_dirty &&
2460
+ if (!canvas_dirty &&
2645
2461
  direct_replay &&
2646
2462
  n->render.bg_recolor_pending &&
2647
2463
  n->first_child < 0 &&
@@ -3029,38 +2845,6 @@ namespace gea::embedded::ui
3029
2845
  (int)simpleUnifiedReplay, (int)interleavedUnifiedFlush, (int)hasFlushOnlyRecolorRegions,
3030
2846
  (int)GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH);
3031
2847
  }
3032
- #endif
3033
- #if GEA_EMBEDDED_DISPLAY_BANDED_UI
3034
- if (banded)
3035
- {
3036
- // Every pixel the panel receives is re-rendered into its band, so the band
3037
- // set is everything this frame repaints (rects) or transmits (flush_rects).
3038
- DirtyRegions::Rect bandRegions[DirtyRegions::kMaxRects];
3039
- int bandRegionCount = 0;
3040
- for (int i = 0; i < flush_rect_count; i++)
3041
- addDirtyRegion(bandRegions, &bandRegionCount, flush_rects[i], width, height);
3042
- for (int i = 0; i < rect_count; i++)
3043
- addDirtyRegion(bandRegions, &bandRegionCount, rects[i], width, height);
3044
- coalesceLowCostDirtyRegions(bandRegions, &bandRegionCount);
3045
- gea::platform::display::DisplayFlushRect bandRects[DirtyRegions::kMaxRects];
3046
- int bandRectCount = 0;
3047
- for (int i = 0; i < bandRegionCount; i++)
3048
- {
3049
- const DirtyRegions::Rect &r = bandRegions[i];
3050
- if (r.x0 > r.x1 || r.y0 > r.y1)
3051
- continue;
3052
- bandRects[bandRectCount++] = gea::platform::display::DisplayFlushRect{r.x0, r.y0, r.x1, r.y1};
3053
- }
3054
- const std::int64_t flushStartUs = refreshPerfNowUs();
3055
- if (bandRectCount > 0)
3056
- {
3057
- if (direct_replay)
3058
- GEA_REFRESH_PERF(perf.treeDirectReplayCalls++);
3059
- bandedFlush(bandRects, bandRectCount, width, height, direct_replay != 0);
3060
- }
3061
- GEA_REFRESH_PERF(perf.treeFlushRectsUs += refreshPerfNowUs() - flushStartUs);
3062
- }
3063
- else
3064
2848
  #endif
3065
2849
  if (simpleUnifiedReplay)
3066
2850
  {
@@ -3302,21 +3086,18 @@ namespace gea::embedded::ui
3302
3086
  display_list_was_structural ? 1 : 0, rect_count, flush_rect_count);
3303
3087
  }
3304
3088
  #endif
3305
- // Banded: never bake — the cache is a second full-screen PSRAM copy whose
3306
- // blits are exactly the read-back this mode removes (directReplay=false
3307
- // keeps it invalid).
3308
3089
  DisplayList::instance().maybeBakeStaticBackdrop(
3309
3090
  width,
3310
3091
  height,
3311
3092
  !display_list_was_structural && staticBackdropStable,
3312
- !banded && direct_replay != 0 && !simpleDirtyReplayAvailable && staticBackdropStable,
3093
+ direct_replay != 0 && !simpleDirtyReplayAvailable && staticBackdropStable,
3313
3094
  staticBackdropEligible);
3314
3095
 
3315
3096
  const std::int64_t flushRectsStartUs = refreshPerfNowUs();
3316
3097
  #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
3317
3098
  const auto diagnosticReplayEnd = esp_timer_get_time();
3318
3099
  #endif
3319
- if (!banded && !simpleUnifiedReplay && !interleavedUnifiedFlush)
3100
+ if (!simpleUnifiedReplay && !interleavedUnifiedFlush)
3320
3101
  {
3321
3102
  for (int i = 0; i < flush_rect_count; i++)
3322
3103
  {