@geastack/engine 0.1.25 → 0.1.26
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 +1 -1
- package/rasterized_font.cpp +30 -3
- package/ui/root_scroll_refresh.cpp +4 -0
- package/ui/tree_render.cpp +4 -0
package/package.json
CHANGED
package/rasterized_font.cpp
CHANGED
|
@@ -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 =
|
|
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
|
|
|
@@ -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.
|
package/ui/tree_render.cpp
CHANGED
|
@@ -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();
|