@geastack/engine 0.1.25 → 0.1.27

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.25",
3
+ "version": "0.1.27",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,6 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "graphics/font.h"
3
3
 
4
+ namespace {
5
+ const gea::framework::graphics::RuntimeFontProvider *runtimeFontProvider = nullptr;
6
+ }
7
+
4
8
  #ifndef GEA_EMBEDDED_TTF_RUNTIME_FONTS
5
9
  #define GEA_EMBEDDED_TTF_RUNTIME_FONTS 0
6
10
  #endif
@@ -192,10 +196,10 @@ int ceilToInt(float value)
192
196
  return static_cast<int>(std::ceil(value));
193
197
  }
194
198
 
195
- RuntimeRasterizedFontSlot *runtimeFontSlots()
199
+ RuntimeRasterizedFontSlot *runtimeFontSlots(bool allocate = true)
196
200
  {
197
201
  static RuntimeRasterizedFontSlot *slots = nullptr;
198
- if (!slots) {
202
+ if (!slots && allocate) {
199
203
  void *storage = memory::Allocator::allocatePreferSpiram(
200
204
  sizeof(RuntimeRasterizedFontSlot) * kRuntimeFontCacheSlots,
201
205
  alignof(RuntimeRasterizedFontSlot));
@@ -235,7 +239,8 @@ bool buildRuntimeFontSlot(RuntimeRasterizedFontSlot &slot, int familyId, int siz
235
239
  #endif
236
240
 
237
241
  unsigned long fontLength = 0;
238
- const std::uint8_t *fontBytes = generated::lookupRuntimeTtfFontForFamily(familyId, &fontLength);
242
+ const std::uint8_t *fontBytes = runtimeFontProvider ? runtimeFontProvider->fontBytes(familyId, &fontLength) : nullptr;
243
+ if (!fontBytes) fontBytes = generated::lookupRuntimeTtfFontForFamily(familyId, &fontLength);
239
244
  runtimeTtfTrace("slot.lookup family=%d bytes=%p len=%lu", familyId, static_cast<const void *>(fontBytes), fontLength);
240
245
  if (!fontBytes || fontLength == 0) return false;
241
246
 
@@ -666,6 +671,21 @@ RasterizedFont FontRegistry::rasterizedFamily(int familyId, int sizePx,int weigh
666
671
  return RasterizedFont(generated::lookupFontForFamily(familyId, sizePx));
667
672
  }
668
673
 
674
+ void FontRegistry::invalidateRuntimeFonts()
675
+ {
676
+ #if GEA_EMBEDDED_TTF_RUNTIME_FONTS
677
+ if (auto *slots = runtimeFontSlots(false)) {
678
+ for (int i = 0; i < kRuntimeFontCacheSlots; ++i) releaseRuntimeFontSlot(slots[i]);
679
+ }
680
+ #endif
681
+ }
682
+
683
+ void FontRegistry::setRuntimeFontProvider(const RuntimeFontProvider *provider)
684
+ {
685
+ invalidateRuntimeFonts();
686
+ runtimeFontProvider = provider;
687
+ }
688
+
669
689
  const BitmapFont8x16 &FontRegistry::bitmap8x16()
670
690
  {
671
691
  return BitmapFont8x16::instance();
@@ -674,12 +694,19 @@ const BitmapFont8x16 &FontRegistry::bitmap8x16()
674
694
  int FontRegistry::familyId(const char *family)
675
695
  {
676
696
  ensureGeneratedFontsLinked();
697
+ if (runtimeFontProvider) {
698
+ const int id = runtimeFontProvider->lookupFamily(family);
699
+ if (id >= 0) return id;
700
+ }
677
701
  return generated::lookupFontFamily(family);
678
702
  }
679
703
 
680
704
  const char *FontRegistry::familyName(int familyId)
681
705
  {
682
706
  ensureGeneratedFontsLinked();
707
+ if (runtimeFontProvider) {
708
+ if (const char *name = runtimeFontProvider->familyName(familyId)) return name;
709
+ }
683
710
  return generated::lookupFontFamilyName(familyId);
684
711
  }
685
712
 
package/ui/layout.cpp CHANGED
@@ -1783,7 +1783,9 @@ private:
1783
1783
  int extent = 0;
1784
1784
  for (int c = childNode.first_child; c >= 0; c = nodes[c].next_sibling) {
1785
1785
  const Node &grand = nodes[c];
1786
- if (isLayoutExcluded(grand) || isOutOfFlowPosition(grand.computedStyle().position)) continue;
1786
+ // Ignored DOM whitespace has no box to contribute to the flex item's minimum.
1787
+ if (isLayoutExcluded(grand) || isOutOfFlowPosition(grand.computedStyle().position) ||
1788
+ suppressAnonymousWhitespace(nodes, grand.parent, c)) continue;
1787
1789
  // layout.{x,y} are still parent-relative here: resolveAbsoluteCoords runs
1788
1790
  // after the whole layout pass. A text run's laid-out box is its line box,
1789
1791
  // as wide as the space it was offered (and offset by text-align), so it
@@ -37,7 +37,11 @@ extern "C" __attribute__((weak)) bool gea_display_scroll_rect_self_flushing() {
37
37
  // this one repaints the exposed strip starts it here (false: it cannot, and the
38
38
  // caller blits with Display::scrollRect) and joins it in the end call.
39
39
  extern "C" __attribute__((weak)) bool gea_display_scroll_rect_begin(int, int, int, int, int, int) { return false; }
40
+ #if defined(GEA_LINKED_HOOK_DEFAULTS) && GEA_LINKED_HOOK_DEFAULTS
41
+ extern "C" void gea_display_prepare_repaint(const gea::platform::display::DisplayFlushRect *, int);
42
+ #else
40
43
  extern "C" __attribute__((weak)) void gea_display_prepare_repaint(const gea::platform::display::DisplayFlushRect *, int) {}
44
+ #endif
41
45
  // Per screen row from y0: what the coming sideways scroll copy leaves unchanged
42
46
  // (DisplayList::scrollRowSignatures), so the display may skip rows its back
43
47
  // buffer already holds. Taken by the next gea_display_scroll_rect_begin.
@@ -49,7 +49,11 @@
49
49
  // else and skip those rects: on the CrowPanel 7 a scrolling page otherwise
50
50
  // copied the whole viewport between buffers (~1.4 MB of PSRAM traffic a frame)
51
51
  // only to redraw it, and that traffic starved the panel's scanout.
52
+ #if defined(GEA_LINKED_HOOK_DEFAULTS) && GEA_LINKED_HOOK_DEFAULTS
53
+ extern "C" void gea_display_prepare_repaint(const gea::platform::display::DisplayFlushRect *, int);
54
+ #else
52
55
  extern "C" __attribute__((weak)) void gea_display_prepare_repaint(const gea::platform::display::DisplayFlushRect *, int) {}
56
+ #endif
53
57
  extern "C" int gea_bulk_replay_stage_rows_for_width(int width);
54
58
  extern "C" bool gea_replay_stage_begin(int x0, int y0, int x1, int y1);
55
59
  extern "C" void gea_replay_stage_end();