@geastack/engine 0.1.5 → 0.1.7

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.
Files changed (45) hide show
  1. package/README.md +70 -0
  2. package/canvas.cpp +86 -30
  3. package/css/animation.h +64 -0
  4. package/css/declarative.h +6 -0
  5. package/css/engine.h +25 -1
  6. package/image_store.cpp +136 -33
  7. package/package.json +2 -2
  8. package/ui/CSS_FEATURES.md +261 -0
  9. package/ui/absolute_leaf_refresh.cpp +42 -39
  10. package/ui/core.cpp +32 -1
  11. package/ui/css_atom.cpp +6 -0
  12. package/ui/css_atom.h +2 -0
  13. package/ui/css_features.h +282 -0
  14. package/ui/display_invalidation.cpp +29 -0
  15. package/ui/flex_balance.h +73 -0
  16. package/ui/image_node.cpp +33 -28
  17. package/ui/input.cpp +88 -38
  18. package/ui/input_render.cpp +17 -13
  19. package/ui/internal.h +51 -5
  20. package/ui/layout.cpp +2601 -441
  21. package/ui/layout_snapshot.cpp +49 -6
  22. package/ui/node_features.h +18 -0
  23. package/ui/node_lifecycle.cpp +204 -71
  24. package/ui/node_lifecycle.h +1 -0
  25. package/ui/node_model.h +930 -70
  26. package/ui/node_text.h +82 -0
  27. package/ui/render.cpp +793 -352
  28. package/ui/renderer_features.h +19 -0
  29. package/ui/root_scroll_refresh.cpp +46 -24
  30. package/ui/style.cpp +4155 -1073
  31. package/ui/style.h +143 -6
  32. package/ui/style_values.h +16 -0
  33. package/ui/text.cpp +401 -106
  34. package/ui/tree_events.cpp +138 -95
  35. package/ui/tree_events.h +28 -19
  36. package/ui/tree_inspection.h +15 -0
  37. package/ui/tree_internal.h +19 -0
  38. package/ui/tree_nodes.cpp +38 -4
  39. package/ui/tree_render.cpp +119 -40
  40. package/ui/tree_scroll_mirror.cpp +26 -0
  41. package/ui/tree_state.cpp +261 -114
  42. package/ui/tree_state.h +121 -16
  43. package/ui/tree_style.cpp +609 -82
  44. package/ui/view.cpp +720 -299
  45. package/ui/virtual_keyboard.cpp +10 -3
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+
4
+ // Generated from the app's source/style analysis by the build driver. These
5
+ // describe reachable instructions, not app configuration switches. Builds made
6
+ // without an analyzer retain the complete renderer. Cache sizing only matters
7
+ // inside a feature's enabled branch; the disabled branches use no cache storage.
8
+ #ifndef GEA_EMBEDDED_RENDERER_CIRCLES
9
+ #define GEA_EMBEDDED_RENDERER_CIRCLES 1
10
+ #endif
11
+ #ifndef GEA_EMBEDDED_RENDERER_TRANSFORMS
12
+ #define GEA_EMBEDDED_RENDERER_TRANSFORMS 1
13
+ #endif
14
+ #ifndef GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
15
+ #define GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS 1
16
+ #endif
17
+ #ifndef GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
18
+ #define GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS 1
19
+ #endif
@@ -29,30 +29,34 @@
29
29
 
