@geastack/engine 0.1.8 → 0.1.10

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/canvas.cpp CHANGED
@@ -3938,7 +3938,7 @@ void Canvas::drawImage(
3938
3938
  pixel::packed::writeUnpacked(packedRow(rowToPhysical(dy + sy)), dst_x, src_row, row_w);
3939
3939
  #else
3940
3940
  pixel::native_t *dst_row = &pixels_[rowToPhysical(dy + sy) * stride_ + dst_x];
3941
- std::memcpy(dst_row, src_row, static_cast<std::size_t>(row_w) * sizeof(pixel::native_t));
3941
+ pixel::copyNative(dst_row, src_row, row_w);
3942
3942
  #endif
3943
3943
  #if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
3944
3944
  }
@@ -4253,6 +4253,30 @@ void Canvas::drawImage(
4253
4253
  }
4254
4254
  const int wx0 = 256 - fx;
4255
4255
  const int wx1 = fx;
4256
+ #if GEA_EMBEDDED_PIXEL_FORMAT == GEA_PIXEL_RGB565
4257
+ if (!alpha) {
4258
+ // Opaque pixels have a constant alpha denominator. Keep bilinear
4259
+ // filtering, but cancel that factor instead of doing four floating
4260
+ // point alpha products and a reciprocal for every video pixel.
4261
+ // Channel * combined weight sums fit in 24 bits (255 * 65536).
4262
+ unsigned rSum = 0, gSum = 0, bSum = 0;
4263
+ auto addOpaque = [&](int sx, int sy, unsigned weight) {
4264
+ if (!weight) return;
4265
+ int r = 0, g = 0, b = 0, unused = 0;
4266
+ pixel::unpackNative8(src[sy * src_w + sx], &r, &g, &b, &unused);
4267
+ rSum += static_cast<unsigned>(r) * weight;
4268
+ gSum += static_cast<unsigned>(g) * weight;
4269
+ bSum += static_cast<unsigned>(b) * weight;
4270
+ };
4271
+ addOpaque(sx0, sy0, wx0 * wy0);
4272
+ addOpaque(sx1, sy0, wx1 * wy0);
4273
+ addOpaque(sx0, sy1, wx0 * wy1);
4274
+ addOpaque(sx1, sy1, wx1 * wy1);
4275
+ writePixel(px, py, pixel::packNative8((rSum + 32768) >> 16,
4276
+ (gSum + 32768) >> 16, (bSum + 32768) >> 16, 255));
4277
+ continue;
4278
+ }
4279
+ #endif
4256
4280
  // FLOAT accumulators (no int64 anywhere). The previous int64 version cost
4257
4281
  // ~160ms for a 220x220 icon on this board: Xtensa LX7 has NO hardware
4258
4282
  // 64-bit divide AND no hardware int64->float, so both int64 divides and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/engine",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -57,7 +57,6 @@
57
57
  },
58
58
  "sideEffects": false,
59
59
  "dependencies": {
60
- "@geastack/core": "^0.1.30"
61
- },
62
- "gitHead": "e375eddd8f725d7cc5de3fd46baca63e35936027"
60
+ "@geastack/core": "^0.1.35"
61
+ }
63
62
  }
package/ui/document.cpp CHANGED
@@ -150,7 +150,7 @@ NodeHandle Document::createElement(const char *tag) const
150
150
  if (lowered == "button") node = createButton();
151
151
  else if (lowered == "canvas") node = createCanvas();
152
152
  else if (lowered == "audio") node = createAudio();
153
- else if (lowered == "img" || lowered == "image") node = createImage();
153
+ else if (lowered == "img" || lowered == "image" || lowered == "video") node = createImage();
154
154
  else if (lowered == "virtual-list") node = createVirtualList();
155
155
  else node = createView();
156
156
  if (!lowered.empty()) node.setTagName(lowered.c_str());
package/ui/render.cpp CHANGED
@@ -2725,6 +2725,9 @@ int gLastScrollUiFrame = -1000;
2725
2725
  return;
2726
2726
 
2727
2727
  const int stride = canvas->strideBytes() / static_cast<int>(sizeof(gea::framework::graphics::pixel::native_t));
2728
+ #if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
2729
+ const bool rotated = canvas->isLandscapeRotated();
2730
+ #endif
2728
2731
  int dirtyX0 = canvas->width();
2729
2732
  int dirtyY0 = canvas->height();
2730
2733
  int dirtyX1 = -1;
@@ -3111,13 +3114,19 @@ int gLastScrollUiFrame = -1000;
3111
3114
  alpha = (alpha * parentAlpha + 127) / 255;
3112
3115
  if (alpha <= 0)
3113
3116
  continue;
3117
+ auto *target = dst;
3118
+ #if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
3119
+ // Projected text writes native pixels directly, so it must use
3120
+ // the same logical-to-physical mapping as Canvas text drawing.
3121
+ if (rotated) target = canvas->pixels() + (canvas->width() - 1 - xi) * stride + y;
3122
+ #endif
3114
3123
  if (alpha >= 255)
