@geastack/core 0.1.49 → 0.1.51

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/include/canvas.h CHANGED
@@ -221,8 +221,9 @@ public:
221
221
  void drawTextFontFamilyRotated90(const char *text, int lx, int ly, pixel::native_t color, int family_id, int size_px);
222
222
  void drawTextFontFamilyOnBackground(const char *text, int x, int y, pixel::native_t color,
223
223
  int family_id, int size_px, pixel::native_t background);
224
- int measureTextFontFamily(const char *text, int family_id, int size_px);
225
- int measureTextInkCenterFontFamily(const char *text, int family_id, int size_px);
224
+ // Font metrics only: no pixels or canvas state, so callers need no surface.
225
+ static int measureTextFontFamily(const char *text, int family_id, int size_px);
226
+ static int measureTextInkCenterFontFamily(const char *text, int family_id, int size_px);
226
227
  static void measureTextFont(const char *text, int max_width, int font_id, int *out_w, int *out_h);
227
228
  void fillRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, pixel::native_t color);
228
229
  void strokeRoundedRect(int x, int y, int w, int h, int tl, int tr, int br, int bl, int lw, pixel::native_t color);
@@ -243,6 +244,41 @@ public:
243
244
  int dx, int dy, int dst_w, int dst_h, int tl, int tr, int br, int bl);
244
245
  void drawImageTiledX(const pixel::native_t *src, const std::uint8_t *alpha, int src_w, int src_h,
245
246
  int dx, int dy, int width);
247
+ // Blend one logical row of anti-aliased coverage: pixel x0+i receives
248
+ // `color` at coverage[i] (0..255, scaled by global alpha). Honours the clip,
249
+ // marks the touched span dirty. The vector (SVG) rasterizer's only output.
250
+ // markDirty=false lets a second core blend disjoint rows concurrently; the
251
+ // caller then marks the region dirty once itself.
252
+ void blendCoverageRow(int y, int x0, int count, const std::uint8_t *coverage, pixel::native_t color,
253
+ bool markDirty = true);
254
+ // Direct row access for a renderer that blends whole rows itself (the
255
+ // vector rasterizer, whose many short runs would otherwise each pay a call):
256
+ // logical row y's pixels and the clip's x range [*x0, *x1], or nullptr when
257
+ // the row is clipped out or this canvas needs per-pixel handling (landscape
258
+ // rotation, packed storage, a global alpha). The caller marks dirty itself.
259
+ pixel::native_t *directRow(int y, int *x0, int *x1)
260
+ {
261
+ #if GEA_PIXEL_STORAGE_PACKED
262
+ (void)y, (void)x0, (void)x1;
263
+ return nullptr;
264
+ #else
265
+ #if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
266
+ if (landscapeRot_) return nullptr;
267
+ #endif
268
+ if (!pixels_ || globalAlpha_ != 255) return nullptr;
269
+ const ClipRect &clip = clipStack_[clipDepth_];
270
+ if (y < 0 || y >= height_ || y < clip.y0 || y > clip.y1) return nullptr;
271
+ *x0 = clip.x0 > 0 ? clip.x0 : 0;
272
+ *x1 = clip.x1 < width_ - 1 ? clip.x1 : width_ - 1;
273
+ if (*x0 > *x1) return nullptr;
274
+ return &pixels_[rowToPhysical(y) * stride_];
275
+ #endif
276
+ }
277
+ // One run of `count` pixels at a single coverage: a span fill when fully
278
+ // covered, else one blend per distinct destination colour. Same clip, alpha
279
+ // and dirty rules as blendCoverageRow.
280
+ void blendCoverageSpan(int y, int x0, int count, std::uint8_t coverage, pixel::native_t color,
281
+ bool markDirty = true);
246
282
 
247
283
  private:
248
284
  void writePixel(int x, int y, pixel::native_t fg);
@@ -257,6 +293,8 @@ private:
257
293
  // (converted once to native). fillSpanGlobalAlpha honours globalAlpha_.
258
294
  void fillSpanColor(int phys, int x0, int count, pixel::native_t color);
259
295
  void fillSpanGlobalAlpha(int phys, int x0, int count, pixel::native_t color);
296
+ // Blends `count` pixels of logical row `y` (physical row `phys`) at one alpha.
297
+ void blendSpanAlpha(int y, int phys, int x0, int count, pixel::native_t color, int alpha);
260
298
  void markDirtyClipped(int x0, int y0, int x1, int y1);
