@geastack/engine 0.1.29 → 0.1.31
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/css/animation.h +12 -3
- package/css/declarative.h +12 -2
- package/css/interpolate.h +16 -0
- package/package.json +2 -2
- package/ui/canvas_element.cpp +1 -1
- package/ui/canvas_store.h +1 -0
- package/ui/document.cpp +12 -1
- package/ui/internal.h +1 -0
- package/ui/node_lifecycle.cpp +5 -1
- package/ui/render.cpp +4 -0
- package/ui/svg_element.h +17 -0
- package/ui/svg_element_impl.h +14 -0
- package/ui/text.cpp +2 -0
- package/ui/tree_internal.h +3 -0
- package/ui/tree_nodes.cpp +16 -1
- package/ui/view.cpp +2 -0
package/css/animation.h
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#include "../ui/style.h"
|
|
16
16
|
#include "easing.h"
|
|
17
17
|
#include "interpolate.h"
|
|
18
|
+
#include "pixel.h"
|
|
18
19
|
|
|
19
20
|
namespace gea::css {
|
|
20
21
|
|
|
@@ -218,15 +219,23 @@ inline double sampleSegment(const Animation &a, const Keyframe &k0, const Keyfra
|
|
|
218
219
|
const double eased = a.easing.kind() == EasingKind::Linear ? localT : a.easing(localT);
|
|
219
220
|
|
|
220
221
|
if (a.kind == ValueKind::Color) {
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
// Color keyframes hold native style values, which are 32-bit colors on
|
|
223
|
+
// RGBA8888 and ARGB8888 builds.
|
|
224
|
+
const int from = static_cast<int>(std::llround(k0.value));
|
|
225
|
+
const int to = static_cast<int>(std::llround(k1.value));
|
|
226
|
+
#if GEA_PIXEL_FORMAT_IS_8888
|
|
227
|
+
return static_cast<double>(lerpColor8888(from, to, eased));
|
|
228
|
+
#else
|
|
229
|
+
return static_cast<double>(lerpColor565(from, to, eased));
|
|
230
|
+
#endif
|
|
223
231
|
}
|
|
224
232
|
return lerp(k0.value, k1.value, eased);
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
// Sample the property value at timeline progress p (0..1 within one iteration):
|
|
228
236
|
// find the bracketing keyframes, ease the in-segment progress, interpolate per
|
|
229
|
-
// kind. Returns the value to apply (degrees for Angle,
|
|
237
|
+
// kind. Returns the value to apply (degrees for Angle, the native style value
|
|
238
|
+
// for Color).
|
|
230
239
|
inline double sampleTrack(const Animation &a, double p)
|
|
231
240
|
{
|
|
232
241
|
const auto &kf = a.keyframes;
|
package/css/declarative.h
CHANGED
|
@@ -110,14 +110,24 @@ private:
|
|
|
110
110
|
AnimationEngine::instance().start(a, nowMs);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
// Color attributes are RGB565; 8888 style values hold 8 bits per channel.
|
|
114
|
+
auto color = [](int rgb565) {
|
|
115
|
+
#if GEA_PIXEL_FORMAT_IS_8888
|
|
116
|
+
namespace pixel = gea::framework::graphics::pixel;
|
|
117
|
+
return static_cast<int>(pixel::nativeStyleValueFromRgba8888(pixel::rgba8888FromRgb565(static_cast<std::uint16_t>(rgb565))));
|
|
118
|
+
#else
|
|
119
|
+
return rgb565;
|
|
120
|
+
#endif
|
|
121
|
+
};
|
|
122
|
+
|
|
113
123
|
if (!std::strcmp(kind, "rotate"))
|
|
114
124
|
startOne(Property::TransformRotate, from, to);
|
|
115
125
|
else if (!std::strcmp(kind, "opacity"))
|
|
116
126
|
startOne(Property::Opacity, from, to);
|
|
117
127
|
else if (!std::strcmp(kind, "color"))
|
|
118
|
-
startOne(Property::Color, from, to);
|
|
128
|
+
startOne(Property::Color, color(from), color(to));
|
|
119
129
|
else if (!std::strcmp(kind, "bg") || !std::strcmp(kind, "background"))
|
|
120
|
-
startOne(Property::BackgroundColor, from, to);
|
|
130
|
+
startOne(Property::BackgroundColor, color(from), color(to));
|
|
121
131
|
else if (!std::strcmp(kind, "width"))
|
|
122
132
|
startOne(Property::Width, from, to);
|
|
123
133
|
else if (!std::strcmp(kind, "height"))
|
package/css/interpolate.h
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// (inline). Part of the gea CSS animation engine. See docs/geaos-grand-vision.md (M1).
|
|
7
7
|
|
|
8
8
|
#include <cmath>
|
|
9
|
+
#include <cstdint>
|
|
9
10
|
|
|
10
11
|
namespace gea::css {
|
|
11
12
|
|
|
@@ -35,4 +36,19 @@ inline int lerpColor565(int fromRgb565, int toRgb565, double t)
|
|
|
35
36
|
return (r << 11) | (g << 5) | b;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
// Interpolate two 32-bit colors one byte at a time. Each byte is one channel in
|
|
40
|
+
// both RGBA8888 and ARGB8888, so the channel order does not matter here.
|
|
41
|
+
inline int lerpColor8888(int from, int to, double t)
|
|
42
|
+
{
|
|
43
|
+
const auto a = static_cast<std::uint32_t>(from);
|
|
44
|
+
const auto b = static_cast<std::uint32_t>(to);
|
|
45
|
+
std::uint32_t out = 0;
|
|
46
|
+
for (int shift = 0; shift < 32; shift += 8) {
|
|
47
|
+
const int ca = static_cast<int>((a >> shift) & 0xFFu);
|
|
48
|
+
const int cb = static_cast<int>((b >> shift) & 0xFFu);
|
|
49
|
+
out |= static_cast<std::uint32_t>(detail::clampi(detail::roundi(lerp(ca, cb, t)), 0, 0xFF)) << shift;
|
|
50
|
+
}
|
|
51
|
+
return static_cast<int>(out);
|
|
52
|
+
}
|
|
53
|
+
|
|
38
54
|
} // namespace gea::css
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
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.63"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/ui/canvas_element.cpp
CHANGED
|
@@ -1817,7 +1817,7 @@ void CanvasRenderingContext2D::setFont(const std::string &font)
|
|
|
1817
1817
|
void CanvasRenderingContext2D::clear()
|
|
1818
1818
|
{
|
|
1819
1819
|
if (recordingPresentBatch()) {
|
|
1820
|
-
appendPresentClear(0);
|
|
1820
|
+
appendPresentClear(gea::framework::graphics::pixel::nativeColor(0, 0, 0));
|
|
1821
1821
|
return;
|
|
1822
1822
|
}
|
|
1823
1823
|
auto *surface = drawingCanvas();
|
package/ui/canvas_store.h
CHANGED
package/ui/document.cpp
CHANGED
|
@@ -318,6 +318,7 @@ void Document::addEventListener(const char *type, gea::framework::events::EventL
|
|
|
318
318
|
namespace
|
|
319
319
|
{
|
|
320
320
|
gea::framework::display::Underlay::Paint underlayPaint = nullptr;
|
|
321
|
+
gea::framework::display::Underlay::Describe underlayDescribe = nullptr;
|
|
321
322
|
void *underlayUser = nullptr;
|
|
322
323
|
int underlayX0 = 0, underlayY0 = 0, underlayX1 = -1, underlayY1 = -1;
|
|
323
324
|
bool underlayOpaque = false;
|
|
@@ -328,9 +329,10 @@ bool gea::framework::display::Underlay::composited()
|
|
|
328
329
|
return !gea::embedded::ui::Document::directCanvasContextUsed() && gea::embedded::ui::Tree::instance().mountedRoot() >= 0;
|
|
329
330
|
}
|
|
330
331
|
|
|
331
|
-
void gea::framework::display::Underlay::set(Paint paint, void *user, int x0, int y0, int x1, int y1)
|
|
332
|
+
void gea::framework::display::Underlay::set(Paint paint, void *user, int x0, int y0, int x1, int y1, Describe describe)
|
|
332
333
|
{
|
|
333
334
|
underlayPaint = paint;
|
|
335
|
+
underlayDescribe = describe;
|
|
334
336
|
underlayUser = user;
|
|
335
337
|
underlayX0 = x0;
|
|
336
338
|
underlayY0 = y0;
|
|
@@ -352,10 +354,19 @@ bool gea::framework::display::Underlay::covers(int x0, int y0, int x1, int y1)
|
|
|
352
354
|
void gea::framework::display::Underlay::clear()
|
|
353
355
|
{
|
|
354
356
|
underlayPaint = nullptr;
|
|
357
|
+
underlayDescribe = nullptr;
|
|
355
358
|
underlayUser = nullptr;
|
|
356
359
|
underlayOpaque = false;
|
|
357
360
|
}
|
|
358
361
|
|
|
362
|
+
bool gea::framework::display::Underlay::describe(Sink &sink)
|
|
363
|
+
{
|
|
364
|
+
if (!underlayPaint || !underlayDescribe) return false;
|
|
365
|
+
sink.area(underlayX0, underlayY0, underlayX1, underlayY1);
|
|
366
|
+
underlayDescribe(sink, underlayUser);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
|
|
359
370
|
bool gea::framework::display::Underlay::active()
|
|
360
371
|
{
|
|
361
372
|
return underlayPaint != nullptr;
|
package/ui/internal.h
CHANGED
|
@@ -454,6 +454,7 @@ void rootScrollImageHoldTick();
|
|
|
454
454
|
bool reprojectDirtyRect(int *x0, int *y0, int *x1, int *y1) const;
|
|
455
455
|
void filterBlurCacheStats(int *hits, int *misses) const;
|
|
456
456
|
int commandCount() const;
|
|
457
|
+
const DisplayCommand *commandAt(int index) const;
|
|
457
458
|
bool hasTextClippedBackgrounds() const;
|
|
458
459
|
// Scrollbar thumbs are recorded outside every node's command range;
|
|
459
460
|
// see DisplayListState::scrollbarBoxes.
|
package/ui/node_lifecycle.cpp
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
#include <cstdlib>
|
|
8
8
|
#include <new>
|
|
9
9
|
#include <utility>
|
|
10
|
+
|
|
11
|
+
#ifndef GEA_EMBEDDED_DEFAULT_FONT_FAMILY_ID
|
|
12
|
+
#define GEA_EMBEDDED_DEFAULT_FONT_FAMILY_ID -1
|
|
13
|
+
#endif
|
|
10
14
|
#if defined(ESP_PLATFORM)
|
|
11
15
|
#include "esp_heap_caps.h"
|
|
12
16
|
#endif
|
|
@@ -194,7 +198,7 @@ constexpr ComputedStyle makeDefaultStyle()
|
|
|
194
198
|
#if GEA_CSS_FONT_STRETCH
|
|
195
199
|
style.font_stretch = 1000;
|
|
196
200
|
#endif
|
|
197
|
-
style.font_id =
|
|
201
|
+
style.font_id = GEA_EMBEDDED_DEFAULT_FONT_FAMILY_ID;
|
|
198
202
|
style.font_size = 0;
|
|
199
203
|
#if GEA_CSS_FONT_WEIGHT
|
|
200
204
|
style.font_weight = 400;
|
package/ui/render.cpp
CHANGED
|
@@ -11323,6 +11323,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
11323
11323
|
}
|
|
11324
11324
|
|
|
11325
11325
|
int DisplayList::commandCount() const { return state.commandCount; }
|
|
11326
|
+
const DisplayCommand *DisplayList::commandAt(int index) const
|
|
11327
|
+
{
|
|
11328
|
+
return state.commands && index >= 0 && index < state.commandCount ? &state.commands[index] : nullptr;
|
|
11329
|
+
}
|
|
11326
11330
|
bool DisplayList::hasTextClippedBackgrounds() const
|
|
11327
11331
|
{
|
|
11328
11332
|
return state.textClippedBackgrounds;
|
package/ui/svg_element.h
CHANGED
|
@@ -89,6 +89,23 @@ void validateScenes();
|
|
|
89
89
|
void record(const Node &svgNode);
|
|
90
90
|
void paint(const DisplayCommand &command);
|
|
91
91
|
|
|
92
|
+
struct Path;
|
|
93
|
+
struct StrokeStyle;
|
|
94
|
+
|
|
95
|
+
// One paint of a scene item, for a target that draws scenes itself: the fill
|
|
96
|
+
// of `geometry` (svg-local pixels), or with `stroke` set its stroke outline.
|
|
97
|
+
// A gradient paint is only flagged.
|
|
98
|
+
struct ScenePaint {
|
|
99
|
+
const Path *geometry;
|
|
100
|
+
const StrokeStyle *stroke;
|
|
101
|
+
bool evenOdd;
|
|
102
|
+
bool gradient;
|
|
103
|
+
std::uint32_t color; // native
|
|
104
|
+
float alpha;
|
|
105
|
+
};
|
|
106
|
+
// The paints of an svg root's scene as last recorded, in paint order.
|
|
107
|
+
void visitScene(int root, void (*visit)(void *user, const ScenePaint &paint), void *user);
|
|
108
|
+
|
|
92
109
|
// Hit test inside an svg root whose box contains (x, y): the topmost shape
|
|
93
110
|
// under the point, or -1 when no shape paints there.
|
|
94
111
|
int hitTest(int rootId, int x, int y);
|
package/ui/svg_element_impl.h
CHANGED
|
@@ -185,6 +185,7 @@ struct Item {
|
|
|
185
185
|
bool evenOdd = false;
|
|
186
186
|
bool hittable = true;
|
|
187
187
|
float halfStroke = 0.0f;
|
|
188
|
+
StrokeStyle strokeStyle;
|
|
188
189
|
Bounds fillBounds, strokeBounds;
|
|
189
190
|
// Everything the geometry and edges depend on (attributes, transform,
|
|
190
191
|
// stroke style): an unchanged item keeps them across scene rebuilds, so a
|
|
@@ -783,6 +784,7 @@ void walk(int id, const Context &parent, std::vector<Item> &items, ItemCache &ca
|
|
|
783
784
|
// distance to the path), so it goes straight to edges.
|
|
784
785
|
strokePathEdges(item.geometry, style, item.strokeEdges, item.strokeBounds);
|
|
785
786
|
item.halfStroke = width / 2;
|
|
787
|
+
item.strokeStyle = style;
|
|
786
788
|
}
|
|
787
789
|
if (item.fill.on) {
|
|
788
790
|
item.fillBounds.add(item.geometry.contours);
|
|
@@ -1568,6 +1570,18 @@ void paint(const DisplayCommand &c)
|
|
|
1568
1570
|
paintRows(&band, cy0, cy1);
|
|
1569
1571
|
}
|
|
1570
1572
|
|
|
1573
|
+
void visitScene(int root, void (*visit)(void *user, const ScenePaint &paint), void *user)
|
|
1574
|
+
{
|
|
1575
|
+
auto it = g_scenes.find(root);
|
|
1576
|
+
if (it == g_scenes.end()) return;
|
|
1577
|
+
for (const Item &item : it->second.items) {
|
|
1578
|
+
if (item.fill.on)
|
|
1579
|
+
visit(user, {&item.geometry, nullptr, item.evenOdd, item.fill.gradient, item.fill.color, std::min(1.0f, item.fill.alpha)});
|
|
1580
|
+
if (!item.strokeEdges.empty())
|
|
1581
|
+
visit(user, {&item.geometry, &item.strokeStyle, false, item.stroke.gradient, item.stroke.color, std::min(1.0f, item.stroke.alpha)});
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1571
1585
|
int hitTest(int rootId, int x, int y)
|
|
1572
1586
|
{
|
|
1573
1587
|
auto it = g_scenes.find(rootId);
|
package/ui/text.cpp
CHANGED
|
@@ -267,6 +267,8 @@ void appendAlphaCommand(uint8_t alpha, int bx, int by, int bw, int bh)
|
|
|
267
267
|
cmd->type = DisplayCommandType::SetAlpha;
|
|
268
268
|
cmd->bx = bx; cmd->by = by; cmd->bw = bw; cmd->bh = bh;
|
|
269
269
|
cmd->alpha.alpha = alpha;
|
|
270
|
+
cmd->alpha.recordParentAlpha = alpha;
|
|
271
|
+
cmd->alpha.nodeId = -1;
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
void boundsFromCorners(const int16_t *xs, const int16_t *ys, int *x0, int *y0, int *x1, int *y1)
|
package/ui/tree_internal.h
CHANGED
|
@@ -103,6 +103,9 @@ public:
|
|
|
103
103
|
void displayBackedFailDebug(int *reason, int *extra, int *count) const;
|
|
104
104
|
void canvasSlotDebug(int id, int *mode, int *rebinds) const;
|
|
105
105
|
void markCanvasDirty(int node);
|
|
106
|
+
// The <canvas> node whose owned bitmap is `pixels` (-1: none), and how many
|
|
107
|
+
// times it has been redrawn (markCanvasDirty) since its surface was created.
|
|
108
|
+
int canvasForPixels(const gea::framework::graphics::pixel::native_t *pixels, std::uint32_t *redraws) const;
|
|
106
109
|
|
|
107
110
|
// A <camera> leaf reuses the same per-node RGB565 surface machinery as a
|
|
108
111
|
// canvas, but the pixels are produced by the platform camera backend each
|
package/ui/tree_nodes.cpp
CHANGED
|
@@ -523,6 +523,20 @@ void Tree::canvasSlotDebug(int id, int *mode, int *rebinds) const
|
|
|
523
523
|
*rebinds = gCanvasRebindCount;
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
+
int Tree::canvasForPixels(const gea::framework::graphics::pixel::native_t *pixels, std::uint32_t *redraws) const
|
|
527
|
+
{
|
|
528
|
+
const auto &state = treeState();
|
|
529
|
+
int found = -1;
|
|
530
|
+
state.canvases.forEach([&](const CanvasSurfaceState &surface) {
|
|
531
|
+
if (found >= 0 || !surface.ownsPixels() || surface.pixels != pixels || surface.nodeId < 0 || surface.nodeId >= state.nodeCount ||
|
|
532
|
+
state.nodes[surface.nodeId].type != NodeType::Canvas)
|
|
533
|
+
return;
|
|
534
|
+
found = surface.nodeId;
|
|
535
|
+
*redraws = surface.redraws;
|
|
536
|
+
});
|
|
537
|
+
return found;
|
|
538
|
+
}
|
|
539
|
+
|
|
526
540
|
bool Tree::isDisplayBackedCanvas(int id) const
|
|
527
541
|
{
|
|
528
542
|
const auto &state = treeState();
|
|
@@ -535,8 +549,9 @@ void Tree::markCanvasDirty(int id)
|
|
|
535
549
|
{
|
|
536
550
|
auto &state = treeState();
|
|
537
551
|
if (id < 0 || id >= state.nodeCount) return;
|
|
538
|
-
|
|
552
|
+
auto *surface = state.canvases.find(id);
|
|
539
553
|
if (surface && surface->displayBacked()) return;
|
|
554
|
+
if (surface) ++surface->redraws;
|
|
540
555
|
// Pixels only: drawing never changes the element's box, so no layout_dirty.
|
|
541
556
|
// It used to be set here, and a canvas redrawn every frame (Ember's heat
|
|
542
557
|
// arc) then cost a full relayout of the whole screen per frame (~5.5 ms of
|
package/ui/view.cpp
CHANGED
|
@@ -75,6 +75,8 @@ void appendAlphaCommand(uint8_t alpha, int bx, int by, int bw, int bh)
|
|
|
75
75
|
cmd->type = DisplayCommandType::SetAlpha;
|
|
76
76
|
cmd->bx = bx; cmd->by = by; cmd->bw = bw; cmd->bh = bh;
|
|
77
77
|
cmd->alpha.alpha = alpha;
|
|
78
|
+
cmd->alpha.recordParentAlpha = alpha;
|
|
79
|
+
cmd->alpha.nodeId = -1;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
uint8_t interpolateAlpha(uint8_t from, uint8_t to, int permille)
|