3115
- *dst = textColorNative;
3124
+ *target = textColorNative;
3116
3125
  else
3117
3126
  #if GEA_EMBEDDED_PIXEL_FORMAT == GEA_PIXEL_RGB565
3118
- *dst = blendTextRgb565(*dst, alpha);
3127
+ *target = blendTextRgb565(*target, alpha);
3119
3128
  #else
3120
- *dst = gea::framework::graphics::pixel::blendNative(textColorNative, *dst, alpha);
3129
+ *target = gea::framework::graphics::pixel::blendNative(textColorNative, *target, alpha);
3121
3130
  #endif
3122
3131
 
3123
3132
  if (xi < dirtyX0)
@@ -10246,11 +10255,23 @@ int gLastScrollUiFrame = -1000;
10246
10255
  bool DisplayList::patchNodeAlpha(int node, uint8_t opacity)
10247
10256
  {
10248
10257
  // The OPEN SetAlpha wrapping a node's subtree lives OUTSIDE the node's
10249
- // [drawStart,drawEnd] range, so scan by the nodeId tag recordNode stamped on
10250
- // it. Recompute from the record-time parent alpha so nested scopes stay
10258
+ // [drawStart,drawEnd] range, immediately before drawStart. Recompute
10259
+ // from the record-time parent alpha so nested scopes stay
10251
10260
  // correct: alpha = recordParentAlpha * opacity / 255.
10252
10261
  if (!state.commands || node < 0 || node >= Tree::instance().nodeCount())
10253
10262
  return false;
10263
+ // Reuse the existing range index. Scanning the entire retained list for
10264
+ // each fading leaf makes an N-lamp animation quadratic in command count.
10265
+ if (state.hasNodeScratchFor(node)) {
10266
+ const int ci = state.nodeDrawStart[node] - 1;
10267
+ if (ci >= 0 && ci < state.commandCount) {
10268
+ auto &command = state.commands[ci];
10269
+ if (command.type == DisplayCommandType::SetAlpha && command.alpha.nodeId == node) {
10270
+ command.alpha.alpha = static_cast<uint8_t>((static_cast<int>(command.alpha.recordParentAlpha) * opacity) / 255);
10271
+ return true;
10272
+ }
10273
+ }
10274
+ }
10254
10275
  for (int ci = 0; ci < state.commandCount; ci++)
10255
10276
  {
10256
10277
  DisplayCommand *c = &state.commands[ci];
package/ui/style.cpp CHANGED
@@ -9101,6 +9101,12 @@ void Style::setProperty(const std::string &property, const std::string &value) c
9101
9101
  StyleSheet::instance().applyProperty(NodeHandle(nodeId_), property, value);
9102
9102
  }
9103
9103
 
9104
+ bool Style::setNumberProperty(const std::string &property, double value) const
9105
+ {
9106
+ if (nodeId_ < 0) return false;
9107
+ return StyleSheet::instance().applyNumberProperty(NodeHandle(nodeId_), property.c_str(), value);
9108
+ }
9109
+
9104
9110
  bool Style::removeProperty(const std::string &property) const
9105
9111
  {
9106
9112
  if (nodeId_ < 0) return false;
package/ui/style.h CHANGED
@@ -367,6 +367,7 @@ public:
367
367
  // one the CSS parser feeds), rather than duplicating property-name
368
368
  // parsing here.
369
369
  void setProperty(const std::string &property, const std::string &value) const;
370
+ bool setNumberProperty(const std::string &property, double value) const;
370
371
  bool removeProperty(const std::string &property) const;
371
372
 
372
373
  private:
package/ui/text.cpp CHANGED
@@ -1998,6 +1998,9 @@ void GEA_TEXT_HOT_SRAM TextRenderer::record(const Node &node, uint8_t parentAlph
1998
1998
  int y = n->layout.y;
1999
1999
  int w = n->layout.width;
2000
2000
  int h = n->layout.height;
2001
+ // Empty bounds are not a transform. Hidden-overflow text in an empty
2002
+ // content box has no paintable pixels and must not emit projected ink.
2003
+ if ((w <= 0 && overflowX(n->computedStyle())) || (h <= 0 && overflowY(n->computedStyle()))) return;
2001
2004
  int tx = x + boxInset(n->computedStyle(), 3);
2002
2005
  int ty = y + boxInset(n->computedStyle(), 0);
2003
2006
  int tw = w - boxInset(n->computedStyle(), 1) - boxInset(n->computedStyle(), 3);
@@ -17,6 +17,11 @@
17
17
  #include <cstdlib>
18
18
  #include <cstring>
19
19
 
20
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
21
+ #include "esp_timer.h"
22
+ #include "esp_log.h"
23
+ #endif
24
+
20
25
  #ifndef GEA_EMBEDDED_FLUSH_ANCHOR_LEFT_PARTIAL_RECTS
21
26
  #define GEA_EMBEDDED_FLUSH_ANCHOR_LEFT_PARTIAL_RECTS 1
22
27
  #endif
@@ -1846,6 +1851,9 @@ namespace gea::embedded::ui
1846
1851
 
1847
1852
  void Tree::refresh(int root, int width, int height)
1848
1853
  {
1854
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
1855
+ const auto diagnosticStart = esp_timer_get_time();
1856
+ #endif
1849
1857
  auto &state = treeState();
1850
1858
  if (root < 0 || root >= state.nodeCount)
1851
1859
  return;
@@ -2051,6 +2059,9 @@ namespace gea::embedded::ui
2051
2059
  GEA_REFRESH_PERF(perf.treeLayoutUs += refreshPerfNowUs() - layoutStartUs);
2052
2060
 
2053
2061
  const std::int64_t displayListStartUs = refreshPerfNowUs();
2062
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
2063
+ const auto diagnosticLayoutEnd = esp_timer_get_time();
2064
+ #endif
2054
2065
  const bool display_list_was_dirty = state.displayListDirty;
2055
2066
  // Consume the structural flag for this frame's rebuild decision. A
2056
2067
  // content-only rebuild (appearance change on existing nodes — partial
@@ -2726,6 +2737,9 @@ namespace gea::embedded::ui
2726
2737
  g_broadDirtyBbox = false;
2727
2738
 
2728
2739
  const std::int64_t dirtyCoalesceStartUs = refreshPerfNowUs();
2740
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
2741
+ const auto diagnosticCollectEnd = esp_timer_get_time();
2742
+ #endif
2729
2743
  if (!unifiedRectPath || GEA_EMBEDDED_REPLAY_COALESCE_DIRTY_REGIONS)
2730
2744
  coalesceLowCostDirtyRegions(rects, &rect_count);
2731
2745
  if (!preserveFlatTransformedReplayRects)
@@ -3067,6 +3081,9 @@ namespace gea::embedded::ui
3067
3081
  staticBackdropEligible);
3068
3082
 
3069
3083
  const std::int64_t flushRectsStartUs = refreshPerfNowUs();
3084
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
3085
+ const auto diagnosticReplayEnd = esp_timer_get_time();
3086
+ #endif
3070
3087
  if (!simpleUnifiedReplay && !interleavedUnifiedFlush)
3071
3088
  {
3072
3089
  for (int i = 0; i < flush_rect_count; i++)
@@ -3109,6 +3126,16 @@ namespace gea::embedded::ui
3109
3126
  displayCanvas->resetDirty();
3110
3127
  #endif
3111
3128
  GEA_REFRESH_PERF(perf.treeSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
3129
+ #if defined(ESP_PLATFORM) && CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
3130
+ const auto diagnosticEnd = esp_timer_get_time();
3131
+ if (diagnosticEnd - diagnosticStart > 30000)
3132
+ ESP_LOGW("tree_phase", "layout_ms=%lld collect_ms=%lld replay_ms=%lld flush_ms=%lld rects=%d direct=%d commands=%d structural=%d",
3133
+ (long long)((diagnosticLayoutEnd - diagnosticStart) / 1000),
3134
+ (long long)((diagnosticCollectEnd - diagnosticLayoutEnd) / 1000),
3135
+ (long long)((diagnosticReplayEnd - diagnosticCollectEnd) / 1000),
3136
+ (long long)((diagnosticEnd - diagnosticReplayEnd) / 1000),
3137
+ rect_count, direct_replay, DisplayList::instance().commandCount(), int(display_list_was_structural));
3138
+ #endif
3112
3139
  }
3113
3140
 
3114
3141
  void Tree::frame(int timestamp_ms)
package/ui/tree_style.cpp CHANGED
@@ -1233,16 +1233,12 @@ void setStyleValue(Tree &tree, int node, Property prop, int value, bool recordIn
1233
1233
  if (prop == Property::Display) {
1234
1234
  forceFull = !stayLocal;
1235
1235
  } else if (prop == Property::Opacity) {
1236
- // Partial→partial fade: the SetAlpha scope already exists on both
1237
- // sides (opacity 0 still records a scope), so patch its value in place
1238
- // and keep the display list — no rebuild, no displayListDirty. The
1239
- // full per-rect replay path (tree_render) replays the scope in order,
1240
- // so the patched alpha applies correctly. (The incremental
1241
- // direct-replay path can't use this: it replays only a node's
1242
- // [drawStart,drawEnd], which excludes the scope — which is why
1243
- // canReplayDirectDirtyRegions still bails and we fall to the safe
1244
- // full-per-rect replay. The record stays incremental either way.)
1245
- if (stayLocal && prevOpacity < 255 && style.opacity < 255 &&
1236
+ // An existing leaf alpha scope can represent every opacity, including
1237
+ // full brightness. Keep it across 255 instead of repeatedly removing
1238
+ // and recreating it during a fade. patchNodeAlpha returns false when
1239
+ // no scope exists (for example, an initially opaque or culled node),
1240
+ // so those cases still take the ordinary recording path below.
1241
+ if (stayLocal &&
1246
1242
  DisplayList::instance().patchNodeAlpha(node, static_cast<uint8_t>(style.opacity)))
1247
1243
  return;
1248
1244
  // Crossing the 255 boundary (scope appears/disappears) or a non-leaf: