@geastack/engine 0.1.20 → 0.1.22
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 +150 -27
- package/image_store.cpp +308 -1
- package/package.json +1 -1
- package/ui/CSS_FEATURES.md +51 -0
- package/ui/canvas_element.cpp +12 -16
- package/ui/core.cpp +10 -7
- package/ui/document.cpp +25 -0
- package/ui/input.cpp +341 -11
- package/ui/input_render.cpp +62 -17
- package/ui/input_retirement.h +3 -0
- package/ui/internal.h +38 -1
- package/ui/layout.cpp +68 -16
- package/ui/layout_snapshot.cpp +119 -70
- package/ui/layout_snapshot.h +1 -0
- package/ui/node_features.h +6 -0
- package/ui/node_model.h +23 -2
- package/ui/render.cpp +1154 -64
- package/ui/root_scroll_refresh.cpp +372 -66
- package/ui/root_scroll_refresh.h +4 -0
- package/ui/style.cpp +74 -21
- package/ui/style.h +18 -1
- package/ui/svg_element.h +98 -0
- package/ui/svg_element_impl.h +1589 -0
- package/ui/svg_geometry.h +1767 -0
- package/ui/text.cpp +7 -6
- package/ui/tree_events.cpp +15 -0
- package/ui/tree_internal.h +12 -0
- package/ui/tree_nodes.cpp +37 -2
- package/ui/tree_render.cpp +290 -22
- package/ui/tree_state.h +9 -0
- package/ui/tree_style.cpp +32 -0
- package/ui/view.cpp +27 -9
- package/ui/viewport_region.cpp +53 -0
- package/ui/viewport_region.h +3 -0
- package/ui/virtual_keyboard.cpp +279 -23
- package/ui/virtual_keyboard_icons.h +114 -0
package/ui/input_render.cpp
CHANGED
|
@@ -28,14 +28,20 @@
|
|
|
28
28
|
#include "pixel.h"
|
|
29
29
|
#include "tree_internal.h"
|
|
30
30
|
|
|
31
|
+
#include <cstdlib>
|
|
31
32
|
#include <cstring>
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <unordered_map>
|
|
32
35
|
|
|
33
36
|
namespace gea::embedded::ui {
|
|
34
37
|
|
|
35
38
|
namespace {
|
|
36
39
|
|
|
40
|
+
// lv_theme_default's textarea cursor: a 2 px left border, pad_left -1, so it
|
|
41
|
+
// sits one pixel left of the letter and spans the font's line height plus the
|
|
42
|
+
// border above and below.
|
|
37
43
|
constexpr int kInputCaretWidth = 2;
|
|
38
|
-
constexpr int
|
|
44
|
+
constexpr int kInputCaretOutset = 2;
|
|
39
45
|
// Match text.cpp's local kBitmapFontHeight — used as the implicit font size
|
|
40
46
|
// when an input doesn't have an explicit font_size set, so the vertical
|
|
41
47
|
// centering formula here matches the height the framework's bitmap text path
|
|
@@ -47,12 +53,47 @@ inline gea::framework::graphics::pixel::native_t kPlaceholderColor()
|
|
|
47
53
|
return gea::framework::graphics::pixel::nativeColor(71, 85, 105);
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
bool isPasswordInput(int id)
|
|
57
|
+
{
|
|
58
|
+
const char *type = Tree::instance().getAttribute(id, "type");
|
|
59
|
+
return type && std::strcmp(type, "password") == 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// lv_textarea's password bullet (LV_TEXTAREA_PWD_BULLET_UNICODE).
|
|
63
|
+
constexpr const char *kPasswordBullet = "\xE2\x80\xA2";
|
|
64
|
+
|
|
65
|
+
// What a password input shows for value[0, end): a bullet per character,
|
|
66
|
+
// except the ones typed in the last burst, still shown in clear.
|
|
67
|
+
std::string passwordDisplay(int id, const char *value, int end)
|
|
68
|
+
{
|
|
69
|
+
int from = 0, to = 0;
|
|
70
|
+
const bool reveal = Tree::instance().inputPasswordReveal(id, &from, &to);
|
|
71
|
+
std::string out;
|
|
72
|
+
for (int i = 0; i < end && value[i]; ++i) {
|
|
73
|
+
if (reveal && i >= from && i < to) out.push_back(value[i]);
|
|
74
|
+
else out += kPasswordBullet;
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The display string of each password input, kept alive for its DrawText.
|
|
80
|
+
std::unordered_map<int, std::string> &passwordTexts()
|
|
81
|
+
{
|
|
82
|
+
static std::unordered_map<int, std::string> texts;
|
|
83
|
+
return texts;
|
|
84
|
+
}
|
|
85
|
+
|
|
50
86
|
const char *inputContentText(int id, gea::framework::graphics::pixel::native_t *outColor, gea::framework::graphics::pixel::native_t textColor)
|
|
51
87
|
{
|
|
52
88
|
auto &tree = Tree::instance();
|
|
53
89
|
const char *value = tree.getAttribute(id, "value");
|
|
54
90
|
if (value && value[0]) {
|
|
55
91
|
if (outColor) *outColor = textColor;
|
|
92
|
+
if (isPasswordInput(id)) {
|
|
93
|
+
std::string &text = passwordTexts()[id];
|
|
94
|
+
text = passwordDisplay(id, value, static_cast<int>(std::strlen(value)));
|
|
95
|
+
return text.c_str();
|
|
96
|
+
}
|
|
56
97
|
return value;
|
|
57
98
|
}
|
|
58
99
|
const char *placeholder = tree.getAttribute(id, "placeholder");
|
|
@@ -178,26 +219,30 @@ void InputRenderer::record(int id)
|
|
|
178
219
|
// unfocused would be misleading on targets where the framework handles
|
|
179
220
|
// the input's visual editing state.
|
|
180
221
|
if (tree.activeInputId() == id && tree.activeInputCaretVisible()) {
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
// goes at the START of the content box — typing the first
|
|
185
|
-
// character would land there, and the placeholder gets visually
|
|
186
|
-
// pushed aside by the appearing glyph. Measuring the placeholder
|
|
187
|
-
// here would be wrong: it'd put the caret at the end of a
|
|
188
|
-
// string the user isn't actually editing.
|
|
222
|
+
// At the caret: the width of what is shown before it (bullets on a
|
|
223
|
+
// password), from the content's left edge; at the start when the
|
|
224
|
+
// placeholder shows.
|
|
189
225
|
const char *valueAttr = tree.getAttribute(id, "value");
|
|
190
226
|
const bool hasValue = valueAttr && valueAttr[0];
|
|
191
|
-
int caretX = contentX;
|
|
227
|
+
int caretX = contentX - 1;
|
|
192
228
|
if (hasValue) {
|
|
193
|
-
const int
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
const int caret = tree.activeInputCaret();
|
|
230
|
+
const std::string prefix = isPasswordInput(id) ? passwordDisplay(id, valueAttr, caret) : std::string(valueAttr, caret);
|
|
231
|
+
const int prefixWidth = TextRenderer::measureWidth(prefix.c_str(), n.computedStyle().font_id, n.computedStyle().font_size, n.computedStyle().text_transform);
|
|
232
|
+
caretX += prefixWidth < contentW ? prefixWidth : contentW - kInputCaretWidth;
|
|
233
|
+
}
|
|
234
|
+
const int fontSize = n.computedStyle().font_size > 0 ? n.computedStyle().font_size : 16;
|
|
235
|
+
const int lineHeight = TextRenderer::measureHeight("M", n.computedStyle().font_id, n.computedStyle().font_size, n.computedStyle().text_transform, n.computedStyle().line_height);
|
|
236
|
+
int textY = contentY + (contentH - fontSize) / 2;
|
|
237
|
+
if (textY < contentY) textY = contentY;
|
|
238
|
+
const int caretY = textY - kInputCaretOutset;
|
|
239
|
+
const int caretH = lineHeight + kInputCaretOutset * 2;
|
|
240
|
+
// caret-color, else the text colour (a placeholder's grey is not it).
|
|
241
|
+
gea::framework::graphics::pixel::native_t caretColor = n.computedStyle().text_color ? n.computedStyle().text_color : gea::framework::graphics::pixel::nativeColor(255, 255, 255);
|
|
242
|
+
if (const char *cc = tree.getAttribute(id, "caret-color"); cc && cc[0] == '#' && std::strlen(cc) >= 7) {
|
|
243
|
+
const unsigned long rgb = std::strtoul(cc + 1, nullptr, 16);
|
|
244
|
+
caretColor = gea::framework::graphics::pixel::nativeColor((rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff);
|
|
196
245
|
}
|
|
197
|
-
const int caretY = contentY + kInputCaretInsetY;
|
|
198
|
-
int caretH = contentH - kInputCaretInsetY * 2;
|
|
199
|
-
if (caretH < 4) caretH = contentH > 4 ? contentH - 2 : contentH;
|
|
200
|
-
const gea::framework::graphics::pixel::native_t caretColor = n.computedStyle().text_color ? n.computedStyle().text_color : gea::framework::graphics::pixel::nativeColor(255, 255, 255);
|
|
201
246
|
|
|
202
247
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
203
248
|
if (cmd) {
|
package/ui/input_retirement.h
CHANGED
|
@@ -16,6 +16,9 @@ inline bool inputOwnerLeaving(const NodeHandle &owner,const InputRetirementRoots
|
|
|
16
16
|
}
|
|
17
17
|
void retirePointerInputForSubtrees(const InputRetirementRoots &,const InputRetirementRoots &);
|
|
18
18
|
void cancelPrimaryPointerInput();
|
|
19
|
+
// A programmatic scroll of a `snap-page` scroller animates to its target
|
|
20
|
+
// (engine/ui/input.cpp); false when the node does not snap to pages.
|
|
21
|
+
bool animateSnapPageScroll(int node, bool horizontal, int target);
|
|
19
22
|
void retireTouchInputForSubtrees(const InputRetirementRoots &,const InputRetirementRoots &);
|
|
20
23
|
// Weak Core default; actual native platform providers must override this.
|
|
21
24
|
void retirePlatformInputForSubtrees(const InputRetirementRoots &,const InputRetirementRoots &);
|
package/ui/internal.h
CHANGED
|
@@ -73,7 +73,9 @@ void rootScrollImageHoldTick();
|
|
|
73
73
|
BeginFilterBlur,
|
|
74
74
|
ApplyFilterBlur,
|
|
75
75
|
FillTransformedLinearGradient,
|
|
76
|
-
FillTransformedRoundedRect
|
|
76
|
+
FillTransformedRoundedRect,
|
|
77
|
+
// Inline <svg>: rasterizes the svg node's cached scene (svg_element.h).
|
|
78
|
+
DrawSvg
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
struct DisplayCommand
|
|
@@ -111,6 +113,7 @@ void rootScrollImageHoldTick();
|
|
|
111
113
|
gea::framework::graphics::pixel::native_t color;
|
|
112
114
|
} fill;
|
|
113
115
|
struct { int16_t nodeId, x, y, width, height; std::uint32_t identity; } canvasBatch;
|
|
116
|
+
struct { int16_t nodeId, x, y, w, h; } svg;
|
|
114
117
|
struct
|
|
115
118
|
{
|
|
116
119
|
int16_t cx, cy, r;
|
|
@@ -325,6 +328,27 @@ void rootScrollImageHoldTick();
|
|
|
325
328
|
void recordNodeWithExpandedClip(int id, uint8_t parentAlpha, int clipNode,
|
|
326
329
|
int clipX0, int clipY0, int clipX1, int clipY1);
|
|
327
330
|
void replay();
|
|
331
|
+
// The occlusion-cull start replay() would use under the clip now in
|
|
332
|
+
// force; setReplayCullStart(n) makes replay() use n (-1: compute again).
|
|
333
|
+
int replayCullStart();
|
|
334
|
+
void setReplayCullStart(int start);
|
|
335
|
+
// Whether the last replayCullStart() found an opaque fill covering the clip.
|
|
336
|
+
bool replayCullCovered();
|
|
337
|
+
// Filters the list once for the clip now in force: replay() then walks only
|
|
338
|
+
// the commands that can paint inside it until endRegionReplay(). Computes
|
|
339
|
+
// the cull too (replayCullCovered() reports it). False: not filtered, and
|
|
340
|
+
// replay() walks the whole list as before.
|
|
341
|
+
bool beginRegionReplay();
|
|
342
|
+
// Per viewport row: what a horizontal scroll leaves unchanged, or 0
|
|
343
|
+
// (DisplayCommandReplayer::scrollRowSignatures).
|
|
344
|
+
bool scrollRowSignatures(int vx, int vy, int vw, int vh, std::uint32_t *sig);
|
|
345
|
+
void endRegionReplay();
|
|
346
|
+
// A list filtered by beginRegionReplay() is in force (replay() uses it for
|
|
347
|
+
// any clip inside the rect it was filtered for).
|
|
348
|
+
bool regionReplayActive();
|
|
349
|
+
// Whether the list in force was filtered for a rect holding this one, and
|
|
350
|
+
// whether an opaque fill covered that rect.
|
|
351
|
+
bool regionReplayHolds(int x, int y, int w, int h, bool *covered);
|
|
328
352
|
bool canReplayDirectDirtyRegions(int width, int height) const;
|
|
329
353
|
void translateNodeCommands(int node, int dx, int dy);
|
|
330
354
|
void translateSubtreeCommands(int node, int dx, int dy);
|
|
@@ -335,6 +359,9 @@ void rootScrollImageHoldTick();
|
|
|
335
359
|
// full record. Returns true when such a reveal exists.
|
|
336
360
|
bool subtreeRevealsUnrecordedContent(int node, int width, int height) const;
|
|
337
361
|
bool rerecordNodeCommands(int node);
|
|
362
|
+
// rerecordNodeCommands for a node recorded under recordNodeWithExpandedClip:
|
|
363
|
+
// the expanded-clip node's children see the coverage window, as they did then.
|
|
364
|
+
bool rerecordNodeCommandsWithExpandedClip(int node, int clipNode, int clipX0, int clipY0, int clipX1, int clipY1);
|
|
338
365
|
// A pixel buffer referenced by retained blit commands is about to be freed
|
|
339
366
|
// (canvas surface mode flip / resize / removal). The owning node is only
|
|
340
367
|
// *marked* dirty — its re-record happens later — so any replay in the gap
|
|
@@ -382,6 +409,10 @@ void rootScrollImageHoldTick();
|
|
|
382
409
|
void replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count);
|
|
383
410
|
bool canReplaySimpleDirtyRegions(int width, int height) const;
|
|
384
411
|
bool canReplaySimpleDirtyRegions(int width, int height, const DisplayReplayRegion *regions, int count) const;
|
|
412
|
+
// Between begin and end the tree and display list must not change: the
|
|
413
|
+
// region-independent half of the simple-replay verdict is computed once.
|
|
414
|
+
void beginSimpleReplayScope();
|
|
415
|
+
void endSimpleReplayScope();
|
|
385
416
|
void replaySimpleClippedDirtyRegion(int x0, int y0, int x1, int y1, int origin = -1);
|
|
386
417
|
// Static-backdrop cache: bake every non-dirty (static) node into the bg cache
|
|
387
418
|
// buffer once it's stable, so the dirty-region replay can blit that backdrop and
|
|
@@ -424,6 +455,12 @@ void rootScrollImageHoldTick();
|
|
|
424
455
|
void filterBlurCacheStats(int *hits, int *misses) const;
|
|
425
456
|
int commandCount() const;
|
|
426
457
|
bool hasTextClippedBackgrounds() const;
|
|
458
|
+
// Scrollbar thumbs are recorded outside every node's command range;
|
|
459
|
+
// see DisplayListState::scrollbarBoxes.
|
|
460
|
+
void noteScrollbarBox(int node, int x, int y, int w, int h);
|
|
461
|
+
bool scrollbarOverlapsRegion(int x0, int y0, int x1, int y1) const;
|
|
462
|
+
bool scrollbarThumbsPaintLast() const;
|
|
463
|
+
void replayScrollbarThumbsInRegion(int x0, int y0, int x1, int y1);
|
|
427
464
|
int nodeCommandCount(int node) const;
|
|
428
465
|
const DisplayCommand *nodeCommandAt(int node, int index) const;
|
|
429
466
|
bool nodeCommandBounds(int node, int *x0, int *y0, int *x1, int *y1) const;
|
package/ui/layout.cpp
CHANGED
|
@@ -2143,6 +2143,19 @@ static bool isInlineLevelTag(const char *tag)
|
|
|
2143
2143
|
std::strcmp(tag, "mark") == 0;
|
|
2144
2144
|
}
|
|
2145
2145
|
|
|
2146
|
+
// Tag ids are interned once and never reused, so the answer per id is fixed:
|
|
2147
|
+
// layout asks for every node on every pass, where the string test is up to 14
|
|
2148
|
+
// strcmps. Layout runs on one core, so the cache needs no lock.
|
|
2149
|
+
static bool isInlineLevelTagId(int16_t id)
|
|
2150
|
+
{
|
|
2151
|
+
static std::vector<std::int8_t> cache;
|
|
2152
|
+
if (id < 0) return isInlineLevelTag(tagFromId(id));
|
|
2153
|
+
const auto index = static_cast<std::size_t>(id);
|
|
2154
|
+
if (index >= cache.size()) cache.resize(index + 16, -1);
|
|
2155
|
+
if (cache[index] < 0) cache[index] = isInlineLevelTag(tagFromId(id)) ? 1 : 0;
|
|
2156
|
+
return cache[index] != 0;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2146
2159
|
// Box-tree projection for inline ancestors split by in-flow blocks. The DOM
|
|
2147
2160
|
// ancestry still owns inheritance, events, relative translation, and painting.
|
|
2148
2161
|
// Visible inline decorations require fragments; keep those on their own path.
|
|
@@ -2150,7 +2163,7 @@ bool splitInlineWrapper(const Node *nodes, int id)
|
|
|
2150
2163
|
{
|
|
2151
2164
|
const Node &n = nodes[id];
|
|
2152
2165
|
if (n.type != NodeType::View || n.computedStyle().display_explicit || n.computedStyle().display != kDisplayBlock ||
|
|
2153
|
-
!
|
|
2166
|
+
!isInlineLevelTagId(n.tag_id) || n.computedStyle().float_side || isOutOfFlowPosition(n.computedStyle().position) ||
|
|
2154
2167
|
!FlexLayoutPass::paintsNoBox(n) || boxInsets(n.computedStyle(), true) || boxInsets(n.computedStyle(), false) ||
|
|
2155
2168
|
n.computedStyle().margin[1] || n.computedStyle().margin[3] || n.computedStyle().opacity != 255 || overflowEstablishesContext(n.computedStyle())) return false;
|
|
2156
2169
|
bool containsBlock = false;
|
|
@@ -2159,7 +2172,7 @@ bool splitInlineWrapper(const Node *nodes, int id)
|
|
|
2159
2172
|
if (isLayoutExcluded(child)) continue;
|
|
2160
2173
|
if (isOutOfFlowPosition(child.computedStyle().position)) return false;
|
|
2161
2174
|
if (child.computedStyle().float_side) continue;
|
|
2162
|
-
if (child.type == NodeType::View && (child.computedStyle().display_explicit || !
|
|
2175
|
+
if (child.type == NodeType::View && (child.computedStyle().display_explicit || !isInlineLevelTagId(child.tag_id))) containsBlock = true;
|
|
2163
2176
|
if (splitInlineWrapper(nodes, c)) containsBlock = true;
|
|
2164
2177
|
}
|
|
2165
2178
|
return containsBlock;
|
|
@@ -2416,7 +2429,7 @@ private:
|
|
|
2416
2429
|
bool blockBox(const Node &n) const
|
|
2417
2430
|
{
|
|
2418
2431
|
return n.type == NodeType::View && !isLayoutExcluded(n) &&
|
|
2419
|
-
(n.computedStyle().display_explicit || !
|
|
2432
|
+
(n.computedStyle().display_explicit || !isInlineLevelTagId(n.tag_id));
|
|
2420
2433
|
}
|
|
2421
2434
|
|
|
2422
2435
|
bool flowChild(int parent, int child) const
|
|
@@ -4112,7 +4125,7 @@ bool LayoutEngine::isInlineLevelNode(const Node &n)
|
|
|
4112
4125
|
// into one row.
|
|
4113
4126
|
if (n.computedStyle().margin[0] != 0 || n.computedStyle().margin[2] != 0) return false;
|
|
4114
4127
|
if (n.type == NodeType::Text || n.type == NodeType::Image) return true;
|
|
4115
|
-
return
|
|
4128
|
+
return isInlineLevelTagId(n.tag_id);
|
|
4116
4129
|
}
|
|
4117
4130
|
|
|
4118
4131
|
bool LayoutEngine::isCssInlineLevelBox(const Node &n, bool hypothetical)
|
|
@@ -4124,7 +4137,7 @@ bool LayoutEngine::isCssInlineLevelBox(const Node &n, bool hypothetical)
|
|
|
4124
4137
|
if (parent.computedStyle().display == kDisplayFlex || isDisplayGrid(parent.computedStyle())) return false;
|
|
4125
4138
|
}
|
|
4126
4139
|
if (n.type == NodeType::Text || n.type == NodeType::Image) return true;
|
|
4127
|
-
return n.type == NodeType::View &&
|
|
4140
|
+
return n.type == NodeType::View && isInlineLevelTagId(n.tag_id);
|
|
4128
4141
|
}
|
|
4129
4142
|
|
|
4130
4143
|
int LayoutEngine::clampSize(int size, int minSize, int maxSize) const
|
|
@@ -4457,6 +4470,44 @@ bool LayoutEngine::layoutNodeScoped(int scope, int treeRoot)
|
|
|
4457
4470
|
}
|
|
4458
4471
|
return false;
|
|
4459
4472
|
};
|
|
4473
|
+
// The scope's proper descendants in node-index order -- the order the
|
|
4474
|
+
// whole-tree scans below used to visit them in, at the cost of the subtree
|
|
4475
|
+
// rather than of every node in the tree (a ticking legend row re-lays
|
|
4476
|
+
// three nodes; scanning all of them, twice, cost more than its layout).
|
|
4477
|
+
constexpr int kMaxScopeDescendants = 64;
|
|
4478
|
+
int descendants[kMaxScopeDescendants];
|
|
4479
|
+
int descendantCount = 0;
|
|
4480
|
+
bool descendantsOverflow = false;
|
|
4481
|
+
{
|
|
4482
|
+
int stack[kMaxScopeDescendants];
|
|
4483
|
+
int depth = 0;
|
|
4484
|
+
for (int child = a.first_child; child >= 0 && child < nodeCount; child = nodes[child].next_sibling) {
|
|
4485
|
+
if (depth == kMaxScopeDescendants) { descendantsOverflow = true; break; }
|
|
4486
|
+
stack[depth++] = child;
|
|
4487
|
+
}
|
|
4488
|
+
while (depth > 0 && !descendantsOverflow) {
|
|
4489
|
+
const int id = stack[--depth];
|
|
4490
|
+
if (descendantCount == kMaxScopeDescendants) { descendantsOverflow = true; break; }
|
|
4491
|
+
descendants[descendantCount++] = id;
|
|
4492
|
+
for (int child = nodes[id].first_child; child >= 0 && child < nodeCount; child = nodes[child].next_sibling) {
|
|
4493
|
+
if (depth == kMaxScopeDescendants) { descendantsOverflow = true; break; }
|
|
4494
|
+
stack[depth++] = child;
|
|
4495
|
+
}
|
|
4496
|
+
}
|
|
4497
|
+
if (!descendantsOverflow) std::sort(descendants, descendants + descendantCount);
|
|
4498
|
+
}
|
|
4499
|
+
// Visits every proper descendant of the scope, in index order.
|
|
4500
|
+
auto forEachDescendant = [&](auto &&visit) {
|
|
4501
|
+
if (!descendantsOverflow) {
|
|
4502
|
+
for (int k = 0; k < descendantCount; ++k)
|
|
4503
|
+
if (!visit(descendants[k])) return;
|
|
4504
|
+
return;
|
|
4505
|
+
}
|
|
4506
|
+
for (int i = 0; i < nodeCount; ++i) {
|
|
4507
|
+
if (i == scope || !inScope(i)) continue;
|
|
4508
|
+
if (!visit(i)) return;
|
|
4509
|
+
}
|
|
4510
|
+
};
|
|
4460
4511
|
|
|
4461
4512
|
// Absolute descendants positioned against a containing block OUTSIDE the
|
|
4462
4513
|
// scope mix coordinate spaces (the global containing-block pass runs in
|
|
@@ -4465,17 +4516,19 @@ bool LayoutEngine::layoutNodeScoped(int scope, int treeRoot)
|
|
|
4465
4516
|
// recomputed, and a size change is rejected by the dims check. Testing it
|
|
4466
4517
|
// here refused every absolutely placed scope (Ember's temperature readout,
|
|
4467
4518
|
// then its screen), so each tick of a number fell back to a full relayout.
|
|
4468
|
-
|
|
4519
|
+
bool escapes = false;
|
|
4520
|
+
forEachDescendant([&](int i) {
|
|
4469
4521
|
const Node &n = nodes[i];
|
|
4470
|
-
if (
|
|
4471
|
-
if (n.parent < 0 || !isOutOfFlowPosition(n.computedStyle().position) || isLayoutExcluded(n)) continue;
|
|
4472
|
-
if (!inScope(i)) continue;
|
|
4522
|
+
if (n.parent < 0 || !isOutOfFlowPosition(n.computedStyle().position) || isLayoutExcluded(n)) return true;
|
|
4473
4523
|
const int containing = containingBlockForAbsoluteNode(i, treeRoot, nodes);
|
|
4474
4524
|
if (containing >= 0 && !inScope(containing)) {
|
|
4475
4525
|
GEA_REFRESH_PERF(refreshPerfStatsMutable().treeScopedRejectNode = i);
|
|
4526
|
+
escapes = true;
|
|
4476
4527
|
return false;
|
|
4477
4528
|
}
|
|
4478
|
-
|
|
4529
|
+
return true;
|
|
4530
|
+
});
|
|
4531
|
+
if (escapes) return false;
|
|
4479
4532
|
|
|
4480
4533
|
const int prevX = a.layout.x;
|
|
4481
4534
|
const int prevY = a.layout.y;
|
|
@@ -4531,13 +4584,12 @@ bool LayoutEngine::layoutNodeScoped(int scope, int treeRoot)
|
|
|
4531
4584
|
|
|
4532
4585
|
// Scoped equivalent of the root containing-block pass (both the node and
|
|
4533
4586
|
// its containing block are inside the scope, in the same relative space).
|
|
4534
|
-
|
|
4535
|
-
if (isLayoutExcluded(nodes[i]) || !isOutOfFlowPosition(nodes[i].computedStyle().position) || nodes[i].parent < 0)
|
|
4536
|
-
if (!inScope(i) || i == scope) continue;
|
|
4587
|
+
forEachDescendant([&](int i) {
|
|
4588
|
+
if (isLayoutExcluded(nodes[i]) || !isOutOfFlowPosition(nodes[i].computedStyle().position) || nodes[i].parent < 0) return true;
|
|
4537
4589
|
const int containing = containingBlockForAbsoluteNode(i, scope, nodes);
|
|
4538
|
-
if (containing
|
|
4539
|
-
|
|
4540
|
-
}
|
|
4590
|
+
if (containing >= 0) positionAbsoluteNodeInContainingBlock(i, containing, nodes);
|
|
4591
|
+
return true;
|
|
4592
|
+
});
|
|
4541
4593
|
|
|
4542
4594
|
int childParentX = a.layout.x;
|
|
4543
4595
|
int childParentY = a.layout.y;
|
package/ui/layout_snapshot.cpp
CHANGED
|
@@ -5,92 +5,108 @@
|
|
|
5
5
|
|
|
6
6
|
namespace gea::embedded::ui {
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
namespace {
|
|
9
|
+
|
|
10
|
+
// One node's half of capture(): its current layout becomes the previous one
|
|
11
|
+
// and its per-frame dirt is cleared.
|
|
12
|
+
void captureNode(int i, bool captureTransforms)
|
|
9
13
|
{
|
|
10
14
|
auto &state = treeState();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// them. The filter snapshot is independent and retained when filters are reachable.
|
|
17
|
-
#if GEA_CSS_TRANSFORMS
|
|
18
|
-
const bool captureTransforms = ViewRenderer::anyTransformActive();
|
|
19
|
-
#endif
|
|
20
|
-
for (int i = 0; i < state.nodeCount; i++) {
|
|
21
|
-
state.nodes[i].layout.previous_x = state.nodes[i].layout.x;
|
|
22
|
-
state.nodes[i].layout.previous_y = state.nodes[i].layout.y;
|
|
23
|
-
state.nodes[i].layout.previous_width = state.nodes[i].layout.width;
|
|
24
|
-
state.nodes[i].layout.previous_height = state.nodes[i].layout.height;
|
|
15
|
+
(void)captureTransforms;
|
|
16
|
+
state.nodes[i].layout.previous_x = state.nodes[i].layout.x;
|
|
17
|
+
state.nodes[i].layout.previous_y = state.nodes[i].layout.y;
|
|
18
|
+
state.nodes[i].layout.previous_width = state.nodes[i].layout.width;
|
|
19
|
+
state.nodes[i].layout.previous_height = state.nodes[i].layout.height;
|
|
25
20
|
#if GEA_CSS_SCROLLING
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#endif
|
|
29
|
-
// ONE RareStyle pool lookup per node, not ~16 — rstyle() is an out-of-line
|
|
30
|
-
// deque index (separate cache line from the node). Per-field lookups here cost
|
|
31
|
-
// ~1ms/frame on the spinning css-3d-cube (the "snap" phase); spine read these as
|
|
32
|
-
// direct ComputedStyle fields. (Same regression class as the reproject path.)
|
|
33
|
-
#if GEA_CSS_TRANSFORMS || GEA_CSS_FILTERS
|
|
34
|
-
const RareStyle &rs = rstyle(state.nodes[i].computedStyle());
|
|
21
|
+
state.nodes[i].layout.previous_scroll_x = state.nodes[i].layout.scroll_x;
|
|
22
|
+
state.nodes[i].layout.previous_scroll_y = state.nodes[i].layout.scroll_y;
|
|
35
23
|
#endif
|
|
24
|
+
// ONE RareStyle pool lookup per node, not ~16 — rstyle() is an out-of-line
|
|
25
|
+
// deque index (separate cache line from the node). Per-field lookups here cost
|
|
26
|
+
// ~1ms/frame on the spinning css-3d-cube (the "snap" phase); spine read these as
|
|
27
|
+
// direct ComputedStyle fields. (Same regression class as the reproject path.)
|
|
36
28
|
#if GEA_CSS_TRANSFORMS
|
|
29
|
+
// previous_transformable_box is captured with the transforms it qualifies.
|
|
30
|
+
// Every reader ANDs it with a previous transform or perspective, and with
|
|
31
|
+
// no transform active those hold the identity this capture last wrote, so
|
|
32
|
+
// the stale box can't change an answer -- and the per-node box test (a
|
|
33
|
+
// style read) was most of this loop on a transform-free tree.
|
|
34
|
+
if (captureTransforms) {
|
|
35
|
+
const RareStyle &rs = rstyle(state.nodes[i].computedStyle());
|
|
37
36
|
state.nodes[i].render.previous_transformable_box = ViewRenderer::isTransformableBox(state.nodes[i]);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
state.nodes[i].render.previous_scale_z = rs.scale_z;
|
|
37
|
+
state.nodes[i].render.previous_rotate_angle = rs.rotate_angle;
|
|
38
|
+
state.nodes[i].render.previous_rotate_axis_x = rs.rotate_axis_x;
|
|
39
|
+
state.nodes[i].render.previous_rotate_axis_y = rs.rotate_axis_y;
|
|
40
|
+
state.nodes[i].render.previous_rotate_axis_z = rs.rotate_axis_z;
|
|
41
|
+
state.nodes[i].render.previous_scale_x = rs.scale_x;
|
|
42
|
+
state.nodes[i].render.previous_scale_y = rs.scale_y;
|
|
43
|
+
state.nodes[i].render.previous_scale_z = rs.scale_z;
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
state.nodes[i].render.previous_transform_rotate = rs.transform_rotate;
|
|
46
|
+
state.nodes[i].render.previous_transform_rotate_x = rs.transform_rotate_x;
|
|
47
|
+
state.nodes[i].render.previous_transform_rotate_y = rs.transform_rotate_y;
|
|
48
|
+
state.nodes[i].render.previous_transform_translate_x = composedTranslateX(rs);
|
|
49
|
+
state.nodes[i].render.previous_translate_x = rs.translate_x;
|
|
50
|
+
state.nodes[i].render.previous_translate_y = rs.translate_y;
|
|
51
|
+
state.nodes[i].render.previous_translate_z = rs.translate_z;
|
|
52
|
+
state.nodes[i].render.previous_translate_x_percent = rs.translate_x_percent;
|
|
53
|
+
state.nodes[i].render.previous_translate_y_percent = rs.translate_y_percent;
|
|
54
|
+
state.nodes[i].render.previous_transform_translate_outer_axes = rs.transform_translate_outer_axes;
|
|
55
|
+
state.nodes[i].render.previous_transform_translate_y = composedTranslateY(rs);
|
|
56
|
+
state.nodes[i].render.previous_transform_translate_z = composedTranslateZ(rs);
|
|
57
|
+
state.nodes[i].render.previous_transform_translate_x_percent = composedTranslateXPercent(rs);
|
|
58
|
+
state.nodes[i].render.previous_transform_translate_y_percent = composedTranslateYPercent(rs);
|
|
59
|
+
state.nodes[i].render.previous_transform_scale_x = rs.transform_scale_x;
|
|
60
|
+
state.nodes[i].render.previous_transform_scale_y = rs.transform_scale_y;
|
|
61
|
+
state.nodes[i].render.previous_transform_scale_z = rs.transform_scale_z;
|
|
62
|
+
state.nodes[i].render.previous_transform_origin_x = rs.transform_origin_x;
|
|
63
|
+
state.nodes[i].render.previous_transform_origin_y = rs.transform_origin_y;
|
|
64
|
+
state.nodes[i].render.previous_perspective = rs.perspective;
|
|
65
|
+
state.nodes[i].render.previous_perspective_origin_x = rs.perspective_origin_x;
|
|
66
|
+
state.nodes[i].render.previous_perspective_origin_y = rs.perspective_origin_y;
|
|
67
|
+
}
|
|
70
68
|
#endif
|
|
71
69
|
#if GEA_CSS_FILTERS
|
|
72
|
-
|
|
70
|
+
state.nodes[i].render.previous_filter_blur_radius = rstyle(state.nodes[i].computedStyle()).filter_blur_radius;
|
|
73
71
|
#endif
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
state.nodes[i].render.dirty = 0;
|
|
73
|
+
state.nodes[i].render.canvas_pixels_only_dirty = 0;
|
|
74
|
+
state.nodes[i].render.layout_dirty = 0;
|
|
77
75
|
#if GEA_CSS_SCROLLING
|
|
78
|
-
|
|
76
|
+
state.nodes[i].render.scroll_dirty = 0;
|
|
79
77
|
#endif
|
|
80
78
|
#if GEA_CSS_SCROLLING
|
|
81
|
-
|
|
79
|
+
state.nodes[i].render.non_scroll_dirty = 0;
|
|
82
80
|
#endif
|
|
83
81
|
#if GEA_CSS_TRANSFORMS
|
|
84
|
-
|
|
82
|
+
state.nodes[i].render.transform_dirty = 0;
|
|
85
83
|
#endif
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
state.nodes[i].render.bg_recolor_pending = 0;
|
|
85
|
+
state.nodes[i].render.text_layout_stable = 0;
|
|
86
|
+
state.nodes[i].render.text_partial_dirty = 0;
|
|
87
|
+
state.nodeCommandDirty[i] = 0;
|
|
88
|
+
state.nodeCommandDirtyBoundsValid[i] = 0;
|
|
89
|
+
state.nodeCommandDirtyCanOverpaint[i] = 0;
|
|
90
|
+
if (state.nodes[i].type == NodeType::VirtualList) VirtualListRenderer::captureSnapshot(i);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
} // namespace
|
|
94
|
+
|
|
95
|
+
void LayoutSnapshot::capture()
|
|
96
|
+
{
|
|
97
|
+
auto &state = treeState();
|
|
98
|
+
// Snapshotting previous_transform_* costs ~15 pooled rstyle() reads per node. They
|
|
99
|
+
// are ONLY read back when a transform is active (transformedBounds early-outs on
|
|
100
|
+
// !anyTransformActive), and anyTransformActive checks both current and previous
|
|
101
|
+
// transforms — so for a tree with no transforms (e.g. bouncing-balls) these reads
|
|
102
|
+
// are pure per-frame waste and the stale previous_* values are never observed. Skip
|
|
103
|
+
// them. The filter snapshot is independent and retained when filters are reachable.
|
|
104
|
+
#if GEA_CSS_TRANSFORMS
|
|
105
|
+
const bool captureTransforms = ViewRenderer::anyTransformActive();
|
|
106
|
+
#else
|
|
107
|
+
constexpr bool captureTransforms = false;
|
|
108
|
+
#endif
|
|
109
|
+
for (int i = 0; i < state.nodeCount; i++) captureNode(i, captureTransforms);
|
|
94
110
|
#if GEA_CSS_SCROLLING
|
|
95
111
|
for (int i = 0; i < kScrollDirtyWordCount; i++)
|
|
96
112
|
state.scrollDirtyNodes[i] = 0;
|
|
@@ -105,6 +121,39 @@ void LayoutSnapshot::capture()
|
|
|
105
121
|
#endif
|
|
106
122
|
}
|
|
107
123
|
|
|
124
|
+
// capture() for a frame that touched only `ids` and the subtree of `subtreeRoot`
|
|
125
|
+
// (a scroll fast-path frame: no layout ran, so every other node's current and
|
|
126
|
+
// previous layout already agree and its dirt is clear). A pass over every node
|
|
127
|
+
// reads each one from PSRAM: ~2-3 ms of a CrowPanel scroll frame.
|
|
128
|
+
void LayoutSnapshot::captureNodes(const int *ids, int count, int subtreeRoot)
|
|
129
|
+
{
|
|
130
|
+
auto &state = treeState();
|
|
131
|
+
#if GEA_CSS_TRANSFORMS
|
|
132
|
+
if (ViewRenderer::anyTransformActive()) {
|
|
133
|
+
capture();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
#endif
|
|
137
|
+
constexpr bool captureTransforms = false;
|
|
138
|
+
for (int k = 0; k < count; k++) captureNode(ids[k], captureTransforms);
|
|
139
|
+
const Node *nodes = state.nodes;
|
|
140
|
+
for (int id = subtreeRoot; id >= 0;) {
|
|
141
|
+
captureNode(id, captureTransforms);
|
|
142
|
+
if (nodes[id].first_child >= 0) {
|
|
143
|
+
id = nodes[id].first_child;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
while (id != subtreeRoot && nodes[id].next_sibling < 0) id = nodes[id].parent;
|
|
147
|
+
if (id == subtreeRoot) break;
|
|
148
|
+
id = nodes[id].next_sibling;
|
|
149
|
+
}
|
|
150
|
+
#if GEA_CSS_SCROLLING
|
|
151
|
+
for (int i = 0; i < kScrollDirtyWordCount; i++)
|
|
152
|
+
state.scrollDirtyNodes[i] = 0;
|
|
153
|
+
state.scrollDirtyAny = false;
|
|
154
|
+
#endif
|
|
155
|
+
}
|
|
156
|
+
|
|
108
157
|
void LayoutSnapshot::markChangesDirty()
|
|
109
158
|
{
|
|
110
159
|
auto &state = treeState();
|
package/ui/layout_snapshot.h
CHANGED
package/ui/node_features.h
CHANGED
|
@@ -29,6 +29,12 @@ static_assert(GEA_UI_CLASS_INLINE_TOKENS >= 1 && GEA_UI_CLASS_INLINE_TOKENS <= 4
|
|
|
29
29
|
|
|
30
30
|
// Closed whole-source auxiliary-state proof. Unknown/older programs keep all
|
|
31
31
|
// owners; callers cannot prune these through application manifest switches.
|
|
32
|
+
// Inline <svg>: the element, its scene cache and the SVG paint properties in
|
|
33
|
+
// RareStyle. The plugin proves absence (node-svg); unknown programs keep it.
|
|
34
|
+
#ifndef GEA_UI_SVG
|
|
35
|
+
#define GEA_UI_SVG 1
|
|
36
|
+
#endif
|
|
37
|
+
|
|
32
38
|
#ifndef GEA_UI_NODE_LISTENERS
|
|
33
39
|
#define GEA_UI_NODE_LISTENERS 1
|
|
34
40
|
#endif
|
package/ui/node_model.h
CHANGED
|
@@ -161,6 +161,22 @@ inline bool isNativeButtonNodeType(NodeType type)
|
|
|
161
161
|
// BEFORE ComputedStyle so it can be a by-value member).
|
|
162
162
|
struct RareStyle {
|
|
163
163
|
bool operator==(const RareStyle &) const = default;
|
|
164
|
+
#if GEA_UI_SVG
|
|
165
|
+
// SVG paint. Unset (0 / -1) means "inherit from the SVG parent"; the scene
|
|
166
|
+
// resolver walks the svg subtree, so no inheritance machinery runs for them.
|
|
167
|
+
int32_t svg_fill = 0; // svg::encodePaint
|
|
168
|
+
int32_t svg_stroke = 0; // svg::encodePaint
|
|
169
|
+
int32_t svg_stroke_width = -1; // px * 100
|
|
170
|
+
int16_t svg_fill_opacity = -1; // 0..1000
|
|
171
|
+
int16_t svg_stroke_opacity = -1; // 0..1000
|
|
172
|
+
int8_t svg_stroke_linecap = -1; // svg::LineCap
|
|
173
|
+
int8_t svg_stroke_linejoin = -1; // svg::LineJoin
|
|
174
|
+
int8_t svg_fill_rule = -1; // 0 nonzero, 1 evenodd
|
|
175
|
+
#else
|
|
176
|
+
static constexpr int32_t svg_fill = 0, svg_stroke = 0, svg_stroke_width = -1;
|
|
177
|
+
static constexpr int16_t svg_fill_opacity = -1, svg_stroke_opacity = -1;
|
|
178
|
+
static constexpr int8_t svg_stroke_linecap = -1, svg_stroke_linejoin = -1, svg_fill_rule = -1;
|
|
179
|
+
#endif
|
|
164
180
|
// Logical edges: block-start/end, inline-start/end.
|
|
165
181
|
#if GEA_CSS_MARGIN_TRIM
|
|
166
182
|
uint8_t margin_trim = 0;
|
|
@@ -494,7 +510,7 @@ inline int composedTranslateZ(const RareStyle &s) { return int(s.transform_trans
|
|
|
494
510
|
inline int composedTranslateXPercent(const RareStyle &s) { return int(s.transform_translate_x_percent) + s.translate_x_percent; }
|
|
495
511
|
inline int composedTranslateYPercent(const RareStyle &s) { return int(s.transform_translate_y_percent) + s.translate_y_percent; }
|
|
496
512
|
|
|
497
|
-
#define GEA_CSS_RARE_STYLE (GEA_CSS_ASPECT_RATIO || GEA_CSS_BACKGROUND_LAYERS || GEA_CSS_BORDER_RELIEF || GEA_CSS_BOX_EXPRESSIONS || GEA_CSS_BOX_SHADOW || GEA_CSS_CONTAINMENT || GEA_CSS_FILTERS || GEA_CSS_FLEX_BASIS_EXPRESSIONS || GEA_CSS_FLEX_LINE_COUNT || GEA_CSS_GRID || GEA_CSS_JUSTIFY_SELF || GEA_CSS_LINE_HEIGHT_EXPRESSIONS || GEA_CSS_MARGIN_TRIM || GEA_CSS_SIDE_BORDERS || GEA_CSS_TRANSFORMS || GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS)
|
|
513
|
+
#define GEA_CSS_RARE_STYLE (GEA_CSS_ASPECT_RATIO || GEA_CSS_BACKGROUND_LAYERS || GEA_CSS_BORDER_RELIEF || GEA_CSS_BOX_EXPRESSIONS || GEA_CSS_BOX_SHADOW || GEA_CSS_CONTAINMENT || GEA_CSS_FILTERS || GEA_CSS_FLEX_BASIS_EXPRESSIONS || GEA_CSS_FLEX_LINE_COUNT || GEA_CSS_GRID || GEA_CSS_JUSTIFY_SELF || GEA_CSS_LINE_HEIGHT_EXPRESSIONS || GEA_CSS_MARGIN_TRIM || GEA_CSS_SIDE_BORDERS || GEA_CSS_TRANSFORMS || GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS || GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS || GEA_UI_SVG)
|
|
498
514
|
static_assert(GEA_CSS_RARE_STYLE || std::is_empty<RareStyle>::value, "An unguarded rare field requires a reachability family");
|
|
499
515
|
|
|
500
516
|
struct ComputedStyle {
|
|
@@ -1341,7 +1357,12 @@ inline bool scrollsOverflowY(const ComputedStyle &style)
|
|
|
1341
1357
|
inline bool hasSideBorder(const ComputedStyle &style)
|
|
1342
1358
|
{
|
|
1343
1359
|
#if GEA_CSS_SIDE_BORDERS
|
|
1344
|
-
|
|
1360
|
+
#if !GEA_EMBEDDED_RARE_STYLE_INLINE
|
|
1361
|
+
// Pooled mode: no entry => no per-side borders. Inline mode never assigns a
|
|
1362
|
+
// handle (the fields live in the style itself), so the guard would drop every
|
|
1363
|
+
// side border there.
|
|
1364
|
+
if (style.rare_style < 0) return false;
|
|
1365
|
+
#endif
|
|
1345
1366
|
const RareStyle &r = rstyle(style);
|
|
1346
1367
|
return r.border_side_width[0] > 0 ||
|
|
1347
1368
|
r.border_side_width[1] > 0 ||
|