@geastack/engine 0.1.15 → 0.1.16
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 +270 -139
- package/css/engine.h +23 -3
- package/image_store.cpp +35 -2
- package/package.json +2 -2
- package/rasterized_font.cpp +42 -2
- package/touch_runtime.cpp +231 -178
- package/ui/canvas_element.cpp +432 -125
- package/ui/canvas_element.h +84 -16
- package/ui/core.cpp +1 -0
- package/ui/debugger_listeners.h +80 -0
- package/ui/debugger_overlay.h +79 -0
- package/ui/debugger_picker.h +105 -0
- package/ui/document.cpp +1 -1
- package/ui/image_node.cpp +33 -1
- package/ui/input.cpp +27 -6
- package/ui/input_render.cpp +6 -8
- package/ui/internal.h +20 -0
- package/ui/layout.cpp +130 -17
- package/ui/layout_snapshot.cpp +1 -0
- package/ui/node.h +4 -0
- package/ui/node_lifecycle.cpp +7 -0
- package/ui/node_model.h +38 -16
- package/ui/render.cpp +259 -26
- package/ui/style.cpp +571 -66
- package/ui/style.h +16 -1
- package/ui/text.cpp +113 -65
- package/ui/tree_events.cpp +55 -13
- package/ui/tree_internal.h +5 -0
- package/ui/tree_nodes.cpp +16 -1
- package/ui/tree_render.cpp +153 -13
- package/ui/tree_style.cpp +25 -3
- package/ui/view.cpp +8 -8
package/css/engine.h
CHANGED
|
@@ -46,6 +46,22 @@ public:
|
|
|
46
46
|
{
|
|
47
47
|
running_.eraseIf([&](const Running &r) { return r.handle == handle; });
|
|
48
48
|
}
|
|
49
|
+
bool contains(int handle) const
|
|
50
|
+
{
|
|
51
|
+
for (std::size_t i = 0; i < running_.size(); ++i)
|
|
52
|
+
if (running_[i].handle == handle) return true;
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
void setPaused(int handle, bool paused, uint32_t nowMs)
|
|
56
|
+
{
|
|
57
|
+
for (std::size_t i = 0; i < running_.size(); ++i) {
|
|
58
|
+
Running &r = running_[i];
|
|
59
|
+
if (r.handle != handle || r.paused == paused) continue;
|
|
60
|
+
if (paused) r.pauseMs = nowMs;
|
|
61
|
+
else r.startMs += nowMs - r.pauseMs;
|
|
62
|
+
r.paused = paused;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
49
65
|
void cancelNode(int nodeId) // cancel all animations targeting a node
|
|
50
66
|
{
|
|
51
67
|
running_.eraseIf([&](const Running &r) { return r.anim.nodeId == nodeId; });
|
|
@@ -65,7 +81,7 @@ public:
|
|
|
65
81
|
const Progress pr = computeProgress(first.anim, elapsed);
|
|
66
82
|
std::size_t groupEnd = i + 1;
|
|
67
83
|
while (groupEnd < running_.size() && sameTimeline(first, running_[groupEnd])) ++groupEnd;
|
|
68
|
-
if (pr.active) {
|
|
84
|
+
if (pr.active && !first.paused) {
|
|
69
85
|
for (std::size_t j = i; j < groupEnd; ++j) {
|
|
70
86
|
const auto &a = running_[j].anim;
|
|
71
87
|
if (!a.rotationAxes.empty())
|
|
@@ -75,7 +91,7 @@ public:
|
|
|
75
91
|
else applyValue(a, sampleTrack(a, pr.p));
|
|
76
92
|
}
|
|
77
93
|
}
|
|
78
|
-
if (pr.done)
|
|
94
|
+
if (pr.done && !first.paused)
|
|
79
95
|
running_.erase(i, groupEnd);
|
|
80
96
|
else
|
|
81
97
|
i = groupEnd;
|
|
@@ -89,6 +105,8 @@ private:
|
|
|
89
105
|
Animation anim;
|
|
90
106
|
uint32_t startMs;
|
|
91
107
|
int handle;
|
|
108
|
+
bool paused = false;
|
|
109
|
+
uint32_t pauseMs = 0;
|
|
92
110
|
};
|
|
93
111
|
|
|
94
112
|
class RunningList {
|
|
@@ -195,7 +213,7 @@ private:
|
|
|
195
213
|
|
|
196
214
|
static bool sameTimeline(const Running &a, const Running &b)
|
|
197
215
|
{
|
|
198
|
-
return a.startMs == b.startMs && a.anim.durationMs == b.anim.durationMs &&
|
|
216
|
+
return a.paused == b.paused && a.startMs == b.startMs && a.anim.durationMs == b.anim.durationMs &&
|
|
199
217
|
a.anim.delayMs == b.anim.delayMs && a.anim.iterations == b.anim.iterations &&
|
|
200
218
|
a.anim.direction == b.anim.direction && a.anim.fill == b.anim.fill;
|
|
201
219
|
}
|
|
@@ -237,6 +255,8 @@ public:
|
|
|
237
255
|
static AnimationEngine &instance() { static AnimationEngine engine; return engine; }
|
|
238
256
|
int start(Animation, uint32_t) = delete;
|
|
239
257
|
void cancel(int) {}
|
|
258
|
+
bool contains(int) const { return false; }
|
|
259
|
+
void setPaused(int, bool, uint32_t) {}
|
|
240
260
|
void cancelNode(int) {}
|
|
241
261
|
void clear() {}
|
|
242
262
|
bool active() const { return false; }
|
package/image_store.cpp
CHANGED
|
@@ -869,10 +869,38 @@ bool ImageStore::rotate90(int id)
|
|
|
869
869
|
return true;
|
|
870
870
|
}
|
|
871
871
|
|
|
872
|
+
bool ImageStore::retain(int id)
|
|
873
|
+
{
|
|
874
|
+
if (id < 0 || id >= kImageMax) return false;
|
|
875
|
+
ImageStoreLock lock(slotMutex_);
|
|
876
|
+
if (!slot(id)) return false;
|
|
877
|
+
++references_[id];
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
void ImageStore::release(int id)
|
|
882
|
+
{
|
|
883
|
+
if (id < 0 || id >= kImageMax) return;
|
|
884
|
+
ImageStoreLock lock(slotMutex_);
|
|
885
|
+
if (!slot(id) || references_[id] == 0) return;
|
|
886
|
+
if (--references_[id] == 0 && retired_[id]) disposeLocked(id);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
int ImageStore::idForPixels(const pixel::native_t *pixels) const
|
|
890
|
+
{
|
|
891
|
+
if (!pixels) return -1;
|
|
892
|
+
ImageStoreLock lock(slotMutex_);
|
|
893
|
+
for (int id = 0; id < kImageMax; ++id)
|
|
894
|
+
if (used_[id] && images_[id].pixels == pixels) return id;
|
|
895
|
+
return -1;
|
|
896
|
+
}
|
|
897
|
+
|
|
872
898
|
void ImageStore::dispose(int id)
|
|
873
899
|
{
|
|
874
900
|
ImageStoreLock lock(slotMutex_);
|
|
875
|
-
|
|
901
|
+
if (!slot(id)) return;
|
|
902
|
+
retired_[id] = true;
|
|
903
|
+
if (references_[id] == 0) disposeLocked(id);
|
|
876
904
|
}
|
|
877
905
|
|
|
878
906
|
void ImageStore::disposeLocked(int id)
|
|
@@ -889,13 +917,18 @@ void ImageStore::disposeLocked(int id)
|
|
|
889
917
|
ImageMemory::release(image->alpha);
|
|
890
918
|
*image = ImageSlot{};
|
|
891
919
|
used_[id] = false;
|
|
920
|
+
references_[id] = 0;
|
|
921
|
+
retired_[id] = false;
|
|
892
922
|
}
|
|
893
923
|
|
|
894
924
|
void ImageStore::disposeAll()
|
|
895
925
|
{
|
|
896
926
|
ImageStoreLock lock(slotMutex_);
|
|
897
927
|
for (int i = 0; i < kImageMax; i++) {
|
|
898
|
-
if (used_[i])
|
|
928
|
+
if (used_[i]) {
|
|
929
|
+
retired_[i] = true;
|
|
930
|
+
if (references_[i] == 0) disposeLocked(i);
|
|
931
|
+
}
|
|
899
932
|
}
|
|
900
933
|
}
|
|
901
934
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
},
|
|
58
58
|
"sideEffects": false,
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@geastack/core": "^0.1.
|
|
60
|
+
"@geastack/core": "^0.1.40"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/rasterized_font.cpp
CHANGED
|
@@ -64,6 +64,15 @@ public:
|
|
|
64
64
|
for (int i = 0; i < font->glyphCount; i++) {
|
|
65
65
|
if (font->glyphs[i].codepoint == codepoint) return &font->glyphs[i];
|
|
66
66
|
}
|
|
67
|
+
if (font->strictGlyphLookup)
|
|
68
|
+
{
|
|
69
|
+
for (int i = 0; i < font->glyphCount; i++)
|
|
70
|
+
{
|
|
71
|
+
if (font->glyphs[i].codepoint == font->fallbackCodepoint)
|
|
72
|
+
return &font->glyphs[i];
|
|
73
|
+
}
|
|
74
|
+
return nullptr;
|
|
75
|
+
}
|
|
67
76
|
if (font->glyphCount > 0 && codepoint != '?') {
|
|
68
77
|
for (int i = 0; i < font->glyphCount; i++) {
|
|
69
78
|
if (font->glyphs[i].codepoint == '?') return &font->glyphs[i];
|
|
@@ -352,7 +361,8 @@ void ensureRuntimeGlyphMetrics(const RasterizedFontData *data, int codepoint)
|
|
|
352
361
|
slot->atlasRowHeight = std::max(slot->atlasRowHeight, glyph.height);
|
|
353
362
|
slot->atlasCursorX += glyph.width + kRuntimeAtlasPadding;
|
|
354
363
|
if (metricTraceCount <= 48) {
|
|
355
|
-
runtimeTtfTrace("glyph.metrics.ready family=%d size=%d cp=%d adv=%d
|
|
364
|
+
runtimeTtfTrace("glyph.metrics.ready family=%d size=%d cp=%d adv=%d "
|
|
365
|
+
"box=%dx%d bearing=%d,%d src=%d,%d",
|
|
356
366
|
slot->familyId,
|
|
357
367
|
slot->data.sizePx,
|
|
358
368
|
codepoint,
|
|
@@ -464,6 +474,35 @@ bool RasterizedFont::glyph(int codepoint, Glyph *out) const
|
|
|
464
474
|
return true;
|
|
465
475
|
}
|
|
466
476
|
|
|
477
|
+
int RasterizedFont::advance(int codepoint, int nextCodepoint) const
|
|
478
|
+
{
|
|
479
|
+
Glyph value{};
|
|
480
|
+
if (!glyph(codepoint, &value))
|
|
481
|
+
return data_ && data_->strictGlyphLookup ? 0 : sizePx() / 2;
|
|
482
|
+
if (value.advance16 < 0)
|
|
483
|
+
return value.advance;
|
|
484
|
+
int adjustment = 0;
|
|
485
|
+
int first = 0;
|
|
486
|
+
int last = data_->kerningCount;
|
|
487
|
+
while (first < last)
|
|
488
|
+
{
|
|
489
|
+
const int middle = first + (last - first) / 2;
|
|
490
|
+
const FontKerningPair &pair = data_->kerning[middle];
|
|
491
|
+
if (pair.left < codepoint ||
|
|
492
|
+
(pair.left == codepoint && pair.right < nextCodepoint))
|
|
493
|
+
first = middle + 1;
|
|
494
|
+
else
|
|
495
|
+
last = middle;
|
|
496
|
+
}
|
|
497
|
+
if (first < data_->kerningCount)
|
|
498
|
+
{
|
|
499
|
+
const FontKerningPair &pair = data_->kerning[first];
|
|
500
|
+
if (pair.left == codepoint && pair.right == nextCodepoint)
|
|
501
|
+
adjustment = pair.adjustment16;
|
|
502
|
+
}
|
|
503
|
+
return (value.advance16 + adjustment + 8) >> 4;
|
|
504
|
+
}
|
|
505
|
+
|
|
467
506
|
std::uint8_t RasterizedFont::coverage(const Glyph &glyph, int row, int col) const
|
|
468
507
|
{
|
|
469
508
|
if (!data_ || !data_->atlas) return 0;
|
|
@@ -487,7 +526,8 @@ std::uint8_t RasterizedFont::coverage(const Glyph &glyph, int row, int col) cons
|
|
|
487
526
|
if (data_->atlasBits == 2) {
|
|
488
527
|
const int stride = (data_->atlasWidth + 3) >> 2;
|
|
489
528
|
const int level = (data_->atlas[y * stride + (x >> 2)] >> ((3 - (x & 3)) * 2)) & 0x3;
|
|
490
|
-
#if defined(GEA_EMBEDDED_FONT_COVERAGE_PAPERS3) &&
|
|
529
|
+
#if defined(GEA_EMBEDDED_FONT_COVERAGE_PAPERS3) && \
|
|
530
|
+
GEA_EMBEDDED_FONT_COVERAGE_PAPERS3
|
|
491
531
|
static constexpr std::uint8_t kCoverage[4] = {0, 144, 176, 255};
|
|
492
532
|
return kCoverage[level];
|
|
493
533
|
#else
|