261
299
  void addDirtyRect(int x0, int y0, int x1, int y1);
262
300
  bool fillCircleNoDirty(int cx, int cy, int r, pixel::native_t color);
@@ -25,6 +25,13 @@ namespace gea::framework::display
25
25
  // Registers the painter for the screen area it covers; replaces any
26
26
  // previous one. The caller marks the area dirty to have it repainted.
27
27
  static void set(Paint paint, void *user, int x0, int y0, int x1, int y1);
28
+ // Declares that the painter writes every pixel of its area (a 3D frame
29
+ // with a background colour). `set` resets it to false.
30
+ static void setOpaque(bool opaque);
31
+ // True when an opaque underlay paints all of [x0, x1] x [y0, y1]: a
32
+ // refresh that paints it there repaints that rect completely, so the
33
+ // display need not restore the rect's old pixels first.
34
+ static bool covers(int x0, int y0, int x1, int y1);
28
35
  static void clear();
29
36
  static bool active();
30
37
  // Paints the part of [x0, x1] x [y0, y1] the underlay covers.
package/include/image.h CHANGED
@@ -82,6 +82,11 @@ struct ImageSlot {
82
82
  // Preserve whether the source has no alpha channel so materialization can
83
83
  // discard the synthetic all-255 alpha plane and use the opaque blit path.
84
84
  bool deferredOpaque = false;
85
+ // Where a deferred decode came from, kept after it materializes so
86
+ // releaseIdleDecodes() can drop the pixels and decode again on next use.
87
+ const std::uint8_t *sourceData = nullptr;
88
+ int sourceLength = 0;
89
+ bool sourceOpaque = false;
85
90
  };
86
91
 