30
30
  namespace gea::embedded::ui {
31
31
 
32
+ #if GEA_CSS_SCROLLING
32
33
  namespace {
33
34
 
34
35
  bool hasTransformState(const Node &node)
35
36
  {
36
- return rstyle(node.style).transform_rotate != 0 ||
37
+ return hasIndividualLinearTransform(rstyle(node.style)) || hadIndividualLinearTransform(node.render) ||
38
+ rstyle(node.style).transform_rotate != 0 ||
37
39
  node.render.previous_transform_rotate != 0 ||
38
40
  rstyle(node.style).transform_rotate_x != 0 ||
39
41
  node.render.previous_transform_rotate_x != 0 ||
40
42
  rstyle(node.style).transform_rotate_y != 0 ||
41
43
  node.render.previous_transform_rotate_y != 0 ||
42
- rstyle(node.style).transform_translate_x != 0 ||
44
+ composedTranslateX(rstyle(node.style)) != 0 ||
43
45
  node.render.previous_transform_translate_x != 0 ||
44
- rstyle(node.style).transform_translate_y != 0 ||
46
+ composedTranslateY(rstyle(node.style)) != 0 ||
45
47
  node.render.previous_transform_translate_y != 0 ||
46
- rstyle(node.style).transform_translate_z != 0 ||
48
+ composedTranslateZ(rstyle(node.style)) != 0 ||
47
49
  node.render.previous_transform_translate_z != 0 ||
48
- rstyle(node.style).transform_translate_x_percent != 0 ||
50
+ composedTranslateXPercent(rstyle(node.style)) != 0 ||
49
51
  node.render.previous_transform_translate_x_percent != 0 ||
50
- rstyle(node.style).transform_translate_y_percent != 0 ||
52
+ composedTranslateYPercent(rstyle(node.style)) != 0 ||
51
53
  node.render.previous_transform_translate_y_percent != 0 ||
52
54
  rstyle(node.style).transform_scale_x != 1000 ||
53
55
  node.render.previous_transform_scale_x != 1000 ||
54
56
  rstyle(node.style).transform_scale_y != 1000 ||
57
+ rstyle(node.style).transform_scale_z != 1000 ||
55
58
  node.render.previous_transform_scale_y != 1000 ||
59
+ node.render.previous_transform_scale_z != 1000 ||
56
60
  rstyle(node.style).perspective > 0 ||
57
61
  node.render.previous_perspective > 0;
58
62
  }
@@ -104,8 +108,8 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
104
108
  if (n.style.position != 1) return false;
105
109
  // Anchored via top/bottom (the windowed axis); refresh() recomputes y from
106
110
  // these offsets directly.
107
- if (n.style.pos_offsets[0] == kUnset && n.style.pos_offset_percent[0] == kUnset &&
108
- n.style.pos_offsets[2] == kUnset && n.style.pos_offset_percent[2] == kUnset)
111
+ if (GEA_CSS_POSITION_PX_0(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_0(n.style) == kUnset &&
112
+ GEA_CSS_POSITION_PX_2(n.style) == kUnset && GEA_CSS_POSITION_PERCENT_2(n.style) == kUnset)
109
113
  return false;
110
114
  if (hasTransformState(n)) return false;
111
115
  // The reconcile translates the slot box; a pending size change needs layout.
@@ -114,10 +118,11 @@ bool isSlotRepositionCandidate(const TreeState &state, int node, int scrollNode)
114
118
  return true;
115
119
  }
116
120
 
117
- int resolvedSlotOffset(const Node &slot, int side, int basis)
121
+ template <int side>
122
+ int resolvedSlotOffset(const Node &slot, int basis)
118
123
  {
119
- int offset = slot.style.pos_offsets[side] != kUnset ? slot.style.pos_offsets[side] : 0;
120
- const int percent = slot.style.pos_offset_percent[side];
124
+ int offset = GEA_CSS_POSITION_PX(slot.style, side) != kUnset ? GEA_CSS_POSITION_PX(slot.style, side) : 0;
125
+ const int percent = GEA_CSS_POSITION_PERCENT(slot.style, side);
121
126
  if (percent != kUnset) {
122
127
  const int numerator = basis * percent;
123
128
  offset += (numerator + (numerator >= 0 ? 500 : -500)) / 1000;
@@ -168,7 +173,7 @@ bool flowsChildrenAsRow(const TreeState &state, const Node &p)
168
173
  bool anyInFlow = false;
169
174
  for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
170
175
  const Node &child = state.nodes[c];
171
- if (child.style.display == kDisplayNone || child.style.position == 1) continue;
176
+ if (child.style.display == kDisplayNone || isOutOfFlowPosition(child.style.position)) continue;
172
177
  if (!LayoutEngine::isInlineLevelNode(child)) return false;
173
178
  anyInFlow = true;
174
179
  }
@@ -198,13 +203,13 @@ void shiftSiblingsForRemeasuredText(TreeState &state, int id, int oldWidth, int
198
203
  int totalFlex = 0;
199
204
  for (int c = p.first_child; c >= 0; c = state.nodes[c].next_sibling) {
200
205
  const Node &child = state.nodes[c];
201
- if (child.style.display == kDisplayNone || child.style.position == 1) continue;
206
+ if (child.style.display == kDisplayNone || isOutOfFlowPosition(child.style.position)) continue;
202
207
  totalFlex += child.style.flex;
203
208
  }
204
209
  if (totalFlex > 0) return;
205
210
  for (int c = n.next_sibling; c >= 0; c = state.nodes[c].next_sibling) {
206
211
  Node &sib = state.nodes[c];
207
- if (sib.style.display == kDisplayNone || sib.style.position == 1) continue;
212
+ if (sib.style.display == kDisplayNone || isOutOfFlowPosition(sib.style.position)) continue;
208
213
  if (row) sib.layout.x += delta;
209
214
  else sib.layout.y += delta;
210
215
  translateSlotDescendants(state, c, row ? delta : 0, row ? 0 : delta);
@@ -299,11 +304,13 @@ int RootScrollOnlyRefresh::refreshNode(int root,
299
304
  int width,
300
305
  int height)
301
306
  {
302
- (void)root;
303
307
  auto &state = treeState();
304
308
  int foundNode = -1;
305
309
  *extraDirtyCount = 0;
306
310
  *slotCount = 0;
311
+ // A scroll blit would move fixed pixels along with the scrolling content.
312
+ // Fall back to layout and repaint until the blit path can exclude them.
313
+ if (LayoutEngine::containsViewportFixed(root)) return -1;
307
314
 
308
315
  // Pass 1: exactly one pure-scroll node.
309
316
  for (int i = 0; i < state.nodeCount; i++) {
@@ -328,7 +335,10 @@ int RootScrollOnlyRefresh::refreshNode(int root,
328
335
  if (hasTransformState(*n)) return -1;
329
336
  if (n->style.opacity != 255 || hasAnyBorder(n->style)) return -1;
330
337
  for (int r = 0; r < 4; r++) {
331
- if (n->style.border_radius[r] != 0 || n->style.border_radius_percent[r] != kUnset) return -1;
338
+ if (n->style.border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return -1;
339
+ #if GEA_CSS_PERCENT_RADIUS
340
+ if (n->style.border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return -1;
341
+ #endif
332
342
  }
333
343
  foundNode = i;
334
344
  continue;
@@ -532,18 +542,18 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
532
542
  if (slot.style.display == 1) continue; // display:none — erase old rect only
533
543
 
534
544
  int newX = slot.layout.x;
535
- if (slot.style.pos_offsets[3] != kUnset || slot.style.pos_offset_percent[3] != kUnset)
536
- newX = n->layout.x + resolvedSlotOffset(slot, 3, n->layout.width);
537
- else if (slot.style.pos_offsets[1] != kUnset || slot.style.pos_offset_percent[1] != kUnset)
545
+ if (GEA_CSS_POSITION_PX_3(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_3(slot.style) != kUnset)
546
+ newX = n->layout.x + resolvedSlotOffset<3>(slot, n->layout.width);
547
+ else if (GEA_CSS_POSITION_PX_1(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_1(slot.style) != kUnset)
538
548
  newX = n->layout.x + n->layout.width - slot.layout.width -
539
- resolvedSlotOffset(slot, 1, n->layout.width);
549
+ resolvedSlotOffset<1>(slot, n->layout.width);
540
550
 
541
551
  int newY = slot.layout.y;
542
- if (slot.style.pos_offsets[0] != kUnset || slot.style.pos_offset_percent[0] != kUnset)
543
- newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset(slot, 0, n->layout.height);
544
- else if (slot.style.pos_offsets[2] != kUnset || slot.style.pos_offset_percent[2] != kUnset)
552
+ if (GEA_CSS_POSITION_PX_0(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_0(slot.style) != kUnset)
553
+ newY = n->layout.y - n->layout.scroll_y + resolvedSlotOffset<0>(slot, n->layout.height);
554
+ else if (GEA_CSS_POSITION_PX_2(slot.style) != kUnset || GEA_CSS_POSITION_PERCENT_2(slot.style) != kUnset)
545
555
  newY = n->layout.y - n->layout.scroll_y + n->layout.height - slot.layout.height -
546
- resolvedSlotOffset(slot, 2, n->layout.height);
556
+ resolvedSlotOffset<2>(slot, n->layout.height);
547
557
 
548
558
  const int dx = newX - slot.layout.x;
549
559
  const int dy = newY - slot.layout.y;
@@ -853,7 +863,19 @@ void rootScrollImageHoldTick()
853
863
  if (state.mountedRoot < 0) return;
854
864
  Tree::instance().markDisplayListDirty();
855
865
  state.nodes[state.mountedRoot].render.dirty = 1;
866
+ #if GEA_CSS_SCROLLING
856
867
  state.nodes[state.mountedRoot].render.non_scroll_dirty = 1;
868
+ #endif
869
+ }
870
+
871
+ #else
872
+ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
873
+ {
874
+ (void)root; (void)width; (void)height;
875
+ return 0;
857
876
  }
858
877
 
878
+ void rootScrollImageHoldTick() {}
879
+ #endif
880
+
859
881
  } // namespace gea::embedded::ui