@geastack/engine 0.1.6 → 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.
- package/README.md +70 -0
- package/canvas.cpp +52 -30
- package/css/declarative.h +6 -0
- package/css/engine.h +19 -0
- package/image_store.cpp +136 -33
- package/package.json +2 -2
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +15 -13
- package/ui/core.cpp +23 -0
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +282 -0
- package/ui/image_node.cpp +9 -8
- package/ui/input.cpp +22 -2
- package/ui/input_render.cpp +4 -0
- package/ui/layout.cpp +171 -83
- package/ui/layout_snapshot.cpp +28 -1
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +192 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +631 -71
- package/ui/node_text.h +82 -0
- package/ui/render.cpp +155 -87
- package/ui/renderer_features.h +19 -0
- package/ui/root_scroll_refresh.cpp +31 -14
- package/ui/style.cpp +991 -228
- package/ui/text.cpp +24 -4
- package/ui/tree_events.cpp +135 -95
- package/ui/tree_events.h +28 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +32 -4
- package/ui/tree_render.cpp +48 -19
- package/ui/tree_scroll_mirror.cpp +26 -0
- package/ui/tree_state.cpp +261 -114
- package/ui/tree_state.h +69 -18
- package/ui/tree_style.cpp +339 -72
- package/ui/view.cpp +122 -62
- package/ui/virtual_keyboard.cpp +10 -3
package/ui/view.cpp
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#include "internal.h"
|
|
3
3
|
#include "state_init.h"
|
|
4
|
+
#include "renderer_features.h"
|
|
4
5
|
#include "style_values.h"
|
|
5
6
|
#include "tree_state.h"
|
|
6
7
|
#include <pixel.h>
|
|
@@ -299,10 +300,10 @@ DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int
|
|
|
299
300
|
cmd->gradient.y = y;
|
|
300
301
|
cmd->gradient.w = w;
|
|
301
302
|
cmd->gradient.h = h;
|
|
302
|
-
cmd->gradient.tl = node.style.border_radius[0];
|
|
303
|
-
cmd->gradient.tr = node.style.border_radius[1];
|
|
304
|
-
cmd->gradient.br = node.style.border_radius[2];
|
|
305
|
-
cmd->gradient.bl = node.style.border_radius[3];
|
|
303
|
+
cmd->gradient.tl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
304
|
+
cmd->gradient.tr = node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
305
|
+
cmd->gradient.br = node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
306
|
+
cmd->gradient.bl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
306
307
|
cmd->gradient.fromColor = fromColor;
|
|
307
308
|
cmd->gradient.midColor = midColor;
|
|
308
309
|
cmd->gradient.toColor = toColor;
|
|
@@ -348,10 +349,10 @@ DisplayCommand *appendRadialGradientRectRaw(const Node &node, int x, int y, int
|
|
|
348
349
|
cmd->radialGradient.y = y;
|
|
349
350
|
cmd->radialGradient.w = w;
|
|
350
351
|
cmd->radialGradient.h = h;
|
|
351
|
-
cmd->radialGradient.tl = node.style.border_radius[0];
|
|
352
|
-
cmd->radialGradient.tr = node.style.border_radius[1];
|
|
353
|
-
cmd->radialGradient.br = node.style.border_radius[2];
|
|
354
|
-
cmd->radialGradient.bl = node.style.border_radius[3];
|
|
352
|
+
cmd->radialGradient.tl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
353
|
+
cmd->radialGradient.tr = node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
354
|
+
cmd->radialGradient.br = node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
355
|
+
cmd->radialGradient.bl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
355
356
|
cmd->radialGradient.cxPermille = rstyle(node.style).bg_radial_gradient_cx;
|
|
356
357
|
cmd->radialGradient.cyPermille = rstyle(node.style).bg_radial_gradient_cy;
|
|
357
358
|
cmd->radialGradient.rxPermille = rstyle(node.style).bg_radial_gradient_rx;
|
|
@@ -437,20 +438,20 @@ bool gradientAlphaNearlyConstant(const Node &node)
|
|
|
437
438
|
|
|
438
439
|
bool hasAnyRadius(const Node &node)
|
|
439
440
|
{
|
|
440
|
-
return node.style.border_radius[0] || node.style.border_radius[1] ||
|
|
441
|
-
node.style.border_radius[2] || node.style.border_radius[3] ||
|
|
442
|
-
node.style.border_radius_percent[0] != kUnset ||
|
|
443
|
-
node.style.border_radius_percent[1] != kUnset ||
|
|
444
|
-
node.style.border_radius_percent[2] != kUnset ||
|
|
445
|
-
node.style.border_radius_percent[3] != kUnset;
|
|
441
|
+
return node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)] || node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)] ||
|
|
442
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)] || node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)] ||
|
|
443
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] != kUnset ||
|
|
444
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] != kUnset ||
|
|
445
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] != kUnset ||
|
|
446
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] != kUnset;
|
|
446
447
|
}
|
|
447
448
|
|
|
448
449
|
bool hasAnyPercentRadius(const Node &node)
|
|
449
450
|
{
|
|
450
|
-
return node.style.border_radius_percent[0] != kUnset ||
|
|
451
|
-
node.style.border_radius_percent[1] != kUnset ||
|
|
452
|
-
node.style.border_radius_percent[2] != kUnset ||
|
|
453
|
-
node.style.border_radius_percent[3] != kUnset;
|
|
451
|
+
return node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(0)] != kUnset ||
|
|
452
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(1)] != kUnset ||
|
|
453
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(2)] != kUnset ||
|
|
454
|
+
node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(3)] != kUnset;
|
|
454
455
|
}
|
|
455
456
|
|
|
456
457
|
int integerSqrt(int n)
|
|
@@ -474,10 +475,10 @@ int normalizedRadius(int radius, int maxRadius)
|
|
|
474
475
|
void roundedNodeRowSpan(const Node &node, int y, int *x0, int *x1)
|
|
475
476
|
{
|
|
476
477
|
const int maxRadius = std::min(node.layout.width / 2, node.layout.height / 2);
|
|
477
|
-
const int tl = normalizedRadius(node.style.border_radius[0], maxRadius);
|
|
478
|
-
const int tr = normalizedRadius(node.style.border_radius[1], maxRadius);
|
|
479
|
-
const int br = normalizedRadius(node.style.border_radius[2], maxRadius);
|
|
480
|
-
const int bl = normalizedRadius(node.style.border_radius[3], maxRadius);
|
|
478
|
+
const int tl = normalizedRadius(node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)], maxRadius);
|
|
479
|
+
const int tr = normalizedRadius(node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)], maxRadius);
|
|
480
|
+
const int br = normalizedRadius(node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)], maxRadius);
|
|
481
|
+
const int bl = normalizedRadius(node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)], maxRadius);
|
|
481
482
|
if ((tl | tr | br | bl) == 0) return;
|
|
482
483
|
|
|
483
484
|
const int left = node.layout.x;
|
|
@@ -519,10 +520,10 @@ bool isFullyRoundedShape(const Node &node)
|
|
|
519
520
|
const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
|
|
520
521
|
if (halfMin <= 0) return false;
|
|
521
522
|
const int minRadius = std::max(1, halfMin - 1);
|
|
522
|
-
return node.style.border_radius[0] >= minRadius &&
|
|
523
|
-
node.style.border_radius[1] >= minRadius &&
|
|
524
|
-
node.style.border_radius[2] >= minRadius &&
|
|
525
|
-
node.style.border_radius[3] >= minRadius;
|
|
523
|
+
return node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)] >= minRadius &&
|
|
524
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)] >= minRadius &&
|
|
525
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)] >= minRadius &&
|
|
526
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)] >= minRadius;
|
|
526
527
|
}
|
|
527
528
|
|
|
528
529
|
void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
|
|
@@ -532,12 +533,15 @@ void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
|
|
|
532
533
|
double rx[4]{};
|
|
533
534
|
double ry[4]{};
|
|
534
535
|
for (int i = 0; i < 4; i++) {
|
|
535
|
-
|
|
536
|
-
|
|
536
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
537
|
+
if (node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)] != kUnset) {
|
|
538
|
+
const double p = static_cast<double>(node.style.border_radius_percent[GEA_CSS_RADIUS_INDEX(i)]) / 1000.0;
|
|
537
539
|
rx[i] = std::max(0.0, width * p);
|
|
538
540
|
ry[i] = std::max(0.0, height * p);
|
|
539
|
-
} else
|
|
540
|
-
|
|
541
|
+
} else
|
|
542
|
+
#endif
|
|
543
|
+
{
|
|
544
|
+
const double r = static_cast<double>(std::max(0, static_cast<int>(node.style.border_radius[GEA_CSS_RADIUS_INDEX(i)])));
|
|
541
545
|
rx[i] = r;
|
|
542
546
|
ry[i] = r;
|
|
543
547
|
}
|
|
@@ -579,10 +583,10 @@ void appendFillRoundedRectWithAlpha(const Node &node, uint8_t parentAlpha, const
|
|
|
579
583
|
appendAlphaCommand(effectiveAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
|
|
580
584
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
581
585
|
if (cmd) {
|
|
582
|
-
const int tl = resolvedRadii ? resolvedRadii[0] : node.style.border_radius[0];
|
|
583
|
-
const int tr = resolvedRadii ? resolvedRadii[1] : node.style.border_radius[1];
|
|
584
|
-
const int br = resolvedRadii ? resolvedRadii[2] : node.style.border_radius[2];
|
|
585
|
-
const int bl = resolvedRadii ? resolvedRadii[3] : node.style.border_radius[3];
|
|
586
|
+
const int tl = resolvedRadii ? resolvedRadii[0] : node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
587
|
+
const int tr = resolvedRadii ? resolvedRadii[1] : node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
588
|
+
const int br = resolvedRadii ? resolvedRadii[2] : node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
589
|
+
const int bl = resolvedRadii ? resolvedRadii[3] : node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
586
590
|
cmd->type = DisplayCommandType::FillRoundedRect;
|
|
587
591
|
cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
|
|
588
592
|
cmd->fillRoundedRect.x = node.layout.x; cmd->fillRoundedRect.y = node.layout.y;
|
|
@@ -690,10 +694,10 @@ void appendStrokeWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
690
694
|
cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
|
|
691
695
|
cmd->strokeRoundedRect.x = node.layout.x; cmd->strokeRoundedRect.y = node.layout.y;
|
|
692
696
|
cmd->strokeRoundedRect.w = node.layout.width; cmd->strokeRoundedRect.h = node.layout.height;
|
|
693
|
-
cmd->strokeRoundedRect.tl = node.style.border_radius[0];
|
|
694
|
-
cmd->strokeRoundedRect.tr = node.style.border_radius[1];
|
|
695
|
-
cmd->strokeRoundedRect.br = node.style.border_radius[2];
|
|
696
|
-
cmd->strokeRoundedRect.bl = node.style.border_radius[3];
|
|
697
|
+
cmd->strokeRoundedRect.tl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)];
|
|
698
|
+
cmd->strokeRoundedRect.tr = node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)];
|
|
699
|
+
cmd->strokeRoundedRect.br = node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)];
|
|
700
|
+
cmd->strokeRoundedRect.bl = node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)];
|
|
697
701
|
cmd->strokeRoundedRect.lineWidth = node.style.border_width;
|
|
698
702
|
resolvedBorderRadii8(node, cmd->strokeRoundedRect.rx8, cmd->strokeRoundedRect.ry8);
|
|
699
703
|
cmd->strokeRoundedRect.cssRadii = hasAnyPercentRadius(node);
|
|
@@ -760,6 +764,7 @@ public:
|
|
|
760
764
|
|
|
761
765
|
static bool nodeHasLocalTransform(const Node &node, bool usePrevious)
|
|
762
766
|
{
|
|
767
|
+
if (!GEA_CSS_TRANSFORMS) return false;
|
|
763
768
|
if (usePrevious ? !node.render.previous_transformable_box : !hasTransformableBox(node)) return false;
|
|
764
769
|
const RareStyle &rs = rstyle(node.style); // one pool lookup, not 10
|
|
765
770
|
const int rotate = usePrevious ? node.render.previous_transform_rotate : rs.transform_rotate;
|
|
@@ -796,6 +801,7 @@ public:
|
|
|
796
801
|
// record path is bypassed at O(1).
|
|
797
802
|
static bool GEA_VIEW_HOT_SRAM_SECTION("any_transform_present") anyTransformPresent()
|
|
798
803
|
{
|
|
804
|
+
#if GEA_CSS_TRANSFORMS
|
|
799
805
|
auto &state = treeState();
|
|
800
806
|
if (state.transformScanSerial == state.refreshSerial) return state.transformPresent;
|
|
801
807
|
// Durable no-transform cache: a transform-free tree stays transform-free until a
|
|
@@ -819,6 +825,9 @@ public:
|
|
|
819
825
|
state.transformScanSerial = state.refreshSerial;
|
|
820
826
|
state.transformScanValid = true;
|
|
821
827
|
return present;
|
|
828
|
+
#else
|
|
829
|
+
return false;
|
|
830
|
+
#endif
|
|
822
831
|
}
|
|
823
832
|
|
|
824
833
|
static bool GEA_VIEW_HOT_SRAM_SECTION("has_transform_chain") hasTransformChain(const Node &node, bool usePrevious)
|
|
@@ -881,6 +890,7 @@ public:
|
|
|
881
890
|
float previousMatrix[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
|
882
891
|
};
|
|
883
892
|
|
|
893
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
884
894
|
struct AverageDepthCacheEntry {
|
|
885
895
|
int nodeId = -1;
|
|
886
896
|
int depth = 0;
|
|
@@ -946,6 +956,7 @@ public:
|
|
|
946
956
|
for (int i = 0; i < count; i++) entries[i].nodeId = -1;
|
|
947
957
|
}
|
|
948
958
|
|
|
959
|
+
#endif
|
|
949
960
|
static Point3 applyLinear(const float *m, Point3 p)
|
|
950
961
|
{
|
|
951
962
|
return {m[0] * p.x + m[1] * p.y + m[2] * p.z,
|
|
@@ -1048,6 +1059,7 @@ public:
|
|
|
1048
1059
|
|
|
1049
1060
|
static NodeTransformCache *cachedNodeTransform(const Node &node)
|
|
1050
1061
|
{
|
|
1062
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1051
1063
|
static ActiveTransformCache cache;
|
|
1052
1064
|
const int id = nodeIndex(node);
|
|
1053
1065
|
if (id < 0) return nullptr;
|
|
@@ -1085,6 +1097,10 @@ public:
|
|
|
1085
1097
|
if (e.nodeId != -1) return nullptr;
|
|
1086
1098
|
fillNodeTransform(e, node, id);
|
|
1087
1099
|
return &e;
|
|
1100
|
+
#else
|
|
1101
|
+
(void)node;
|
|
1102
|
+
return nullptr;
|
|
1103
|
+
#endif
|
|
1088
1104
|
}
|
|
1089
1105
|
|
|
1090
1106
|
// Current-frame transform coefficients for a node, computed once per refresh
|
|
@@ -1099,6 +1115,7 @@ public:
|
|
|
1099
1115
|
// is fixed within a refresh, and the serial bumps when the tree re-records (the
|
|
1100
1116
|
// animating cube each frame). Only the current frame is cached; the colder
|
|
1101
1117
|
// previous-frame (dirty-bounds) path computes directly.
|
|
1118
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1102
1119
|
static const NodeTransformCache &nodeTransform(const Node &node)
|
|
1103
1120
|
{
|
|
1104
1121
|
if (NodeTransformCache *e = cachedNodeTransform(node)) return *e;
|
|
@@ -1107,6 +1124,15 @@ public:
|
|
|
1107
1124
|
return fallback;
|
|
1108
1125
|
}
|
|
1109
1126
|
|
|
1127
|
+
#else
|
|
1128
|
+
static NodeTransformCache nodeTransform(const Node &node)
|
|
1129
|
+
{
|
|
1130
|
+
NodeTransformCache value;
|
|
1131
|
+
fillNodeTransform(value, node, nodeIndex(node));
|
|
1132
|
+
return value;
|
|
1133
|
+
}
|
|
1134
|
+
#endif
|
|
1135
|
+
|
|
1110
1136
|
// Pure hardware-FPU application of precomputed transform coefficients to a
|
|
1111
1137
|
// point — no cache lookup, no divides, no trig. transformRectCorners hoists
|
|
1112
1138
|
// the per-node cache lookup out of its 4-corner loop and calls this directly.
|
|
@@ -1120,6 +1146,7 @@ public:
|
|
|
1120
1146
|
// Facing of a plane within its own CSS 3D rendering context.
|
|
1121
1147
|
static bool backFacing(const Node &node)
|
|
1122
1148
|
{
|
|
1149
|
+
#if GEA_CSS_TRANSFORMS
|
|
1123
1150
|
auto &state = treeState();
|
|
1124
1151
|
Point3 normal{0, 0, 1};
|
|
1125
1152
|
float offset = 0;
|
|
@@ -1148,6 +1175,10 @@ public:
|
|
|
1148
1175
|
if (!hasTransformableBox(parent) || !preserves3D(parent.style)) break;
|
|
1149
1176
|
}
|
|
1150
1177
|
return normal.z < -0.00001f;
|
|
1178
|
+
#else
|
|
1179
|
+
(void)node;
|
|
1180
|
+
return false;
|
|
1181
|
+
#endif
|
|
1151
1182
|
}
|
|
1152
1183
|
|
|
1153
1184
|
// Previous-frame analogue of applyCachedTransform — pure-FPU application of the
|
|
@@ -1396,6 +1427,7 @@ public:
|
|
|
1396
1427
|
// path isn't cached (cold, used only for dirty bounds).
|
|
1397
1428
|
static int GEA_VIEW_HOT_SRAM_SECTION("average_depth") averageDepth(const Node &node, bool usePrevious)
|
|
1398
1429
|
{
|
|
1430
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1399
1431
|
if (usePrevious) return averageDepthCompute(node, true);
|
|
1400
1432
|
static ActiveDepthCache cache;
|
|
1401
1433
|
const int id = nodeIndex(node);
|
|
@@ -1414,6 +1446,9 @@ public:
|
|
|
1414
1446
|
return d;
|
|
1415
1447
|
}
|
|
1416
1448
|
return averageDepthCompute(node, false);
|
|
1449
|
+
#else
|
|
1450
|
+
return averageDepthCompute(node, usePrevious);
|
|
1451
|
+
#endif
|
|
1417
1452
|
}
|
|
1418
1453
|
|
|
1419
1454
|
// The node's four projected screen-space corners for the current frame, cached
|
|
@@ -1422,6 +1457,7 @@ public:
|
|
|
1422
1457
|
// collapses those (and the dirty pass's current-frame half) to one projection.
|
|
1423
1458
|
static void GEA_VIEW_HOT_SRAM_SECTION("transform_corners") transformCorners(const Node &node, bool usePrevious, int16_t *xs, int16_t *ys)
|
|
1424
1459
|
{
|
|
1460
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1425
1461
|
if (usePrevious) {
|
|
1426
1462
|
// Cache previous-frame corners per node per refresh, mirroring the current-frame
|
|
1427
1463
|
// path below. The dirty-bounds collect projects each node's previous corners
|
|
@@ -1480,6 +1516,13 @@ public:
|
|
|
1480
1516
|
}
|
|
1481
1517
|
transformRectCorners(node, false, node.layout.x, node.layout.y,
|
|
1482
1518
|
node.layout.width, node.layout.height, xs, ys);
|
|
1519
|
+
#else
|
|
1520
|
+
transformRectCorners(node, usePrevious,
|
|
1521
|
+
usePrevious ? node.layout.previous_x : node.layout.x,
|
|
1522
|
+
usePrevious ? node.layout.previous_y : node.layout.y,
|
|
1523
|
+
usePrevious ? node.layout.previous_width : node.layout.width,
|
|
1524
|
+
usePrevious ? node.layout.previous_height : node.layout.height, xs, ys);
|
|
1525
|
+
#endif
|
|
1483
1526
|
}
|
|
1484
1527
|
};
|
|
1485
1528
|
|
|
@@ -1541,7 +1584,7 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
1541
1584
|
|
|
1542
1585
|
const bool transformed = ViewGeometry::hasTransformChain(node, false);
|
|
1543
1586
|
for (int side = 0; side < 4; ++side) {
|
|
1544
|
-
const int borderWidth =
|
|
1587
|
+
const int borderWidth = computedBorderWidth(node.style, side);
|
|
1545
1588
|
const auto color = borderPaintColor(node.style, side);
|
|
1546
1589
|
const auto alpha = borderPaintAlpha(node.style, side);
|
|
1547
1590
|
if (borderWidth <= 0) continue;
|
|
@@ -1563,8 +1606,8 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
1563
1606
|
// Horizontal edges own the corners. Avoid compositing a translucent
|
|
1564
1607
|
// asymmetric border twice where two side rectangles would overlap.
|
|
1565
1608
|
if (side == 1 || side == 3) {
|
|
1566
|
-
const int top = std::min<int>(
|
|
1567
|
-
const int bottom = std::min<int>(
|
|
1609
|
+
const int top = std::min<int>(computedBorderWidth(node.style, 0), h);
|
|
1610
|
+
const int bottom = std::min<int>(computedBorderWidth(node.style, 2), h - top);
|
|
1568
1611
|
sy += top;
|
|
1569
1612
|
sh -= top + bottom;
|
|
1570
1613
|
}
|
|
@@ -1736,7 +1779,7 @@ bool recordPlacedBackgrounds(const Node &geometry, const Node &source, bool canv
|
|
|
1736
1779
|
TextBackgroundClipScope textClip(source, clip);
|
|
1737
1780
|
if (clip == 1 || clip == 2) {
|
|
1738
1781
|
int inset[4];
|
|
1739
|
-
for (int i = 0; i < 4; ++i) inset[i] =
|
|
1782
|
+
for (int i = 0; i < 4; ++i) inset[i] = computedBorderWidth(geometry.style, i) +
|
|
1740
1783
|
(clip == 2 ? std::max<int>(0, geometry.style.padding[i]) : 0);
|
|
1741
1784
|
x += inset[3]; y += inset[0]; w -= inset[1]+inset[3]; h -= inset[0]+inset[2];
|
|
1742
1785
|
}
|
|
@@ -1831,7 +1874,7 @@ void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha, int
|
|
|
1831
1874
|
int inset[4]{};
|
|
1832
1875
|
if (backgroundClip > 0)
|
|
1833
1876
|
for (int i = 0; i < 4; ++i)
|
|
1834
|
-
inset[i] =
|
|
1877
|
+
inset[i] = computedBorderWidth(node.style, i) +
|
|
1835
1878
|
(backgroundClip == 2 ? std::max<int>(0, node.style.padding[i]) : 0);
|
|
1836
1879
|
const int x = node.layout.x + inset[3];
|
|
1837
1880
|
const int y = node.layout.y + inset[0];
|
|
@@ -2020,6 +2063,7 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
|
|
|
2020
2063
|
if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
2021
2064
|
}
|
|
2022
2065
|
|
|
2066
|
+
#if GEA_CSS_BOX_SHADOW
|
|
2023
2067
|
uint8_t insetShadowAlphaAt(int depth, int solidDepth, int blurRadius, uint8_t baseAlpha)
|
|
2024
2068
|
{
|
|
2025
2069
|
if (baseAlpha == 0) return 0;
|
|
@@ -2044,7 +2088,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
2044
2088
|
boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
|
|
2045
2089
|
appendFillQuadWithAlpha(xs,
|
|
2046
2090
|
ys,
|
|
2047
|
-
rstyle(node.style).box_shadow_color,
|
|
2091
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0),
|
|
2048
2092
|
alpha,
|
|
2049
2093
|
parentAlpha,
|
|
2050
2094
|
bx0,
|
|
@@ -2059,7 +2103,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
2059
2103
|
return;
|
|
2060
2104
|
}
|
|
2061
2105
|
if (!hasAnyRadius(node)) {
|
|
2062
|
-
appendFillRectWithAlpha(x, y, w, h, rstyle(node.style).box_shadow_color, alpha, parentAlpha, x, y, w, h);
|
|
2106
|
+
appendFillRectWithAlpha(x, y, w, h, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0), alpha, parentAlpha, x, y, w, h);
|
|
2063
2107
|
return;
|
|
2064
2108
|
}
|
|
2065
2109
|
int runX0 = 0;
|
|
@@ -2072,7 +2116,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
2072
2116
|
runY,
|
|
2073
2117
|
runX1 - runX0 + 1,
|
|
2074
2118
|
runH,
|
|
2075
|
-
rstyle(node.style).box_shadow_color,
|
|
2119
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0),
|
|
2076
2120
|
alpha,
|
|
2077
2121
|
parentAlpha,
|
|
2078
2122
|
runX0,
|
|
@@ -2126,7 +2170,7 @@ void constrainShadowRadii(ShadowContour &shape)
|
|
|
2126
2170
|
ShadowContour insetShadowClip(const Node &node)
|
|
2127
2171
|
{
|
|
2128
2172
|
int border[4];
|
|
2129
|
-
for (int i = 0; i < 4; ++i) border[i] =
|
|
2173
|
+
for (int i = 0; i < 4; ++i) border[i] = computedBorderWidth(node.style, i);
|
|
2130
2174
|
ShadowContour shape{float(node.layout.x + border[3]), float(node.layout.y + border[0]),
|
|
2131
2175
|
float(std::max(0, node.layout.width - border[3] - border[1])),
|
|
2132
2176
|
float(std::max(0, node.layout.height - border[0] - border[2]))};
|
|
@@ -2184,8 +2228,8 @@ bool shadowContourRow(const ShadowContour &shape, int y, int &left, int &right)
|
|
|
2184
2228
|
void appendShadowRect(const Node &node, uint8_t parentAlpha, int x, int y, int w, int h)
|
|
2185
2229
|
{
|
|
2186
2230
|
if (w <= 0 || h <= 0) return;
|
|
2187
|
-
const auto color = rstyle(node.style).box_shadow_color;
|
|
2188
|
-
const auto alpha = rstyle(node.style).box_shadow_alpha;
|
|
2231
|
+
const auto color = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0);
|
|
2232
|
+
const auto alpha = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0);
|
|
2189
2233
|
if (!ViewGeometry::hasTransformChain(node, false)) {
|
|
2190
2234
|
appendFillRectWithAlpha(x, y, w, h, color, alpha, parentAlpha, x, y, w, h);
|
|
2191
2235
|
return;
|
|
@@ -2206,7 +2250,7 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
|
|
|
2206
2250
|
bool circular = true;
|
|
2207
2251
|
for (int i = 0; i < 4; ++i) circular &= clip.rx[i] == clip.ry[i] && clip.rx[i] == std::floor(clip.rx[i]) && clip.rx[i] <= std::min(clip.w, clip.h) * 0.5f;
|
|
2208
2252
|
if (ox == 0 && oy == 0 && spread > 0 && hole.w > 0 && hole.h > 0 && circular &&
|
|
2209
|
-
combineAlpha(parentAlpha, rstyle(node.style).box_shadow_alpha) == 255 &&
|
|
2253
|
+
combineAlpha(parentAlpha, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0)) == 255 &&
|
|
2210
2254
|
!ViewGeometry::hasTransformChain(node, false)) {
|
|
2211
2255
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
2212
2256
|
if (cmd) {
|
|
@@ -2221,7 +2265,7 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
|
|
|
2221
2265
|
cmd->strokeRoundedRect.br = static_cast<int16_t>(clip.rx[2]);
|
|
2222
2266
|
cmd->strokeRoundedRect.bl = static_cast<int16_t>(clip.rx[3]);
|
|
2223
2267
|
cmd->strokeRoundedRect.lineWidth = spread;
|
|
2224
|
-
cmd->strokeRoundedRect.color = rstyle(node.style).box_shadow_color;
|
|
2268
|
+
cmd->strokeRoundedRect.color = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0);
|
|
2225
2269
|
}
|
|
2226
2270
|
return;
|
|
2227
2271
|
}
|
|
@@ -2254,23 +2298,23 @@ void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowC
|
|
|
2254
2298
|
|
|
2255
2299
|
void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
|
|
2256
2300
|
{
|
|
2257
|
-
if (!rstyle(node.style).box_shadow_inset || rstyle(node.style).box_shadow_alpha == 0) return;
|
|
2301
|
+
if (!(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_inset : 0) || (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0) == 0) return;
|
|
2258
2302
|
const int x = node.layout.x;
|
|
2259
2303
|
const int y = node.layout.y;
|
|
2260
2304
|
const int w = node.layout.width;
|
|
2261
2305
|
const int h = node.layout.height;
|
|
2262
2306
|
if (w <= 0 || h <= 0) return;
|
|
2263
2307
|
|
|
2264
|
-
const int blur = std::max<int>(0, rstyle(node.style).box_shadow_blur_radius);
|
|
2308
|
+
const int blur = std::max<int>(0, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_blur_radius : 0));
|
|
2265
2309
|
if (blur == 0) {
|
|
2266
|
-
recordSharpInsetShadow(node, parentAlpha, insetShadowClip(node), rstyle(node.style).box_shadow_spread,
|
|
2267
|
-
rstyle(node.style).box_shadow_offset_x, rstyle(node.style).box_shadow_offset_y);
|
|
2310
|
+
recordSharpInsetShadow(node, parentAlpha, insetShadowClip(node), (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_spread : 0),
|
|
2311
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_offset_x : 0), (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_offset_y : 0));
|
|
2268
2312
|
return;
|
|
2269
2313
|
}
|
|
2270
|
-
const int spread = std::max<int>(0, rstyle(node.style).box_shadow_spread);
|
|
2271
|
-
const int ox = rstyle(node.style).box_shadow_offset_x;
|
|
2272
|
-
const int oy = rstyle(node.style).box_shadow_offset_y;
|
|
2273
|
-
const uint8_t baseAlpha = rstyle(node.style).box_shadow_alpha;
|
|
2314
|
+
const int spread = std::max<int>(0, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_spread : 0));
|
|
2315
|
+
const int ox = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_offset_x : 0);
|
|
2316
|
+
const int oy = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_offset_y : 0);
|
|
2317
|
+
const uint8_t baseAlpha = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0);
|
|
2274
2318
|
|
|
2275
2319
|
const int leftSolid = spread + std::max(0, ox);
|
|
2276
2320
|
const int rightSolid = spread + std::max(0, -ox);
|
|
@@ -2291,6 +2335,8 @@ void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
|
|
|
2291
2335
|
appendInsetShadowBand(node, parentAlpha, x + w - d - 1, y, 1, h, insetShadowAlphaAt(d, rightSolid, blur, baseAlpha));
|
|
2292
2336
|
}
|
|
2293
2337
|
|
|
2338
|
+
#endif
|
|
2339
|
+
|
|
2294
2340
|
void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer::transformedBounds(const Node &node, bool use_prev, int *x0, int *y0, int *x1, int *y1)
|
|
2295
2341
|
{
|
|
2296
2342
|
const Node *n = &node;
|
|
@@ -2320,7 +2366,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer:
|
|
|
2320
2366
|
int rotate = use_prev ? n->render.previous_transform_rotate : rstyle(n->style).transform_rotate;
|
|
2321
2367
|
|
|
2322
2368
|
auto expandForBlur = [&]() {
|
|
2323
|
-
const int radius = use_prev ? n->render.previous_filter_blur_radius : rstyle(n->style).filter_blur_radius;
|
|
2369
|
+
const int radius = use_prev ? n->render.previous_filter_blur_radius : (GEA_CSS_FILTERS ? rstyle(n->style).filter_blur_radius : 0);
|
|
2324
2370
|
if (radius <= 0) return;
|
|
2325
2371
|
const int extentX = std::max(1, radius) * 5;
|
|
2326
2372
|
const int extentY = std::max(1, radius) * 5;
|
|
@@ -2418,19 +2464,27 @@ bool ViewRenderer::recordClipBegin(const Node &node)
|
|
|
2418
2464
|
|
|
2419
2465
|
int ViewRenderer::scrollMaxX(const Node &node)
|
|
2420
2466
|
{
|
|
2467
|
+
#if GEA_CSS_SCROLLING
|
|
2421
2468
|
if (node.type == NodeType::VirtualList) return 0;
|
|
2422
2469
|
int max_x = node.layout.scroll_content_width - node.layout.width;
|
|
2423
2470
|
return max_x > 0 ? max_x : 0;
|
|
2471
|
+
#else
|
|
2472
|
+
(void)node; return 0;
|
|
2473
|
+
#endif
|
|
2424
2474
|
}
|
|
2425
2475
|
|
|
2426
2476
|
int ViewRenderer::scrollMaxY(const Node &node)
|
|
2427
2477
|
{
|
|
2478
|
+
#if GEA_CSS_SCROLLING
|
|
2428
2479
|
if (node.type == NodeType::VirtualList) {
|
|
2429
2480
|
const int id = static_cast<int>(&node - Tree::instance().nodes());
|
|
2430
2481
|
return VirtualListRenderer::scrollMaxY(id);
|
|
2431
2482
|
}
|
|
2432
2483
|
int max_y = node.layout.scroll_content_height - node.layout.height;
|
|
2433
2484
|
return max_y > 0 ? max_y : 0;
|
|
2485
|
+
#else
|
|
2486
|
+
(void)node; return 0;
|
|
2487
|
+
#endif
|
|
2434
2488
|
}
|
|
2435
2489
|
|
|
2436
2490
|
void ViewRenderer::recordClipEnd(const Node &node)
|
|
@@ -2454,10 +2508,10 @@ int ViewRenderer::canvasBackgroundSource()
|
|
|
2454
2508
|
const Node &html = state.nodes[root];
|
|
2455
2509
|
// CSS Backgrounds: a transparent root with no images takes the first
|
|
2456
2510
|
// direct body's background. Its used background is then transparent.
|
|
2457
|
-
if (!rstyle(html.style).containment && (!html.style.has_bg || html.style.bg_alpha == 0) && !styleHasBackgroundImage(html.style)) {
|
|
2511
|
+
if (!(GEA_CSS_CONTAINMENT ? rstyle(html.style).containment : 0) && (!html.style.has_bg || html.style.bg_alpha == 0) && !styleHasBackgroundImage(html.style)) {
|
|
2458
2512
|
for (int child = html.first_child; child >= 0; child = state.nodes[child].next_sibling)
|
|
2459
2513
|
if (std::string_view(tagFromId(state.nodes[child].tag_id)) == "body")
|
|
2460
|
-
return rstyle(state.nodes[child].style).containment ? root : child;
|
|
2514
|
+
return (GEA_CSS_CONTAINMENT ? rstyle(state.nodes[child].style).containment : 0) ? root : child;
|
|
2461
2515
|
}
|
|
2462
2516
|
return root;
|
|
2463
2517
|
}
|
|
@@ -2536,7 +2590,9 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
|
|
|
2536
2590
|
}
|
|
2537
2591
|
}
|
|
2538
2592
|
|
|
2593
|
+
#if GEA_CSS_BOX_SHADOW
|
|
2539
2594
|
recordInsetBoxShadow(*n, parentAlpha);
|
|
2595
|
+
#endif
|
|
2540
2596
|
|
|
2541
2597
|
if (n->style.border_width > 0 && !hasBorderRelief(n->style) && !hasSideBorder(n->style) && !borderColorsDiffer(n->style) && !borderIsSameOpaqueSolidBackground(*n, parentAlpha)) {
|
|
2542
2598
|
if (ViewGeometry::hasTransformChain(*n, false)) {
|
|
@@ -2550,6 +2606,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
|
|
|
2550
2606
|
|
|
2551
2607
|
void ViewRenderer::recordScrollbar(const Node &node)
|
|
2552
2608
|
{
|
|
2609
|
+
#if GEA_CSS_SCROLLING
|
|
2553
2610
|
const Node *n = &node;
|
|
2554
2611
|
if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->style))) return;
|
|
2555
2612
|
if (n->layout.height <= 0 || n->layout.scroll_content_height <= n->layout.height) return;
|
|
@@ -2588,6 +2645,9 @@ void ViewRenderer::recordScrollbar(const Node &node)
|
|
|
2588
2645
|
// constant would not fit. 0x8C8E94 is the exact RGB888 expansion of the RGB565
|
|
2589
2646
|
// 0x8C72 this used to spell, so 16-bit panels emit the identical pixel.
|
|
2590
2647
|
cmd->fillRoundedRect.color = gea::framework::graphics::pixel::nativeFromRrggbbaa(0x8C8E94FFu);
|
|
2648
|
+
#else
|
|
2649
|
+
(void)node;
|
|
2650
|
+
#endif
|
|
2591
2651
|
}
|
|
2592
2652
|
|
|
2593
2653
|
} // namespace gea::embedded::ui
|
package/ui/virtual_keyboard.cpp
CHANGED
|
@@ -36,12 +36,13 @@
|
|
|
36
36
|
// handlers fire.
|
|
37
37
|
|
|
38
38
|
#include "virtual_keyboard.h"
|
|
39
|
+
#include "node_features.h"
|
|
39
40
|
|
|
40
41
|
#ifndef GEA_EMBEDDED_ENABLE_VIRTUAL_KEYBOARD
|
|
41
42
|
#define GEA_EMBEDDED_ENABLE_VIRTUAL_KEYBOARD 1
|
|
42
43
|
#endif
|
|
43
44
|
|
|
44
|
-
#if GEA_EMBEDDED_ENABLE_VIRTUAL_KEYBOARD
|
|
45
|
+
#if GEA_EMBEDDED_ENABLE_VIRTUAL_KEYBOARD && GEA_UI_INPUT_NODES
|
|
45
46
|
|
|
46
47
|
#include "display.h"
|
|
47
48
|
#include "internal.h"
|
|
@@ -579,7 +580,9 @@ void applyKeyToActiveInput(int code)
|
|
|
579
580
|
Node &nn = tree.node(nodeId);
|
|
580
581
|
nn.render.dirty = 1;
|
|
581
582
|
nn.render.layout_dirty = 1;
|
|
583
|
+
#if GEA_CSS_SCROLLING
|
|
582
584
|
nn.render.non_scroll_dirty = 1;
|
|
585
|
+
#endif
|
|
583
586
|
};
|
|
584
587
|
|
|
585
588
|
if (code == kCodeBackspace) {
|
|
@@ -701,10 +704,14 @@ void applyAppResize()
|
|
|
701
704
|
// first setStyle lands, so none of them is read back post-mutation.
|
|
702
705
|
const int prevHeight = n.style.height;
|
|
703
706
|
const int prevFlex = n.style.flex;
|
|
707
|
+
#if GEA_CSS_OVERFLOW_AXES
|
|
704
708
|
const int prevOverflowY = n.style.overflow_y;
|
|
709
|
+
#else
|
|
710
|
+
const int prevOverflowY = n.style.overflow;
|
|
711
|
+
#endif
|
|
705
712
|
const int prevPosition = n.style.position;
|
|
706
|
-
const int prevTop = n.style
|
|
707
|
-
const int prevLeft = n.style
|
|
713
|
+
const int prevTop = GEA_CSS_POSITION_PX_0(n.style);
|
|
714
|
+
const int prevLeft = GEA_CSS_POSITION_PX_3(n.style);
|
|
708
715
|
const int viewportH = tree.mountedHeight();
|
|
709
716
|
// Available vertical space between the top of this node (set by
|
|
710
717
|
// previous siblings' heights during the most recent layout pass)
|