87
92
  class ImageStore {
@@ -100,6 +105,13 @@ public:
100
105
  // during idle frames so a later first-draw (e.g. switching weather cities)
101
106
  // doesn't bunch every decode into a single visible hitch.
102
107
  bool materializeOneDeferred();
108
+ // Drop the decoded pixels of large deferred stills that nothing references
109
+ // (no node, no recorded display command); the encoded bytes stay in flash,
110
+ // so the next draw decodes them again. A full-screen backdrop shown once at
111
+ // boot otherwise holds its framebuffer-sized decode for the life of the app.
112
+ // Call once per frame, never between a release and the re-retain that
113
+ // follows it (a style recompute), so a still in use is not thrown away.
114
+ void releaseIdleDecodes();
103
115
  // Register an externally-owned native-format pixel buffer. `takeOwnership`
104
116
  // transfers ownership to the store (freed on dispose) — used by the iOS
105
117
  // camera capture, which hands over a freshly-allocated RGBA8888 still.
package/include/memory.h CHANGED
@@ -3,6 +3,19 @@
3
3
  #include <cstddef>
4
4
  #include <cstdint>
5
5
 
6
+ // Places a large, cold static buffer in external RAM where the target allows a
7
+ // PSRAM .bss (ESP32 with CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY); plain
8
+ // .bss elsewhere. Internal SRAM is the scarce resource on PSRAM boards: on the
9
+ // CrowPanel 7.0 the RGB bounce buffers leave too little of it for the display's
10
+ // SRAM staging strips, and every repaint then rasters straight into PSRAM.
11
+ // Use it for caches touched per record or per layout, not per pixel.
12
+ #if defined(ESP_PLATFORM)
13
+ #include "esp_attr.h"
14
+ #define GEA_EXT_BSS EXT_RAM_BSS_ATTR
15
+ #else
16
+ #define GEA_EXT_BSS
17
+ #endif
18
+
6
19
  namespace gea::framework::memory {
7
20
 
8
21
  class Allocator {
package/index.d.ts CHANGED
@@ -101,6 +101,22 @@ export interface GeaIntrinsicElements {
101
101
  stepper: NativeStepperProps
102
102
  progress: NativeProgressProps
103
103
  'virtual-list': NativeVirtualListProps
104
+ // Inline SVG (engine/ui/svg_element.h): every element is a real node, styled
105
+ // by class and inline style and hit-tested by its geometry.
106
+ svg: SvgRootProps
107
+ g: SvgGroupProps
108
+ path: SvgPathProps
109
+ polyline: SvgPolyProps
110
+ polygon: SvgPolyProps
111
+ line: SvgLineProps
112
+ circle: SvgCircleProps
113
+ ellipse: SvgEllipseProps
114
+ rect: SvgRectProps
115
+ defs: SvgGroupProps
116
+ linearGradient: SvgLinearGradientProps
117
+ stop: SvgStopProps
118
+ title: SvgGroupProps
119
+ desc: SvgGroupProps
104
120
  }
105
121
 
106
122
  export interface WindowEventListenerOptions {
@@ -325,6 +341,16 @@ export interface Style {
325
341
  objectPosition?: string
326
342
  color?: string
327
343
  opacity?: number
344
+ /** SVG paint: a colour, `none` or `currentColor`. Applies to SVG shapes only. */
345
+ fill?: string
346
+ stroke?: string
347
+ strokeWidth?: number | `${number}px`
348
+ fillOpacity?: number
349
+ strokeOpacity?: number
350
+ strokeLinecap?: 'butt' | 'round' | 'square'
351
+ strokeLinejoin?: 'miter' | 'round' | 'bevel'
352
+ fillRule?: 'nonzero' | 'evenodd'
353
+ pointerEvents?: 'auto' | 'none' | 'visiblePainted' | 'painted' | 'fill' | 'stroke' | 'all'
328
354
  blinkInterval?: number
329
355
  borderWidth?: StyleLength
330
356
  borderColor?: string
@@ -685,6 +711,14 @@ export interface NativeViewProps extends DataAttributes, NativeEventAttributes {
685
711
  pressId?: number
686
712
  pressValue?: number
687
713
  momentum?: boolean | string
714
+ /**
715
+ * A scroller whose pages are its own width (or height): a released drag
716
+ * settles on the nearest page, or the next one in a fling's direction, and a
717
+ * programmatic `scrollLeft`/`scrollTop` animates there -- LVGL's tabview
718
+ * content. A `scroll` event fires when it settles.
719
+ */
720
+ 'snap-page'?: boolean
721
+ onScroll?: (event: Event) => void
688
722
  children?: any
689
723
  }
690
724
 
@@ -701,6 +735,59 @@ export interface NativeViewProps extends DataAttributes, NativeEventAttributes {
701
735
  */
702
736
  export interface TextProps extends NativeViewProps {}
703
737
 
738
+ type SvgNumber = number | string
739
+ /** Presentation attributes every SVG element accepts; CSS overrides them. */
740
+ export interface SvgPresentationProps extends DataAttributes, NativeEventAttributes {
741
+ key?: string | number
742
+ id?: string
743
+ class?: ClassValue
744
+ style?: Style
745
+ ref?: GeaElement | null
746
+ children?: any
747
+ transform?: string
748
+ fill?: string
749
+ stroke?: string
750
+ 'stroke-width'?: SvgNumber
751
+ 'stroke-linecap'?: 'butt' | 'round' | 'square'
752
+ 'stroke-linejoin'?: 'miter' | 'round' | 'bevel'
753
+ 'stroke-miterlimit'?: SvgNumber
754
+ 'fill-rule'?: 'nonzero' | 'evenodd'
755
+ opacity?: SvgNumber
756
+ 'fill-opacity'?: SvgNumber
757
+ 'stroke-opacity'?: SvgNumber
758
+ color?: string
759
+ visibility?: 'visible' | 'hidden' | 'collapse'
760
+ display?: string
761
+ 'pointer-events'?: 'auto' | 'none' | 'visiblePainted' | 'painted' | 'fill' | 'stroke' | 'all'
762
+ }
763
+ export interface SvgRootProps extends SvgPresentationProps {
764
+ width?: SvgNumber
765
+ height?: SvgNumber
766
+ viewBox?: string
767
+ preserveAspectRatio?: string
768
+ xmlns?: string
769
+ }
770
+ export interface SvgGroupProps extends SvgPresentationProps {}
771
+ export interface SvgPathProps extends SvgPresentationProps { d?: string }
772
+ export interface SvgPolyProps extends SvgPresentationProps { points?: string }
773
+ export interface SvgLineProps extends SvgPresentationProps { x1?: SvgNumber; y1?: SvgNumber; x2?: SvgNumber; y2?: SvgNumber }
774
+ export interface SvgCircleProps extends SvgPresentationProps { cx?: SvgNumber; cy?: SvgNumber; r?: SvgNumber }
775
+ export interface SvgEllipseProps extends SvgPresentationProps { cx?: SvgNumber; cy?: SvgNumber; rx?: SvgNumber; ry?: SvgNumber }
776
+ export interface SvgRectProps extends SvgPresentationProps {
777
+ x?: SvgNumber; y?: SvgNumber; width?: SvgNumber; height?: SvgNumber; rx?: SvgNumber; ry?: SvgNumber
778
+ }
779
+ // A paint server for fill/stroke="url(#id)": x1..y2 are fractions of the
780
+ // painted shape's box (objectBoundingBox, the default) or user-space units.
781
+ export interface SvgLinearGradientProps extends SvgPresentationProps {
782
+ x1?: SvgNumber; y1?: SvgNumber; x2?: SvgNumber; y2?: SvgNumber
783
+ gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse'
784
+ }
785
+ export interface SvgStopProps extends SvgPresentationProps {
786
+ offset?: SvgNumber
787
+ 'stop-color'?: string
788
+ 'stop-opacity'?: SvgNumber
789
+ }
790
+
704
791
  export interface GeaNode extends Node {}
705
792
  export interface GeaElement extends Element {}
706
793
 
@@ -1206,6 +1293,23 @@ export interface CanvasRenderingContext2D {
1206
1293
  * Allocate once, write every frame, then draw with `putImageData`.
1207
1294
  */
1208
1295
  createImageData565(width: number, height: number): ImageData565
1296
+ /**
1297
+ * How many display buffers a frame can be rendered into in place; 0 where it
1298
+ * cannot (no swap buffers, a panel that is not plain RGB565, the browser).
1299
+ */
1300
+ panelBufferCount(): number
1301
+ /**
1302
+ * An `ImageData565` whose `data16` is display buffer `index` itself: write a
1303
+ * whole frame there and `putImageData` it at (0, 0) without a copy. Make one
1304
+ * per buffer, once; each frame draw into the one `acquirePanelBuffer` names.
1305
+ */
1306
+ createPanelImageData565(index: number): ImageData565
1307
+ /**
1308
+ * Waits until the display has released the buffer the next frame draws into
1309
+ * and returns its index, or -1 when frames cannot be drawn in place. The
1310
+ * frame must repaint every pixel: the buffer holds an older frame.
1311
+ */
1312
+ acquirePanelBuffer(): number
1209
1313
  /** Draw an `ImageData565` with its top-left corner at (dx, dy): one blit. */
1210
1314
  putImageData(image: ImageData565, dx: number, dy: number): void
1211
1315
  /** Draw only the dirty rectangle of an `ImageData565`, at (dx + dirtyX, dy + dirtyY). */
@@ -1397,6 +1501,12 @@ export interface MemoryController {
1397
1501
  allocationPsramPeakBytes(): number
1398
1502
  stats(): EmbeddedMemoryStats
1399
1503
  config(): EmbeddedMemoryConfig
1504
+ // Typed arrays and other allocations made between these two calls prefer
1505
+ // fast on-chip RAM (ESP32-S3 SRAM instead of PSRAM), for tables read at
1506
+ // random per pixel. `bytes` is how much room to make: the display may give
1507
+ // up some internal staging for it. No-ops where there is one kind of RAM.
1508
+ beginInternal(bytes: number): void
1509
+ endInternal(): void
1400
1510
  }
1401
1511
 
1402
1512
  export declare const Memory: MemoryController
@@ -1674,6 +1784,30 @@ export interface NotifyController {
1674
1784
 
1675
1785
  export declare const Notify: NotifyController
1676
1786
 
1787
+ export interface SimdController {
1788
+ // Sums byte windows into a clamped byte grid, vectorized where the chip has
1789
+ // SIMD (ESP32-S3 PIE) and an exact scalar loop elsewhere:
1790
+ // dst[dstStart + r*dstStride + x] =
1791
+ // min(255, ((sum over k of src[offsets[k] + r*srcStride + x]) * multiplier) >> shift)
1792
+ // for r < rows, x < width, k < windows (at most 8). A call that would read
1793
+ // or write outside its arrays does nothing.
1794
+ sumWindowsU8(
1795
+ dst: Uint8Array,
1796
+ dstStart: number,
1797
+ dstStride: number,
1798
+ src: Uint8Array,
1799
+ offsets: Int32Array,
1800
+ windows: number,
1801
+ srcStride: number,
1802
+ width: number,
1803
+ rows: number,
1804
+ multiplier: number,
1805
+ shift: number,
1806
+ ): void
1807
+ }
1808
+
1809
+ export declare const Simd: SimdController
1810
+
1677
1811
  export interface DeviceControlController {
1678
1812
  // Run a host shell command, return combined stdout+stderr. macOS companion
1679
1813
  // only — drives the device-control + install/uninstall scripts over USB.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/core",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "GeaStack app API, reactivity headers, runtime sources, and type declarations.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "@geajs/core": "1.5.1",
67
67
  "@geajs/vite-plugin": "1.5.0",
68
68
  "@geastack/compiler": "^1.0.29",
69
- "@geastack/geatsc-plugin-gea": "0.1.26",
69
+ "@geastack/geatsc-plugin-gea": "0.1.27",
70
70
  "opentype.js": "^2.0.0",
71
71
  "vite": "^8.0.0"
72
72
  },
package/runtime/host.ts CHANGED
@@ -337,6 +337,8 @@ declare const __gea_Memory: {
337
337
  allocationPsramBytes(): number
338
338
  allocationSramPeakBytes(): number
339
339
  allocationPsramPeakBytes(): number
340
+ beginInternal(bytes: number): void
341
+ endInternal(): void
340
342
  }
341
343
  declare const __gea_Input: {
342
344
  // Reads-and-clears the one-shot back-button-pressed flag. Set by the
@@ -416,6 +418,21 @@ declare const __gea_Battery: {
416
418
  // Battery charge percentage (0-100) from the platform PMU.
417
419
  level(): number
418
420
  }
421
+ declare const __gea_Simd: {
422
+ sumWindowsU8(
423
+ dst: Uint8Array,
424
+ dstStart: number,
425
+ dstStride: number,
426
+ src: Uint8Array,
427
+ offsets: Int32Array,
428
+ windows: number,
429
+ srcStride: number,
430
+ width: number,
431
+ rows: number,
432
+ multiplier: number,
433
+ shift: number,
434
+ ): void
435
+ }
419
436
  declare const __gea_Notify: {
420
437
  // Transient host->app notification channel. text() is the latest message;
421
438
  // seq() increments on each post so an app can detect a new one.
@@ -1009,6 +1026,12 @@ export const Memory = {
1009
1026
  allocationPsramPeakBytes(): number {
1010
1027
  return __gea_Memory.allocationPsramPeakBytes()
1011
1028
  },
1029
+ beginInternal(bytes: number): void {
1030
+ __gea_Memory.beginInternal(bytes)
1031
+ },
1032
+ endInternal(): void {
1033
+ __gea_Memory.endInternal()
1034
+ },
1012
1035
  stats(): EmbeddedMemoryStats {
1013
1036
  return {
1014
1037
  internalFree: __gea_Memory.internalFree(),
@@ -1187,6 +1210,23 @@ export const Battery = {
1187
1210
  return __gea_Battery.level()
1188
1211
  },
1189
1212
  }
1213
+ export const Simd = {
1214
+ sumWindowsU8(
1215
+ dst: Uint8Array,
1216
+ dstStart: number,
1217
+ dstStride: number,
1218
+ src: Uint8Array,
1219
+ offsets: Int32Array,
1220
+ windows: number,
1221
+ srcStride: number,
1222
+ width: number,
1223
+ rows: number,
1224
+ multiplier: number,
1225
+ shift: number,
1226
+ ): void {
1227
+ __gea_Simd.sumWindowsU8(dst, dstStart, dstStride, src, offsets, windows, srcStride, width, rows, multiplier, shift)
1228
+ },
1229
+ }
1190
1230
  export const Notify = {
1191
1231
  text(): string {
1192
1232
  return __gea_Notify.text()
@@ -2120,7 +2120,6 @@ function parseStaticCssColorRef(rawValue) {
2120
2120
  function cssIgnoredProperty(property) {
2121
2121
  return new Set([
2122
2122
  'color-scheme',
2123
- 'grid-column',
2124
2123
  'isolation',
2125
2124
  'letter-spacing',
2126
2125
  'outline',