@geastack/engine 0.1.22 → 0.1.23

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.22",
3
+ "version": "0.1.23",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -104,7 +104,14 @@ gea::framework::graphics::Canvas *CanvasStore::bindOwned(CanvasSurfaceState &sur
104
104
  // Cache-line aligned (size rounded up to the alignment) so DMA engines — the
105
105
  // ESP32-P4 PPA in particular — can scale/rotate straight into this buffer with
106
106
  // no bounce copy. A few padding bytes per canvas is a negligible cost.
107
+ // Apple hosts align to the page instead, so the GPU can read the buffer in
108
+ // place (a Metal buffer wraps whole, page-aligned pages) and presenting a
109
+ // canvas copies nothing.
110
+ #ifdef __APPLE__
111
+ constexpr std::size_t kCanvasAlign = 16384;
112
+ #else
107
113
  constexpr std::size_t kCanvasAlign = 128;
114
+ #endif
108
115
  const auto pixelBytes = static_cast<std::size_t>(width) * static_cast<std::size_t>(height) * sizeof(gea::framework::graphics::pixel::native_t);
109
116
  const auto byteCount = (pixelBytes + (kCanvasAlign - 1)) & ~(kCanvasAlign - 1);
110
117
  surface.pixels = static_cast<gea::framework::graphics::pixel::native_t *>(
@@ -176,6 +176,11 @@ public:
176
176
  // Bumped on every mount()/refresh(); native renderers diff against the last
177
177
  // value they synced to decide whether a re-sync is needed at all.
178
178
  uint64_t refreshSerial() const;
179
+ // A host that presents the tree with its own native views (the iOS/tvOS
180
+ // UIKit renderer) never shows the software framebuffer: while suppressed,
181
+ // refresh() still lays out and records, but skips rasterizing and flushing.
182
+ // The first refresh after suppression ends repaints the whole viewport.
183
+ void setSoftwareRasterSuppressed(bool suppressed);
179
184
  void setDisplayListRebuildRequired(bool required);
180
185
  bool nodeDisplayCommandsDirty(int node) const;
181
186
  void clearNodeDisplayCommandDirty(int node);
@@ -2161,6 +2161,13 @@ namespace gea::embedded::ui
2161
2161
  }
2162
2162
  } // namespace
2163
2163
 
2164
+ namespace {
2165
+ bool gSoftwareRasterSuppressed = false;
2166
+ bool gSoftwareRasterStale = false; // frames went unrasterized since the last repaint
2167
+ }
2168
+
2169
+ void Tree::setSoftwareRasterSuppressed(bool suppressed) { gSoftwareRasterSuppressed = suppressed; }
2170
+
2164
2171
  void Tree::refresh(int root, int width, int height)
2165
2172
  {
2166
2173
  #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
@@ -2180,7 +2187,10 @@ namespace gea::embedded::ui
2180
2187
  #endif
2181
2188
  const bool viewportChanged = gLayoutViewportRoot != root ||
2182
2189
  gLayoutViewportWidth != width || gLayoutViewportHeight != height;
2183
- if (viewportChanged) {
2190
+ const bool rasterResumed = gSoftwareRasterStale && !gSoftwareRasterSuppressed;
2191
+ if (rasterResumed)
2192
+ gSoftwareRasterStale = false;
2193
+ if (viewportChanged || rasterResumed) {
2184
2194
  state.displayListDirty = true;
2185
2195
  state.displayListRebuildStructural = true;
2186
2196
  state.nodes[root].render.dirty = true;
@@ -2741,6 +2751,22 @@ namespace gea::embedded::ui
2741
2751
  if (reprojected)
2742
2752
  GEA_REFRESH_PERF(perf.treeReprojects++);
2743
2753
  GEA_REFRESH_PERF(perf.treeDisplayListUs += refreshPerfNowUs() - displayListStartUs);
2754
+ if (gSoftwareRasterSuppressed)
2755
+ {
2756
+ // The host shows native views, not the framebuffer: finish the frame's
2757
+ // bookkeeping (as the end of a rasterized refresh does) without painting.
2758
+ gSoftwareRasterStale = true;
2759
+ LayoutSnapshot::capture();
2760
+ state.canvases.forEach([](CanvasSurfaceState &surface)
2761
+ {
2762
+ if (auto *canvas = surface.canvas()) canvas->resetDirty(); });
2763
+ CanvasRenderingContext2D::clearRetainedCanvasDamage();
2764
+ #if !defined(GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT) || !GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT
2765
+ if (displayCanvas)
2766
+ displayCanvas->resetDirty();
2767
+ #endif
2768
+ return;
2769
+ }
2744
2770
 
2745
2771
  // Horizontal-pan fast path: when a camera/world wrapper translated the viewport
2746
2772
  // this frame (and nothing structural changed), memcpy-shift the viewport instead