@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.
- package/README.md +70 -0
- package/canvas.cpp +86 -30
- package/css/animation.h +64 -0
- package/css/declarative.h +6 -0
- package/css/engine.h +25 -1
- package/image_store.cpp +136 -33
- package/package.json +2 -2
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +42 -39
- package/ui/core.cpp +32 -1
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +282 -0
- package/ui/display_invalidation.cpp +29 -0
- package/ui/flex_balance.h +73 -0
- package/ui/image_node.cpp +33 -28
- package/ui/input.cpp +88 -38
- package/ui/input_render.cpp +17 -13
- package/ui/internal.h +51 -5
- package/ui/layout.cpp +2601 -441
- package/ui/layout_snapshot.cpp +49 -6
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +204 -71
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +930 -70
- package/ui/node_text.h +82 -0
- package/ui/render.cpp +793 -352
- package/ui/renderer_features.h +19 -0
- package/ui/root_scroll_refresh.cpp +46 -24
- package/ui/style.cpp +4155 -1073
- package/ui/style.h +143 -6
- package/ui/style_values.h +16 -0
- package/ui/text.cpp +401 -106
- package/ui/tree_events.cpp +138 -95
- package/ui/tree_events.h +28 -19
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_internal.h +19 -0
- package/ui/tree_nodes.cpp +38 -4
- package/ui/tree_render.cpp +119 -40
- package/ui/tree_scroll_mirror.cpp +26 -0
- package/ui/tree_state.cpp +261 -114
- package/ui/tree_state.h +121 -16
- package/ui/tree_style.cpp +609 -82
- package/ui/view.cpp +720 -299
- package/ui/virtual_keyboard.cpp +10 -3
package/ui/view.cpp
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
#include "internal.h"
|
|
3
3
|
#include "state_init.h"
|
|
4
|
+
#include "renderer_features.h"
|
|
5
|
+
#include "style_values.h"
|
|
4
6
|
#include "tree_state.h"
|
|
5
7
|
#include <pixel.h>
|
|
6
8
|
|
|
@@ -24,6 +26,17 @@
|
|
|
24
26
|
|
|
25
27
|
namespace gea::embedded::ui {
|
|
26
28
|
|
|
29
|
+
class TextBackgroundClipScope {
|
|
30
|
+
int previous_ = -1;
|
|
31
|
+
bool active_ = false;
|
|
32
|
+
public:
|
|
33
|
+
TextBackgroundClipScope(const Node &node, int clip) : active_(clip == 3) {
|
|
34
|
+
if (active_) previous_ = DisplayList::instance().setRecordingTextClipOwner(
|
|
35
|
+
static_cast<int>(&node - Tree::instance().nodes()));
|
|
36
|
+
}
|
|
37
|
+
~TextBackgroundClipScope() { if (active_) DisplayList::instance().setRecordingTextClipOwner(previous_); }
|
|
38
|
+
};
|
|
39
|
+
|
|
27
40
|
constexpr double kPi = 3.14159265358979323846;
|
|
28
41
|
constexpr float kPiF = 3.14159265358979323846f;
|
|
29
42
|
// Reciprocal constants so the per-corner transform math uses hardware FPU
|
|
@@ -48,10 +61,11 @@ uint8_t combineAlpha(uint8_t parentAlpha, uint8_t localAlpha)
|
|
|
48
61
|
|
|
49
62
|
bool borderIsSameOpaqueSolidBackground(const Node &node, uint8_t parentAlpha)
|
|
50
63
|
{
|
|
51
|
-
return node.style.has_bg &&
|
|
52
|
-
node.style.
|
|
53
|
-
node.style
|
|
54
|
-
|
|
64
|
+
return !hasBorderRelief(node.style) && node.style.has_bg &&
|
|
65
|
+
StyleValues::backgroundClip(node.style, rstyle(node.style).bg_image_layer_count - 1) == 0 &&
|
|
66
|
+
!styleHasBackgroundImage(node.style) &&
|
|
67
|
+
node.style.bg_color == borderPaintColor(node.style, 0) &&
|
|
68
|
+
combineAlpha(parentAlpha, node.style.bg_alpha) == combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
void appendAlphaCommand(uint8_t alpha, int bx, int by, int bw, int bh)
|
|
@@ -270,13 +284,13 @@ void appendFillQuadStrokeSegmentRaw(const int16_t *xs, const int16_t *ys, uint16
|
|
|
270
284
|
|
|
271
285
|
void boundsFromCorners(const int16_t *xs, const int16_t *ys, int *x0, int *y0, int *x1, int *y1);
|
|
272
286
|
|
|
273
|
-
|
|
287
|
+
DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h,
|
|
274
288
|
uint16_t fromColor, uint16_t midColor, uint16_t toColor,
|
|
275
289
|
uint16_t midStop, uint16_t toStop, int16_t angle, uint8_t fromAlpha,
|
|
276
290
|
uint8_t midAlpha, uint8_t toAlpha, uint8_t hasMid)
|
|
277
291
|
{
|
|
278
292
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
279
|
-
if (!cmd) return;
|
|
293
|
+
if (!cmd) return nullptr;
|
|
280
294
|
cmd->type = DisplayCommandType::FillLinearGradient;
|
|
281
295
|
cmd->bx = x;
|
|
282
296
|
cmd->by = y;
|
|
@@ -286,10 +300,10 @@ void appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h,
|
|
|
286
300
|
cmd->gradient.y = y;
|
|
287
301
|
cmd->gradient.w = w;
|
|
288
302
|
cmd->gradient.h = h;
|
|
289
|
-
cmd->gradient.tl = node.style.border_radius[0];
|
|
290
|
-
cmd->gradient.tr = node.style.border_radius[1];
|
|
291
|
-
cmd->gradient.br = node.style.border_radius[2];
|
|
292
|
-
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)];
|
|
293
307
|
cmd->gradient.fromColor = fromColor;
|
|
294
308
|
cmd->gradient.midColor = midColor;
|
|
295
309
|
cmd->gradient.toColor = toColor;
|
|
@@ -300,11 +314,12 @@ void appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h,
|
|
|
300
314
|
cmd->gradient.midAlpha = midAlpha;
|
|
301
315
|
cmd->gradient.toAlpha = toAlpha;
|
|
302
316
|
cmd->gradient.hasMid = hasMid;
|
|
317
|
+
return cmd;
|
|
303
318
|
}
|
|
304
319
|
|
|
305
|
-
|
|
320
|
+
DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h)
|
|
306
321
|
{
|
|
307
|
-
appendLinearGradientRectRaw(node,
|
|
322
|
+
return appendLinearGradientRectRaw(node,
|
|
308
323
|
x,
|
|
309
324
|
y,
|
|
310
325
|
w,
|
|
@@ -321,10 +336,10 @@ void appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h)
|
|
|
321
336
|
rstyle(node.style).bg_gradient_has_mid);
|
|
322
337
|
}
|
|
323
338
|
|
|
324
|
-
|
|
339
|
+
DisplayCommand *appendRadialGradientRectRaw(const Node &node, int x, int y, int w, int h)
|
|
325
340
|
{
|
|
326
341
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
327
|
-
if (!cmd) return;
|
|
342
|
+
if (!cmd) return nullptr;
|
|
328
343
|
cmd->type = DisplayCommandType::FillRadialGradient;
|
|
329
344
|
cmd->bx = x;
|
|
330
345
|
cmd->by = y;
|
|
@@ -334,10 +349,10 @@ void appendRadialGradientRectRaw(const Node &node, int x, int y, int w, int h)
|
|
|
334
349
|
cmd->radialGradient.y = y;
|
|
335
350
|
cmd->radialGradient.w = w;
|
|
336
351
|
cmd->radialGradient.h = h;
|
|
337
|
-
cmd->radialGradient.tl = node.style.border_radius[0];
|
|
338
|
-
cmd->radialGradient.tr = node.style.border_radius[1];
|
|
339
|
-
cmd->radialGradient.br = node.style.border_radius[2];
|
|
340
|
-
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)];
|
|
341
356
|
cmd->radialGradient.cxPermille = rstyle(node.style).bg_radial_gradient_cx;
|
|
342
357
|
cmd->radialGradient.cyPermille = rstyle(node.style).bg_radial_gradient_cy;
|
|
343
358
|
cmd->radialGradient.rxPermille = rstyle(node.style).bg_radial_gradient_rx;
|
|
@@ -347,6 +362,7 @@ void appendRadialGradientRectRaw(const Node &node, int x, int y, int w, int h)
|
|
|
347
362
|
cmd->radialGradient.stopPermille = rstyle(node.style).bg_radial_gradient_stop;
|
|
348
363
|
cmd->radialGradient.fromAlpha = rstyle(node.style).bg_radial_gradient_from_alpha;
|
|
349
364
|
cmd->radialGradient.toAlpha = rstyle(node.style).bg_radial_gradient_to_alpha;
|
|
365
|
+
return cmd;
|
|
350
366
|
}
|
|
351
367
|
|
|
352
368
|
void appendDrawLineRaw(int x0, int y0, int x1, int y1, uint16_t color)
|
|
@@ -422,20 +438,20 @@ bool gradientAlphaNearlyConstant(const Node &node)
|
|
|
422
438
|
|
|
423
439
|
bool hasAnyRadius(const Node &node)
|
|
424
440
|
{
|
|
425
|
-
return node.style.border_radius[0] || node.style.border_radius[1] ||
|
|
426
|
-
node.style.border_radius[2] || node.style.border_radius[3] ||
|
|
427
|
-
node.style.border_radius_percent[0] != kUnset ||
|
|
428
|
-
node.style.border_radius_percent[1] != kUnset ||
|
|
429
|
-
node.style.border_radius_percent[2] != kUnset ||
|
|
430
|
-
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;
|
|
431
447
|
}
|
|
432
448
|
|
|
433
449
|
bool hasAnyPercentRadius(const Node &node)
|
|
434
450
|
{
|
|
435
|
-
return node.style.border_radius_percent[0] != kUnset ||
|
|
436
|
-
node.style.border_radius_percent[1] != kUnset ||
|
|
437
|
-
node.style.border_radius_percent[2] != kUnset ||
|
|
438
|
-
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;
|
|
439
455
|
}
|
|
440
456
|
|
|
441
457
|
int integerSqrt(int n)
|
|
@@ -459,10 +475,10 @@ int normalizedRadius(int radius, int maxRadius)
|
|
|
459
475
|
void roundedNodeRowSpan(const Node &node, int y, int *x0, int *x1)
|
|
460
476
|
{
|
|
461
477
|
const int maxRadius = std::min(node.layout.width / 2, node.layout.height / 2);
|
|
462
|
-
const int tl = normalizedRadius(node.style.border_radius[0], maxRadius);
|
|
463
|
-
const int tr = normalizedRadius(node.style.border_radius[1], maxRadius);
|
|
464
|
-
const int br = normalizedRadius(node.style.border_radius[2], maxRadius);
|
|
465
|
-
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);
|
|
466
482
|
if ((tl | tr | br | bl) == 0) return;
|
|
467
483
|
|
|
468
484
|
const int left = node.layout.x;
|
|
@@ -504,10 +520,10 @@ bool isFullyRoundedShape(const Node &node)
|
|
|
504
520
|
const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
|
|
505
521
|
if (halfMin <= 0) return false;
|
|
506
522
|
const int minRadius = std::max(1, halfMin - 1);
|
|
507
|
-
return node.style.border_radius[0] >= minRadius &&
|
|
508
|
-
node.style.border_radius[1] >= minRadius &&
|
|
509
|
-
node.style.border_radius[2] >= minRadius &&
|
|
510
|
-
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;
|
|
511
527
|
}
|
|
512
528
|
|
|
513
529
|
void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
|
|
@@ -517,12 +533,15 @@ void resolvedBorderRadii8(const Node &node, int16_t rx8[4], int16_t ry8[4])
|
|
|
517
533
|
double rx[4]{};
|
|
518
534
|
double ry[4]{};
|
|
519
535
|
for (int i = 0; i < 4; i++) {
|
|
520
|
-
|
|
521
|
-
|
|
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;
|
|
522
539
|
rx[i] = std::max(0.0, width * p);
|
|
523
540
|
ry[i] = std::max(0.0, height * p);
|
|
524
|
-
} else
|
|
525
|
-
|
|
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)])));
|
|
526
545
|
rx[i] = r;
|
|
527
546
|
ry[i] = r;
|
|
528
547
|
}
|
|
@@ -551,6 +570,7 @@ bool resolvedCircularBorderRadii(const Node &node, int radii[4])
|
|
|
551
570
|
for (int i = 0; i < 4; i++) {
|
|
552
571
|
if (std::abs(static_cast<int>(rx8[i]) - static_cast<int>(ry8[i])) > 4) return false;
|
|
553
572
|
const int radius8 = (static_cast<int>(rx8[i]) + static_cast<int>(ry8[i])) / 2;
|
|
573
|
+
if (radius8 > std::min(node.layout.width, node.layout.height) * 4) return false;
|
|
554
574
|
radii[i] = std::max(0, std::min(32767, (radius8 + 4) / 8));
|
|
555
575
|
}
|
|
556
576
|
return true;
|
|
@@ -563,10 +583,10 @@ void appendFillRoundedRectWithAlpha(const Node &node, uint8_t parentAlpha, const
|
|
|
563
583
|
appendAlphaCommand(effectiveAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
|
|
564
584
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
565
585
|
if (cmd) {
|
|
566
|
-
const int tl = resolvedRadii ? resolvedRadii[0] : node.style.border_radius[0];
|
|
567
|
-
const int tr = resolvedRadii ? resolvedRadii[1] : node.style.border_radius[1];
|
|
568
|
-
const int br = resolvedRadii ? resolvedRadii[2] : node.style.border_radius[2];
|
|
569
|
-
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)];
|
|
570
590
|
cmd->type = DisplayCommandType::FillRoundedRect;
|
|
571
591
|
cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
|
|
572
592
|
cmd->fillRoundedRect.x = node.layout.x; cmd->fillRoundedRect.y = node.layout.y;
|
|
@@ -659,7 +679,7 @@ void appendFillCircleWithAlpha(int cx, int cy, int r, gea::framework::graphics::
|
|
|
659
679
|
|
|
660
680
|
void appendStrokeWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
661
681
|
{
|
|
662
|
-
const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.style
|
|
682
|
+
const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
|
|
663
683
|
if (effectiveAlpha != parentAlpha)
|
|
664
684
|
appendAlphaCommand(effectiveAlpha, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
|
|
665
685
|
|
|
@@ -670,21 +690,28 @@ void appendStrokeWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
670
690
|
// with zero radii instead of silently collapsing border-width to 1px.
|
|
671
691
|
if (hasAnyRadius(node) || node.style.border_width > 1) {
|
|
672
692
|
cmd->type = DisplayCommandType::StrokeRoundedRect;
|
|
693
|
+
cmd->strokeRoundedRect = {};
|
|
673
694
|
cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
|
|
674
695
|
cmd->strokeRoundedRect.x = node.layout.x; cmd->strokeRoundedRect.y = node.layout.y;
|
|
675
696
|
cmd->strokeRoundedRect.w = node.layout.width; cmd->strokeRoundedRect.h = node.layout.height;
|
|
676
|
-
cmd->strokeRoundedRect.tl = node.style.border_radius[0];
|
|
677
|
-
cmd->strokeRoundedRect.tr = node.style.border_radius[1];
|
|
678
|
-
cmd->strokeRoundedRect.br = node.style.border_radius[2];
|
|
679
|
-
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)];
|
|
680
701
|
cmd->strokeRoundedRect.lineWidth = node.style.border_width;
|
|
681
|
-
cmd->strokeRoundedRect.
|
|
702
|
+
resolvedBorderRadii8(node, cmd->strokeRoundedRect.rx8, cmd->strokeRoundedRect.ry8);
|
|
703
|
+
cmd->strokeRoundedRect.cssRadii = hasAnyPercentRadius(node);
|
|
704
|
+
for (int i = 0; i < 4; ++i)
|
|
705
|
+
if (cmd->strokeRoundedRect.rx8[i] > std::min(node.layout.width, node.layout.height) * 4 ||
|
|
706
|
+
cmd->strokeRoundedRect.ry8[i] > std::min(node.layout.width, node.layout.height) * 4)
|
|
707
|
+
cmd->strokeRoundedRect.cssRadii = 1;
|
|
708
|
+
cmd->strokeRoundedRect.color = borderPaintColor(node.style, 0);
|
|
682
709
|
} else {
|
|
683
710
|
cmd->type = DisplayCommandType::StrokeRect;
|
|
684
711
|
cmd->bx = node.layout.x; cmd->by = node.layout.y; cmd->bw = node.layout.width; cmd->bh = node.layout.height;
|
|
685
712
|
cmd->stroke.x = node.layout.x; cmd->stroke.y = node.layout.y;
|
|
686
713
|
cmd->stroke.w = node.layout.width; cmd->stroke.h = node.layout.height;
|
|
687
|
-
cmd->stroke.color = node.style
|
|
714
|
+
cmd->stroke.color = borderPaintColor(node.style, 0);
|
|
688
715
|
}
|
|
689
716
|
}
|
|
690
717
|
|
|
@@ -723,20 +750,36 @@ public:
|
|
|
723
750
|
return index >= 0 && index < Tree::instance().nodeCount() ? static_cast<int>(index) : -1;
|
|
724
751
|
}
|
|
725
752
|
|
|
753
|
+
// CSS Transforms applies to transformable boxes, which excludes non-replaced
|
|
754
|
+
// inline-level boxes. The layout classifier also includes inline replaced
|
|
755
|
+
// elements such as images, so retain those while excluding ordinary inline
|
|
756
|
+
// wrappers and text nodes.
|
|
757
|
+
static bool hasTransformableBox(const Node &node)
|
|
758
|
+
{
|
|
759
|
+
if (node.style.display == kDisplayNone) return false;
|
|
760
|
+
if (node.type == NodeType::Text) return false;
|
|
761
|
+
if (node.type == NodeType::Image) return true;
|
|
762
|
+
return !LayoutEngine::isCssInlineLevelBox(node);
|
|
763
|
+
}
|
|
764
|
+
|
|
726
765
|
static bool nodeHasLocalTransform(const Node &node, bool usePrevious)
|
|
727
766
|
{
|
|
767
|
+
if (!GEA_CSS_TRANSFORMS) return false;
|
|
768
|
+
if (usePrevious ? !node.render.previous_transformable_box : !hasTransformableBox(node)) return false;
|
|
728
769
|
const RareStyle &rs = rstyle(node.style); // one pool lookup, not 10
|
|
729
770
|
const int rotate = usePrevious ? node.render.previous_transform_rotate : rs.transform_rotate;
|
|
730
771
|
const int rotateX = usePrevious ? node.render.previous_transform_rotate_x : rs.transform_rotate_x;
|
|
731
772
|
const int rotateY = usePrevious ? node.render.previous_transform_rotate_y : rs.transform_rotate_y;
|
|
732
|
-
const int tx = usePrevious ? node.render.previous_transform_translate_x : rs
|
|
733
|
-
const int ty = usePrevious ? node.render.previous_transform_translate_y : rs
|
|
734
|
-
const int tz = usePrevious ? node.render.previous_transform_translate_z : rs
|
|
735
|
-
const int txPercent = usePrevious ? node.render.previous_transform_translate_x_percent : rs
|
|
736
|
-
const int tyPercent = usePrevious ? node.render.previous_transform_translate_y_percent : rs
|
|
773
|
+
const int tx = usePrevious ? node.render.previous_transform_translate_x : composedTranslateX(rs);
|
|
774
|
+
const int ty = usePrevious ? node.render.previous_transform_translate_y : composedTranslateY(rs);
|
|
775
|
+
const int tz = usePrevious ? node.render.previous_transform_translate_z : composedTranslateZ(rs);
|
|
776
|
+
const int txPercent = usePrevious ? node.render.previous_transform_translate_x_percent : composedTranslateXPercent(rs);
|
|
777
|
+
const int tyPercent = usePrevious ? node.render.previous_transform_translate_y_percent : composedTranslateYPercent(rs);
|
|
737
778
|
const int sx = usePrevious ? node.render.previous_transform_scale_x : rs.transform_scale_x;
|
|
738
779
|
const int sy = usePrevious ? node.render.previous_transform_scale_y : rs.transform_scale_y;
|
|
739
|
-
|
|
780
|
+
const int sz = usePrevious ? node.render.previous_transform_scale_z : rs.transform_scale_z;
|
|
781
|
+
return (usePrevious ? hadIndividualLinearTransform(node.render) : hasIndividualLinearTransform(rs)) ||
|
|
782
|
+
(rotate % 3600) != 0 ||
|
|
740
783
|
(rotateX % 3600) != 0 ||
|
|
741
784
|
(rotateY % 3600) != 0 ||
|
|
742
785
|
tx != 0 ||
|
|
@@ -745,7 +788,8 @@ public:
|
|
|
745
788
|
txPercent != 0 ||
|
|
746
789
|
tyPercent != 0 ||
|
|
747
790
|
sx != 1000 ||
|
|
748
|
-
sy != 1000
|
|
791
|
+
sy != 1000 ||
|
|
792
|
+
sz != 1000;
|
|
749
793
|
}
|
|
750
794
|
|
|
751
795
|
// True iff any node carries a non-identity transform/perspective this frame
|
|
@@ -757,6 +801,7 @@ public:
|
|
|
757
801
|
// record path is bypassed at O(1).
|
|
758
802
|
static bool GEA_VIEW_HOT_SRAM_SECTION("any_transform_present") anyTransformPresent()
|
|
759
803
|
{
|
|
804
|
+
#if GEA_CSS_TRANSFORMS
|
|
760
805
|
auto &state = treeState();
|
|
761
806
|
if (state.transformScanSerial == state.refreshSerial) return state.transformPresent;
|
|
762
807
|
// Durable no-transform cache: a transform-free tree stays transform-free until a
|
|
@@ -770,7 +815,8 @@ public:
|
|
|
770
815
|
for (int i = 0; i < state.nodeCount; i++) {
|
|
771
816
|
const Node &n = state.nodes[i];
|
|
772
817
|
if (nodeHasLocalTransform(n, false) || nodeHasLocalTransform(n, true) ||
|
|
773
|
-
rstyle(n.style).perspective > 0 ||
|
|
818
|
+
(hasTransformableBox(n) && rstyle(n.style).perspective > 0) ||
|
|
819
|
+
(n.render.previous_transformable_box && n.render.previous_perspective > 0)) {
|
|
774
820
|
present = true;
|
|
775
821
|
break;
|
|
776
822
|
}
|
|
@@ -779,6 +825,9 @@ public:
|
|
|
779
825
|
state.transformScanSerial = state.refreshSerial;
|
|
780
826
|
state.transformScanValid = true;
|
|
781
827
|
return present;
|
|
828
|
+
#else
|
|
829
|
+
return false;
|
|
830
|
+
#endif
|
|
782
831
|
}
|
|
783
832
|
|
|
784
833
|
static bool GEA_VIEW_HOT_SRAM_SECTION("has_transform_chain") hasTransformChain(const Node &node, bool usePrevious)
|
|
@@ -787,6 +836,7 @@ public:
|
|
|
787
836
|
auto &state = treeState();
|
|
788
837
|
for (int id = nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
|
|
789
838
|
if (nodeHasLocalTransform(state.nodes[id], usePrevious)) return true;
|
|
839
|
+
if (usePrevious ? !state.nodes[id].render.previous_transformable_box : !hasTransformableBox(state.nodes[id])) continue;
|
|
790
840
|
const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].style).perspective;
|
|
791
841
|
if (perspective > 0) return true;
|
|
792
842
|
}
|
|
@@ -831,26 +881,16 @@ public:
|
|
|
831
881
|
#endif
|
|
832
882
|
int nodeId = -1;
|
|
833
883
|
int x = 0, y = 0, w = 0, h = 0;
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
float ox = 0.0f, oy = 0.0f; // transform-origin in absolute coords
|
|
838
|
-
float scaleX = 1.0f, scaleY = 1.0f;
|
|
839
|
-
float transX = 0.0f, transY = 0.0f, transZ = 0.0f; // translate (incl % of size)
|
|
840
|
-
float sinZ = 0.0f, cosZ = 1.0f, sinY = 0.0f, cosY = 1.0f, sinX = 0.0f, cosX = 1.0f;
|
|
841
|
-
// Previous-frame coefficients (from render.previous_* / layout.previous_*),
|
|
842
|
-
// filled LAZILY on first dirty-bounds (previous-frame) access so the hot
|
|
843
|
-
// reproject path never pays for them. Lets the dirty-collect pass project
|
|
844
|
-
// previous-frame corners with the same pure-FPU cached apply as the current
|
|
845
|
-
// frame instead of re-walking the ancestor chain + recomputing 6 software
|
|
846
|
-
// trig per corner (the css-3d-cube dirty cost).
|
|
884
|
+
float ox = 0.0f, oy = 0.0f;
|
|
885
|
+
float transX = 0.0f, transY = 0.0f, transZ = 0.0f;
|
|
886
|
+
float matrix[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
|
847
887
|
bool prevValid = false;
|
|
848
888
|
float pOx = 0.0f, pOy = 0.0f;
|
|
849
|
-
float pScaleX = 1.0f, pScaleY = 1.0f;
|
|
850
889
|
float pTransX = 0.0f, pTransY = 0.0f, pTransZ = 0.0f;
|
|
851
|
-
float
|
|
890
|
+
float previousMatrix[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
|
852
891
|
};
|
|
853
892
|
|
|
893
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
854
894
|
struct AverageDepthCacheEntry {
|
|
855
895
|
int nodeId = -1;
|
|
856
896
|
int depth = 0;
|
|
@@ -916,121 +956,110 @@ public:
|
|
|
916
956
|
for (int i = 0; i < count; i++) entries[i].nodeId = -1;
|
|
917
957
|
}
|
|
918
958
|
|
|
959
|
+
#endif
|
|
960
|
+
static Point3 applyLinear(const float *m, Point3 p)
|
|
961
|
+
{
|
|
962
|
+
return {m[0] * p.x + m[1] * p.y + m[2] * p.z,
|
|
963
|
+
m[3] * p.x + m[4] * p.y + m[5] * p.z,
|
|
964
|
+
m[6] * p.x + m[7] * p.y + m[8] * p.z};
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
static void fillLinear(float *m, int rx, int ry, int rz, int sx, int sy, int sz = 1000)
|
|
968
|
+
{
|
|
969
|
+
const float ax = rx * kPiF * kInv1800f, ay = ry * kPiF * kInv1800f, az = rz * kPiF * kInv1800f;
|
|
970
|
+
const float sinX = sinf(ax), cosX = cosf(ax), sinY = sinf(ay), cosY = cosf(ay), sinZ = sinf(az), cosZ = cosf(az);
|
|
971
|
+
for (int column = 0; column < 3; ++column) {
|
|
972
|
+
Point3 basis{column == 0 ? sx * kInv1000f : 0.0f, column == 1 ? sy * kInv1000f : 0.0f, column == 2 ? sz * kInv1000f : 0.0f};
|
|
973
|
+
rotateZ(basis, sinZ, cosZ); rotateY(basis, sinY, cosY); rotateX(basis, sinX, cosX);
|
|
974
|
+
m[column] = basis.x; m[3 + column] = basis.y; m[6 + column] = basis.z;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
static Point3 listTranslation(Point3 shift, unsigned outerAxes, int rx, int ry, int rz)
|
|
979
|
+
{
|
|
980
|
+
Point3 inner{(outerAxes & 1) ? 0.0f : shift.x, (outerAxes & 2) ? 0.0f : shift.y, (outerAxes & 4) ? 0.0f : shift.z};
|
|
981
|
+
float rotation[9]; fillLinear(rotation, rx, ry, rz, 1000, 1000);
|
|
982
|
+
inner = applyLinear(rotation, inner);
|
|
983
|
+
return {inner.x + ((outerAxes & 1) ? shift.x : 0.0f), inner.y + ((outerAxes & 2) ? shift.y : 0.0f), inner.z + ((outerAxes & 4) ? shift.z : 0.0f)};
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// CSS order is individual translate, rotate, scale, then the transform list.
|
|
987
|
+
// Left-multiply the list's linear map and offset once when filling the cache;
|
|
988
|
+
// per-point projection then needs only one affine matrix application.
|
|
989
|
+
static void composeIndividual(float *matrix, Point3 &shift, int angle, int axisX, int axisY, int axisZ,
|
|
990
|
+
int sx, int sy, int sz, Point3 translation)
|
|
991
|
+
{
|
|
992
|
+
float x = static_cast<float>(axisX), y = static_cast<float>(axisY), z = static_cast<float>(axisZ);
|
|
993
|
+
const float length = sqrtf(x*x + y*y + z*z);
|
|
994
|
+
float r[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
|
995
|
+
if (length > 0 && angle % 3600 != 0) {
|
|
996
|
+
x /= length; y /= length; z /= length;
|
|
997
|
+
const float a = angle * kPiF * kInv1800f, c = cosf(a), sine = sinf(a), t = 1 - c;
|
|
998
|
+
r[0] = c+x*x*t; r[1] = x*y*t-z*sine; r[2] = x*z*t+y*sine;
|
|
999
|
+
r[3] = y*x*t+z*sine; r[4] = c+y*y*t; r[5] = y*z*t-x*sine;
|
|
1000
|
+
r[6] = z*x*t-y*sine; r[7] = z*y*t+x*sine; r[8] = c+z*z*t;
|
|
1001
|
+
}
|
|
1002
|
+
for (int row = 0; row < 3; ++row) { r[row*3] *= sx*kInv1000f; r[row*3+1] *= sy*kInv1000f; r[row*3+2] *= sz*kInv1000f; }
|
|
1003
|
+
for (int column = 0; column < 3; ++column) {
|
|
1004
|
+
const auto v = applyLinear(r, {matrix[column], matrix[3+column], matrix[6+column]});
|
|
1005
|
+
matrix[column] = v.x; matrix[3+column] = v.y; matrix[6+column] = v.z;
|
|
1006
|
+
}
|
|
1007
|
+
shift = applyLinear(r, shift);
|
|
1008
|
+
shift.x += translation.x; shift.y += translation.y; shift.z += translation.z;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
919
1011
|
static void fillNodeTransform(NodeTransformCache &e, const Node &node, int id)
|
|
920
1012
|
{
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
e.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
e.
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
e.
|
|
941
|
-
e.
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const float fh = static_cast<float>(node.layout.height);
|
|
945
|
-
e.ox = static_cast<float>(node.layout.x) + fw * static_cast<float>(rs.transform_origin_x) * kInv1000f;
|
|
946
|
-
e.oy = static_cast<float>(node.layout.y) + fh * static_cast<float>(rs.transform_origin_y) * kInv1000f;
|
|
947
|
-
e.scaleX = static_cast<float>(rs.transform_scale_x) * kInv1000f;
|
|
948
|
-
e.scaleY = static_cast<float>(rs.transform_scale_y) * kInv1000f;
|
|
949
|
-
e.transX = static_cast<float>(rs.transform_translate_x) +
|
|
950
|
-
fw * static_cast<float>(rs.transform_translate_x_percent) * kInv1000f;
|
|
951
|
-
e.transY = static_cast<float>(rs.transform_translate_y) +
|
|
952
|
-
fh * static_cast<float>(rs.transform_translate_y_percent) * kInv1000f;
|
|
953
|
-
e.transZ = static_cast<float>(rs.transform_translate_z);
|
|
954
|
-
const float az = static_cast<float>(rs.transform_rotate) * kPiF * kInv1800f;
|
|
955
|
-
const float ay = static_cast<float>(rs.transform_rotate_y) * kPiF * kInv1800f;
|
|
956
|
-
const float ax = static_cast<float>(rs.transform_rotate_x) * kPiF * kInv1800f;
|
|
957
|
-
e.sinZ = sinf(az); e.cosZ = cosf(az);
|
|
958
|
-
e.sinY = sinf(ay); e.cosY = cosf(ay);
|
|
959
|
-
e.sinX = sinf(ax); e.cosX = cosf(ax);
|
|
960
|
-
// Previous-frame coefficients are filled lazily (only the dirty-bounds pass
|
|
961
|
-
// needs them); mark invalid so the first prev access recomputes for this id.
|
|
962
|
-
e.prevValid = false;
|
|
963
|
-
e.nodeId = id;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
// Previous-frame analogue of fillNodeTransform: precompute one node's transform
|
|
967
|
-
// coefficients from its SNAPSHOTTED previous-frame fields (render.previous_* +
|
|
968
|
-
// layout.previous_*). Lets transformRectCorners' previous-frame path gather the
|
|
969
|
-
// chain ONCE and apply pure-FPU to all 4 corners — instead of re-walking the
|
|
970
|
-
// ancestor chain and recomputing 6 software trig PER CORNER (the css-3d-cube
|
|
971
|
-
// dirty-collect's dominant cost: ~280 applyNodeTransform calls/frame). The math
|
|
972
|
-
// mirrors applyNodeTransform's usePrevious branch exactly, so the projected
|
|
973
|
-
// corners are bit-identical — no visual change.
|
|
1013
|
+
const RareStyle &r = rstyle(node.style);
|
|
1014
|
+
e.x = node.layout.x; e.y = node.layout.y; e.w = node.layout.width; e.h = node.layout.height;
|
|
1015
|
+
e.ox = e.x + e.w * r.transform_origin_x * kInv1000f;
|
|
1016
|
+
e.oy = e.y + e.h * r.transform_origin_y * kInv1000f;
|
|
1017
|
+
if (!hasTransformableBox(node)) {
|
|
1018
|
+
std::fill(std::begin(e.matrix), std::end(e.matrix), 0.0f);
|
|
1019
|
+
e.matrix[0] = e.matrix[4] = e.matrix[8] = 1.0f;
|
|
1020
|
+
e.transX = e.transY = e.transZ = 0.0f;
|
|
1021
|
+
e.prevValid = false; e.nodeId = id;
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
fillLinear(e.matrix, r.transform_rotate_x, r.transform_rotate_y, r.transform_rotate,
|
|
1025
|
+
r.transform_scale_x, r.transform_scale_y, r.transform_scale_z);
|
|
1026
|
+
auto shift = listTranslation({r.transform_translate_x + e.w*r.transform_translate_x_percent*kInv1000f,
|
|
1027
|
+
r.transform_translate_y + e.h*r.transform_translate_y_percent*kInv1000f, static_cast<float>(r.transform_translate_z)},
|
|
1028
|
+
r.transform_translate_outer_axes, r.transform_rotate_x, r.transform_rotate_y, r.transform_rotate);
|
|
1029
|
+
composeIndividual(e.matrix, shift, r.rotate_angle, r.rotate_axis_x, r.rotate_axis_y, r.rotate_axis_z,
|
|
1030
|
+
r.scale_x, r.scale_y, r.scale_z,
|
|
1031
|
+
{r.translate_x + e.w*r.translate_x_percent*kInv1000f, r.translate_y + e.h*r.translate_y_percent*kInv1000f, static_cast<float>(r.translate_z)});
|
|
1032
|
+
e.transX = shift.x; e.transY = shift.y; e.transZ = shift.z;
|
|
1033
|
+
e.prevValid = false; e.nodeId = id;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
974
1036
|
static void fillNodeTransformPrev(NodeTransformCache &e, const Node &node)
|
|
975
1037
|
{
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
e.
|
|
996
|
-
e.pScaleX = static_cast<float>(sx) * kInv1000f;
|
|
997
|
-
e.pScaleY = static_cast<float>(sy) * kInv1000f;
|
|
998
|
-
e.pTransX = static_cast<float>(tx) + fw * static_cast<float>(txPercent) * kInv1000f;
|
|
999
|
-
e.pTransY = static_cast<float>(ty) + fh * static_cast<float>(tyPercent) * kInv1000f;
|
|
1000
|
-
e.pTransZ = static_cast<float>(tz);
|
|
1001
|
-
const float az = static_cast<float>(rotate) * kPiF * kInv1800f;
|
|
1002
|
-
const float ay = static_cast<float>(rotateYValue) * kPiF * kInv1800f;
|
|
1003
|
-
const float ax = static_cast<float>(rotateXValue) * kPiF * kInv1800f;
|
|
1004
|
-
e.pSinZ = sinf(az); e.pCosZ = cosf(az);
|
|
1005
|
-
e.pSinY = sinf(ay); e.pCosY = cosf(ay);
|
|
1006
|
-
e.pSinX = sinf(ax); e.pCosX = cosf(ax);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
[[maybe_unused]] static bool nodeTransformMatches(const NodeTransformCache &e, const Node &node, int id)
|
|
1010
|
-
{
|
|
1011
|
-
// One RareStyle pool lookup, not one per compared field (see fillNodeTransform).
|
|
1012
|
-
const RareStyle &rs = rstyle(node.style);
|
|
1013
|
-
return e.nodeId == id &&
|
|
1014
|
-
e.x == node.layout.x &&
|
|
1015
|
-
e.y == node.layout.y &&
|
|
1016
|
-
e.w == node.layout.width &&
|
|
1017
|
-
e.h == node.layout.height &&
|
|
1018
|
-
e.rotate == rs.transform_rotate &&
|
|
1019
|
-
e.rotateX == rs.transform_rotate_x &&
|
|
1020
|
-
e.rotateY == rs.transform_rotate_y &&
|
|
1021
|
-
e.tx == rs.transform_translate_x &&
|
|
1022
|
-
e.ty == rs.transform_translate_y &&
|
|
1023
|
-
e.tz == rs.transform_translate_z &&
|
|
1024
|
-
e.txPercent == rs.transform_translate_x_percent &&
|
|
1025
|
-
e.tyPercent == rs.transform_translate_y_percent &&
|
|
1026
|
-
e.sx == rs.transform_scale_x &&
|
|
1027
|
-
e.sy == rs.transform_scale_y &&
|
|
1028
|
-
e.originX == rs.transform_origin_x &&
|
|
1029
|
-
e.originY == rs.transform_origin_y;
|
|
1038
|
+
const auto &r = node.render;
|
|
1039
|
+
if (!r.previous_transformable_box) {
|
|
1040
|
+
e.pOx = e.pOy = e.pTransX = e.pTransY = e.pTransZ = 0.0f;
|
|
1041
|
+
std::fill(std::begin(e.previousMatrix), std::end(e.previousMatrix), 0.0f);
|
|
1042
|
+
e.previousMatrix[0] = e.previousMatrix[4] = e.previousMatrix[8] = 1.0f;
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
const float w = node.layout.previous_width, h = node.layout.previous_height;
|
|
1046
|
+
e.pOx = node.layout.previous_x + w*r.previous_transform_origin_x*kInv1000f;
|
|
1047
|
+
e.pOy = node.layout.previous_y + h*r.previous_transform_origin_y*kInv1000f;
|
|
1048
|
+
fillLinear(e.previousMatrix, r.previous_transform_rotate_x, r.previous_transform_rotate_y, r.previous_transform_rotate,
|
|
1049
|
+
r.previous_transform_scale_x, r.previous_transform_scale_y, r.previous_transform_scale_z);
|
|
1050
|
+
auto shift = listTranslation({r.previous_transform_translate_x - r.previous_translate_x + w*(r.previous_transform_translate_x_percent-r.previous_translate_x_percent)*kInv1000f,
|
|
1051
|
+
r.previous_transform_translate_y - r.previous_translate_y + h*(r.previous_transform_translate_y_percent-r.previous_translate_y_percent)*kInv1000f,
|
|
1052
|
+
static_cast<float>(r.previous_transform_translate_z-r.previous_translate_z)}, r.previous_transform_translate_outer_axes,
|
|
1053
|
+
r.previous_transform_rotate_x, r.previous_transform_rotate_y, r.previous_transform_rotate);
|
|
1054
|
+
composeIndividual(e.previousMatrix, shift, r.previous_rotate_angle, r.previous_rotate_axis_x, r.previous_rotate_axis_y, r.previous_rotate_axis_z,
|
|
1055
|
+
r.previous_scale_x, r.previous_scale_y, r.previous_scale_z,
|
|
1056
|
+
{r.previous_translate_x + w*r.previous_translate_x_percent*kInv1000f, r.previous_translate_y + h*r.previous_translate_y_percent*kInv1000f, static_cast<float>(r.previous_translate_z)});
|
|
1057
|
+
e.pTransX = shift.x; e.pTransY = shift.y; e.pTransZ = shift.z;
|
|
1030
1058
|
}
|
|
1031
1059
|
|
|
1032
1060
|
static NodeTransformCache *cachedNodeTransform(const Node &node)
|
|
1033
1061
|
{
|
|
1062
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1034
1063
|
static ActiveTransformCache cache;
|
|
1035
1064
|
const int id = nodeIndex(node);
|
|
1036
1065
|
if (id < 0) return nullptr;
|
|
@@ -1068,6 +1097,10 @@ public:
|
|
|
1068
1097
|
if (e.nodeId != -1) return nullptr;
|
|
1069
1098
|
fillNodeTransform(e, node, id);
|
|
1070
1099
|
return &e;
|
|
1100
|
+
#else
|
|
1101
|
+
(void)node;
|
|
1102
|
+
return nullptr;
|
|
1103
|
+
#endif
|
|
1071
1104
|
}
|
|
1072
1105
|
|
|
1073
1106
|
// Current-frame transform coefficients for a node, computed once per refresh
|
|
@@ -1082,6 +1115,7 @@ public:
|
|
|
1082
1115
|
// is fixed within a refresh, and the serial bumps when the tree re-records (the
|
|
1083
1116
|
// animating cube each frame). Only the current frame is cached; the colder
|
|
1084
1117
|
// previous-frame (dirty-bounds) path computes directly.
|
|
1118
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1085
1119
|
static const NodeTransformCache &nodeTransform(const Node &node)
|
|
1086
1120
|
{
|
|
1087
1121
|
if (NodeTransformCache *e = cachedNodeTransform(node)) return *e;
|
|
@@ -1090,23 +1124,61 @@ public:
|
|
|
1090
1124
|
return fallback;
|
|
1091
1125
|
}
|
|
1092
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
|
+
|
|
1093
1136
|
// Pure hardware-FPU application of precomputed transform coefficients to a
|
|
1094
1137
|
// point — no cache lookup, no divides, no trig. transformRectCorners hoists
|
|
1095
1138
|
// the per-node cache lookup out of its 4-corner loop and calls this directly.
|
|
1096
1139
|
static void applyCachedTransform(const NodeTransformCache &t, Point3 &p)
|
|
1097
1140
|
{
|
|
1098
|
-
p.x -= t.ox;
|
|
1099
|
-
p
|
|
1100
|
-
p.x
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1141
|
+
p.x -= t.ox; p.y -= t.oy;
|
|
1142
|
+
p = applyLinear(t.matrix, p);
|
|
1143
|
+
p.x += t.transX + t.ox; p.y += t.transY + t.oy; p.z += t.transZ;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// Facing of a plane within its own CSS 3D rendering context.
|
|
1147
|
+
static bool backFacing(const Node &node)
|
|
1148
|
+
{
|
|
1149
|
+
#if GEA_CSS_TRANSFORMS
|
|
1150
|
+
auto &state = treeState();
|
|
1151
|
+
Point3 normal{0, 0, 1};
|
|
1152
|
+
float offset = 0;
|
|
1153
|
+
for (int id = nodeIndex(node); id >= 0 && id < state.nodeCount;) {
|
|
1154
|
+
const auto &t = nodeTransform(state.nodes[id]);
|
|
1155
|
+
const float *m = t.matrix;
|
|
1156
|
+
const float cofactors[9] = {
|
|
1157
|
+
m[4]*m[8]-m[5]*m[7], m[5]*m[6]-m[3]*m[8], m[3]*m[7]-m[4]*m[6],
|
|
1158
|
+
m[2]*m[7]-m[1]*m[8], m[0]*m[8]-m[2]*m[6], m[1]*m[6]-m[0]*m[7],
|
|
1159
|
+
m[1]*m[5]-m[2]*m[4], m[2]*m[3]-m[0]*m[5], m[0]*m[4]-m[1]*m[3]};
|
|
1160
|
+
const float determinant = m[0]*cofactors[0] + m[1]*cofactors[1] + m[2]*cofactors[2];
|
|
1161
|
+
if (determinant == 0) return true;
|
|
1162
|
+
offset += normal.x*t.ox + normal.y*t.oy;
|
|
1163
|
+
normal = applyLinear(cofactors, normal);
|
|
1164
|
+
normal.x /= determinant; normal.y /= determinant; normal.z /= determinant;
|
|
1165
|
+
offset -= normal.x*(t.transX+t.ox) + normal.y*(t.transY+t.oy) + normal.z*t.transZ;
|
|
1166
|
+
id = state.nodes[id].parent;
|
|
1167
|
+
if (id < 0 || id >= state.nodeCount) break;
|
|
1168
|
+
const auto &parent = state.nodes[id];
|
|
1169
|
+
const auto &rare = rstyle(parent.style);
|
|
1170
|
+
if (hasTransformableBox(parent) && rare.perspective > 0) {
|
|
1171
|
+
const float ox = parent.layout.x + parent.layout.width * rare.perspective_origin_x * 0.001f;
|
|
1172
|
+
const float oy = parent.layout.y + parent.layout.height * rare.perspective_origin_y * 0.001f;
|
|
1173
|
+
normal.z += (offset + normal.x * ox + normal.y * oy) / rare.perspective;
|
|
1174
|
+
}
|
|
1175
|
+
if (!hasTransformableBox(parent) || !preserves3D(parent.style)) break;
|
|
1176
|
+
}
|
|
1177
|
+
return normal.z < -0.00001f;
|
|
1178
|
+
#else
|
|
1179
|
+
(void)node;
|
|
1180
|
+
return false;
|
|
1181
|
+
#endif
|
|
1110
1182
|
}
|
|
1111
1183
|
|
|
1112
1184
|
// Previous-frame analogue of applyCachedTransform — pure-FPU application of the
|
|
@@ -1114,18 +1186,9 @@ public:
|
|
|
1114
1186
|
// usePrevious branch, so the projected corner is bit-identical (no visual change).
|
|
1115
1187
|
static void applyCachedTransformPrev(const NodeTransformCache &t, Point3 &p)
|
|
1116
1188
|
{
|
|
1117
|
-
p.x -= t.pOx;
|
|
1118
|
-
p
|
|
1119
|
-
p.x
|
|
1120
|
-
p.y *= t.pScaleY;
|
|
1121
|
-
p.x += t.pTransX;
|
|
1122
|
-
p.y += t.pTransY;
|
|
1123
|
-
p.z += t.pTransZ;
|
|
1124
|
-
rotateZ(p, t.pSinZ, t.pCosZ);
|
|
1125
|
-
rotateY(p, t.pSinY, t.pCosY);
|
|
1126
|
-
rotateX(p, t.pSinX, t.pCosX);
|
|
1127
|
-
p.x += t.pOx;
|
|
1128
|
-
p.y += t.pOy;
|
|
1189
|
+
p.x -= t.pOx; p.y -= t.pOy;
|
|
1190
|
+
p = applyLinear(t.previousMatrix, p);
|
|
1191
|
+
p.x += t.pTransX + t.pOx; p.y += t.pTransY + t.pOy; p.z += t.pTransZ;
|
|
1129
1192
|
}
|
|
1130
1193
|
|
|
1131
1194
|
// Gather the ancestor chain's cached transform coefficients for the current
|
|
@@ -1179,39 +1242,9 @@ public:
|
|
|
1179
1242
|
return;
|
|
1180
1243
|
}
|
|
1181
1244
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
const int y = node.layout.previous_y;
|
|
1186
|
-
const int w = node.layout.previous_width;
|
|
1187
|
-
const int h = node.layout.previous_height;
|
|
1188
|
-
const int rotate = node.render.previous_transform_rotate;
|
|
1189
|
-
const int rotateXValue = node.render.previous_transform_rotate_x;
|
|
1190
|
-
const int rotateYValue = node.render.previous_transform_rotate_y;
|
|
1191
|
-
const int tx = node.render.previous_transform_translate_x;
|
|
1192
|
-
const int ty = node.render.previous_transform_translate_y;
|
|
1193
|
-
const int tz = node.render.previous_transform_translate_z;
|
|
1194
|
-
const int txPercent = node.render.previous_transform_translate_x_percent;
|
|
1195
|
-
const int tyPercent = node.render.previous_transform_translate_y_percent;
|
|
1196
|
-
const int sx = node.render.previous_transform_scale_x;
|
|
1197
|
-
const int sy = node.render.previous_transform_scale_y;
|
|
1198
|
-
const int originX = node.render.previous_transform_origin_x;
|
|
1199
|
-
const int originY = node.render.previous_transform_origin_y;
|
|
1200
|
-
|
|
1201
|
-
const float ox = static_cast<float>(x) + static_cast<float>(w) * static_cast<float>(originX) * kInv1000f;
|
|
1202
|
-
const float oy = static_cast<float>(y) + static_cast<float>(h) * static_cast<float>(originY) * kInv1000f;
|
|
1203
|
-
p.x -= ox;
|
|
1204
|
-
p.y -= oy;
|
|
1205
|
-
p.x *= static_cast<float>(sx) * kInv1000f;
|
|
1206
|
-
p.y *= static_cast<float>(sy) * kInv1000f;
|
|
1207
|
-
p.x += static_cast<float>(tx) + static_cast<float>(w) * static_cast<float>(txPercent) * kInv1000f;
|
|
1208
|
-
p.y += static_cast<float>(ty) + static_cast<float>(h) * static_cast<float>(tyPercent) * kInv1000f;
|
|
1209
|
-
p.z += tz;
|
|
1210
|
-
rotateZ(p, sinf(static_cast<float>(rotate) * kPiF * kInv1800f), cosf(static_cast<float>(rotate) * kPiF * kInv1800f));
|
|
1211
|
-
rotateY(p, sinf(static_cast<float>(rotateYValue) * kPiF * kInv1800f), cosf(static_cast<float>(rotateYValue) * kPiF * kInv1800f));
|
|
1212
|
-
rotateX(p, sinf(static_cast<float>(rotateXValue) * kPiF * kInv1800f), cosf(static_cast<float>(rotateXValue) * kPiF * kInv1800f));
|
|
1213
|
-
p.x += ox;
|
|
1214
|
-
p.y += oy;
|
|
1245
|
+
NodeTransformCache previous;
|
|
1246
|
+
fillNodeTransformPrev(previous, node);
|
|
1247
|
+
applyCachedTransformPrev(previous, p);
|
|
1215
1248
|
}
|
|
1216
1249
|
|
|
1217
1250
|
static int nearestPerspectiveNode(const Node &node, bool usePrevious)
|
|
@@ -1219,6 +1252,7 @@ public:
|
|
|
1219
1252
|
if (!anyTransformPresent()) return -1;
|
|
1220
1253
|
auto &state = treeState();
|
|
1221
1254
|
for (int id = nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
|
|
1255
|
+
if (usePrevious ? !state.nodes[id].render.previous_transformable_box : !hasTransformableBox(state.nodes[id])) continue;
|
|
1222
1256
|
const int perspective = usePrevious ? state.nodes[id].render.previous_perspective : rstyle(state.nodes[id].style).perspective;
|
|
1223
1257
|
if (perspective > 0) return id;
|
|
1224
1258
|
}
|
|
@@ -1393,6 +1427,7 @@ public:
|
|
|
1393
1427
|
// path isn't cached (cold, used only for dirty bounds).
|
|
1394
1428
|
static int GEA_VIEW_HOT_SRAM_SECTION("average_depth") averageDepth(const Node &node, bool usePrevious)
|
|
1395
1429
|
{
|
|
1430
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1396
1431
|
if (usePrevious) return averageDepthCompute(node, true);
|
|
1397
1432
|
static ActiveDepthCache cache;
|
|
1398
1433
|
const int id = nodeIndex(node);
|
|
@@ -1411,6 +1446,9 @@ public:
|
|
|
1411
1446
|
return d;
|
|
1412
1447
|
}
|
|
1413
1448
|
return averageDepthCompute(node, false);
|
|
1449
|
+
#else
|
|
1450
|
+
return averageDepthCompute(node, usePrevious);
|
|
1451
|
+
#endif
|
|
1414
1452
|
}
|
|
1415
1453
|
|
|
1416
1454
|
// The node's four projected screen-space corners for the current frame, cached
|
|
@@ -1419,6 +1457,7 @@ public:
|
|
|
1419
1457
|
// collapses those (and the dirty pass's current-frame half) to one projection.
|
|
1420
1458
|
static void GEA_VIEW_HOT_SRAM_SECTION("transform_corners") transformCorners(const Node &node, bool usePrevious, int16_t *xs, int16_t *ys)
|
|
1421
1459
|
{
|
|
1460
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
1422
1461
|
if (usePrevious) {
|
|
1423
1462
|
// Cache previous-frame corners per node per refresh, mirroring the current-frame
|
|
1424
1463
|
// path below. The dirty-bounds collect projects each node's previous corners
|
|
@@ -1477,20 +1516,77 @@ public:
|
|
|
1477
1516
|
}
|
|
1478
1517
|
transformRectCorners(node, false, node.layout.x, node.layout.y,
|
|
1479
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
|
|
1480
1526
|
}
|
|
1481
1527
|
};
|
|
1482
1528
|
|
|
1529
|
+
void appendReliefBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
1530
|
+
{
|
|
1531
|
+
using namespace gea::framework::graphics;
|
|
1532
|
+
const int w = node.layout.width, h = node.layout.height;
|
|
1533
|
+
if (w <= 0 || h <= 0) return;
|
|
1534
|
+
int widths[4];
|
|
1535
|
+
for (int side = 0; side < 4; ++side)
|
|
1536
|
+
widths[side] = std::min(computedBorderWidth(node.style, side), side % 2 ? w / 2 : h / 2);
|
|
1537
|
+
const bool transformed = ViewGeometry::hasTransformChain(node, false);
|
|
1538
|
+
for (int side = 0; side < 4; ++side) {
|
|
1539
|
+
if (widths[side] <= 0) continue;
|
|
1540
|
+
const int relief = rstyle(node.style).border_relief[side];
|
|
1541
|
+
const int bands = relief == 1 || relief == 2 ? 2 : 1;
|
|
1542
|
+
const auto color = borderPaintColor(node.style, side);
|
|
1543
|
+
int r, g, b; pixel::unpackRgb565(color, &r, &g, &b);
|
|
1544
|
+
r = pixel::expand5To8(r); g = pixel::expand6To8(g); b = pixel::expand5To8(b);
|
|
1545
|
+
// CSS permits UA-defined relief shades. Mixing with white keeps even a
|
|
1546
|
+
// black currentColor border visibly raised or recessed.
|
|
1547
|
+
const auto light = pixel::nativeColor((r * 3 + 510) / 5, (g * 3 + 510) / 5, (b * 3 + 510) / 5);
|
|
1548
|
+
const auto dark = pixel::nativeColor(r * 3 / 5, g * 3 / 5, b * 3 / 5);
|
|
1549
|
+
for (int band = 0; band < bands; ++band) {
|
|
1550
|
+
int16_t ringX[2][4], ringY[2][4];
|
|
1551
|
+
for (int ring = 0; ring < 2; ++ring) {
|
|
1552
|
+
int inset[4];
|
|
1553
|
+
for (int edge = 0; edge < 4; ++edge) inset[edge] = widths[edge] * (band + ring) / bands;
|
|
1554
|
+
const int left = node.layout.x + inset[3], right = node.layout.x + w - inset[1];
|
|
1555
|
+
const int top = node.layout.y + inset[0], bottom = node.layout.y + h - inset[2];
|
|
1556
|
+
const int px[4] = {left, right, right, left}, py[4] = {top, top, bottom, bottom};
|
|
1557
|
+
for (int corner = 0; corner < 4; ++corner) {
|
|
1558
|
+
if (transformed) ViewGeometry::transformPoint(node, false, px[corner], py[corner], 0, &ringX[ring][corner], &ringY[ring][corner]);
|
|
1559
|
+
else { ringX[ring][corner] = px[corner]; ringY[ring][corner] = py[corner]; }
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
const int next = (side + 1) % 4;
|
|
1563
|
+
const int16_t xs[4] = {ringX[0][side], ringX[0][next], ringX[1][next], ringX[1][side]};
|
|
1564
|
+
const int16_t ys[4] = {ringY[0][side], ringY[0][next], ringY[1][next], ringY[1][side]};
|
|
1565
|
+
const bool inset = relief == 3 || (relief == 1 && band == 0) || (relief == 2 && band == 1);
|
|
1566
|
+
const bool shadedDark = (side == 0 || side == 3) == inset;
|
|
1567
|
+
int bx0, by0, bx1, by1; boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
|
|
1568
|
+
appendFillQuadWithAlpha(xs, ys, relief == 0 ? color : shadedDark ? dark : light,
|
|
1569
|
+
borderPaintAlpha(node.style, side), parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1483
1574
|
void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
1484
1575
|
{
|
|
1485
1576
|
const int x = node.layout.x;
|
|
1486
1577
|
const int y = node.layout.y;
|
|
1487
1578
|
const int w = node.layout.width;
|
|
1488
1579
|
const int h = node.layout.height;
|
|
1489
|
-
if (
|
|
1580
|
+
if (hasBorderRelief(node.style)) { appendReliefBordersWithAlpha(node, parentAlpha); return; }
|
|
1581
|
+
const bool textClippedTransform = StyleValues::hasTextBackgroundClip(node.style) &&
|
|
1582
|
+
ViewGeometry::hasTransformChain(node, false) && !isFullyRoundedShape(node);
|
|
1583
|
+
if (w <= 0 || h <= 0 || (!hasSideBorder(node.style) && !borderColorsDiffer(node.style) && !textClippedTransform)) return;
|
|
1490
1584
|
|
|
1491
1585
|
const bool transformed = ViewGeometry::hasTransformChain(node, false);
|
|
1492
1586
|
for (int side = 0; side < 4; ++side) {
|
|
1493
|
-
const int borderWidth =
|
|
1587
|
+
const int borderWidth = computedBorderWidth(node.style, side);
|
|
1588
|
+
const auto color = borderPaintColor(node.style, side);
|
|
1589
|
+
const auto alpha = borderPaintAlpha(node.style, side);
|
|
1494
1590
|
if (borderWidth <= 0) continue;
|
|
1495
1591
|
int sx = x;
|
|
1496
1592
|
int sy = y;
|
|
@@ -1507,6 +1603,14 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
1507
1603
|
} else {
|
|
1508
1604
|
sw = std::min(borderWidth, w);
|
|
1509
1605
|
}
|
|
1606
|
+
// Horizontal edges own the corners. Avoid compositing a translucent
|
|
1607
|
+
// asymmetric border twice where two side rectangles would overlap.
|
|
1608
|
+
if (side == 1 || side == 3) {
|
|
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);
|
|
1611
|
+
sy += top;
|
|
1612
|
+
sh -= top + bottom;
|
|
1613
|
+
}
|
|
1510
1614
|
if (sw <= 0 || sh <= 0) continue;
|
|
1511
1615
|
if (transformed) {
|
|
1512
1616
|
int16_t xs[4], ys[4];
|
|
@@ -1515,8 +1619,8 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
1515
1619
|
boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
|
|
1516
1620
|
appendFillQuadWithAlpha(xs,
|
|
1517
1621
|
ys,
|
|
1518
|
-
|
|
1519
|
-
|
|
1622
|
+
color,
|
|
1623
|
+
alpha,
|
|
1520
1624
|
parentAlpha,
|
|
1521
1625
|
bx0,
|
|
1522
1626
|
by0,
|
|
@@ -1532,8 +1636,8 @@ void appendSideBordersWithAlpha(const Node &node, uint8_t parentAlpha)
|
|
|
1532
1636
|
sy,
|
|
1533
1637
|
sw,
|
|
1534
1638
|
sh,
|
|
1535
|
-
|
|
1536
|
-
|
|
1639
|
+
color,
|
|
1640
|
+
alpha,
|
|
1537
1641
|
parentAlpha,
|
|
1538
1642
|
sx,
|
|
1539
1643
|
sy,
|
|
@@ -1600,10 +1704,10 @@ void recordLinearGradientBackground(const Node &node, uint8_t parentAlpha)
|
|
|
1600
1704
|
// span rasterizer paints the first/last edgeWidth px of every span, tracing
|
|
1601
1705
|
// the quad outline). Emitting projected stroke quads instead would disarm
|
|
1602
1706
|
// the transform-reproject fast path every frame.
|
|
1603
|
-
if (node.style.border_width > 0 && node.style.
|
|
1707
|
+
if (!StyleValues::hasTextBackgroundClip(node.style) && node.style.border_width > 0 && !hasBorderRelief(node.style) && !hasSideBorder(node.style) && !borderColorsDiffer(node.style) && borderPaintAlpha(node.style, 0) > 0 &&
|
|
1604
1708
|
!isFullyRoundedShape(node)) {
|
|
1605
|
-
g.edgeColor = node.style
|
|
1606
|
-
g.edgeAlpha = node.style
|
|
1709
|
+
g.edgeColor = borderPaintColor(node.style, 0);
|
|
1710
|
+
g.edgeAlpha = borderPaintAlpha(node.style, 0);
|
|
1607
1711
|
const int ew = node.style.border_width < 1 ? 1 : node.style.border_width;
|
|
1608
1712
|
g.edgeWidth = static_cast<uint8_t>(ew > 8 ? 8 : ew);
|
|
1609
1713
|
} else {
|
|
@@ -1651,6 +1755,77 @@ void recordOverlayLinearGradientBackground(const Node &node)
|
|
|
1651
1755
|
rstyle(node.style).bg_overlay_gradient_has_mid);
|
|
1652
1756
|
}
|
|
1653
1757
|
|
|
1758
|
+
// Background positioning and painting areas are distinct. In particular, the
|
|
1759
|
+
// document canvas paints beyond the root box without stretching its images.
|
|
1760
|
+
bool recordPlacedBackgrounds(const Node &geometry, const Node &source, bool canvas)
|
|
1761
|
+
{
|
|
1762
|
+
const auto &r = rstyle(source.style);
|
|
1763
|
+
if (!canvas && r.bg_size_list < 0 && r.bg_position_list < 0 && r.bg_repeat_list < 0 &&
|
|
1764
|
+
r.bg_attachment_list < 0 && r.bg_origin_list < 0) return false;
|
|
1765
|
+
if (ViewGeometry::hasTransformChain(geometry, false)) return false;
|
|
1766
|
+
const int nodeId = ViewGeometry::nodeIndex(geometry);
|
|
1767
|
+
for (int layer = r.bg_image_layer_count-1; layer >= 0; --layer) {
|
|
1768
|
+
const bool linear = source.style.bg_fill == 1 && layer == r.bg_gradient_layer;
|
|
1769
|
+
const bool overlay = r.bg_overlay_gradient && layer == r.bg_overlay_gradient_layer;
|
|
1770
|
+
const bool radial = r.bg_radial_gradient && layer == r.bg_radial_gradient_layer;
|
|
1771
|
+
if (!linear && !overlay && !radial) continue;
|
|
1772
|
+
const auto p = StyleValues::backgroundPlacement(source.style, nodeId, layer,
|
|
1773
|
+
geometry.layout.x, geometry.layout.y, geometry.layout.width, geometry.layout.height);
|
|
1774
|
+
if (p.width <= 0 || p.height <= 0) continue;
|
|
1775
|
+
int x = canvas ? 0 : geometry.layout.x, y = canvas ? 0 : geometry.layout.y;
|
|
1776
|
+
int w = canvas ? treeState().mountedWidth : geometry.layout.width;
|
|
1777
|
+
int h = canvas ? treeState().mountedHeight : geometry.layout.height;
|
|
1778
|
+
const int clip = canvas ? 0 : StyleValues::backgroundClip(source.style, layer);
|
|
1779
|
+
TextBackgroundClipScope textClip(source, clip);
|
|
1780
|
+
if (clip == 1 || clip == 2) {
|
|
1781
|
+
int inset[4];
|
|
1782
|
+
for (int i = 0; i < 4; ++i) inset[i] = computedBorderWidth(geometry.style, i) +
|
|
1783
|
+
(clip == 2 ? std::max<int>(0, geometry.style.padding[i]) : 0);
|
|
1784
|
+
x += inset[3]; y += inset[0]; w -= inset[1]+inset[3]; h -= inset[0]+inset[2];
|
|
1785
|
+
}
|
|
1786
|
+
if (w <= 0 || h <= 0) continue;
|
|
1787
|
+
auto *begin = DisplayList::instance().append();
|
|
1788
|
+
if (!begin) return true;
|
|
1789
|
+
begin->type = DisplayCommandType::PushClip;
|
|
1790
|
+
begin->bx = begin->clip.x = x; begin->by = begin->clip.y = y;
|
|
1791
|
+
begin->bw = begin->clip.w = w; begin->bh = begin->clip.h = h; begin->clip.nodeId = -1;
|
|
1792
|
+
struct TileAxis { double start, step; int count; };
|
|
1793
|
+
auto axis = [](int position, int size, int mode, int area, int areaSize, int clipStart, int clipSize) -> TileAxis {
|
|
1794
|
+
if (mode == 1) return {static_cast<double>(position), static_cast<double>(size), 1};
|
|
1795
|
+
if (mode == 3) {
|
|
1796
|
+
const int count = areaSize/size;
|
|
1797
|
+
if (count < 2) return {static_cast<double>(position), static_cast<double>(size), 1};
|
|
1798
|
+
return {static_cast<double>(area), static_cast<double>(areaSize-size)/(count-1), count};
|
|
1799
|
+
}
|
|
1800
|
+
const int start = position + static_cast<int>(std::floor(static_cast<double>(clipStart-position)/size))*size;
|
|
1801
|
+
return {static_cast<double>(start), static_cast<double>(size), (clipStart+clipSize-start+size-1)/size};
|
|
1802
|
+
};
|
|
1803
|
+
const auto ax = axis(p.x,p.width,p.repeatX,p.areaX,p.areaWidth,x,w), ay = axis(p.y,p.height,p.repeatY,p.areaY,p.areaHeight,y,h);
|
|
1804
|
+
for (int row = 0; row < ay.count; ++row) for (int col = 0; col < ax.count; ++col) {
|
|
1805
|
+
const int tx = std::lround(ax.start+col*ax.step), ty = std::lround(ay.start+row*ay.step);
|
|
1806
|
+
if (tx >= x+w || ty >= y+h || tx+p.width <= x || ty+p.height <= y) continue;
|
|
1807
|
+
DisplayCommand *paint = nullptr;
|
|
1808
|
+
if (linear) paint = appendLinearGradientRectRaw(source,tx,ty,p.width,p.height);
|
|
1809
|
+
else if (radial) paint = appendRadialGradientRectRaw(source,tx,ty,p.width,p.height);
|
|
1810
|
+
else paint = appendLinearGradientRectRaw(source,tx,ty,p.width,p.height,
|
|
1811
|
+
r.bg_overlay_gradient_from_color,r.bg_overlay_gradient_mid_color,r.bg_overlay_gradient_to_color,
|
|
1812
|
+
r.bg_overlay_gradient_mid_stop,r.bg_overlay_gradient_to_stop,r.bg_overlay_gradient_angle,
|
|
1813
|
+
r.bg_overlay_gradient_from_alpha,r.bg_overlay_gradient_mid_alpha,r.bg_overlay_gradient_to_alpha,r.bg_overlay_gradient_has_mid);
|
|
1814
|
+
// Radius belongs to the painting box, never to each repeated image.
|
|
1815
|
+
if (paint) {
|
|
1816
|
+
auto &cmd = *paint;
|
|
1817
|
+
if (radial) cmd.radialGradient.tl = cmd.radialGradient.tr = cmd.radialGradient.br = cmd.radialGradient.bl = 0;
|
|
1818
|
+
else cmd.gradient.tl = cmd.gradient.tr = cmd.gradient.br = cmd.gradient.bl = 0;
|
|
1819
|
+
cmd.bx = std::max(x, tx); cmd.by = std::max(y, ty);
|
|
1820
|
+
cmd.bw = std::min(x+w,tx+p.width)-cmd.bx; cmd.bh = std::min(y+h,ty+p.height)-cmd.by;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
auto *end = DisplayList::instance().append();
|
|
1824
|
+
if (end) { end->type = DisplayCommandType::PopClip; end->bx = x; end->by = y; end->bw = w; end->bh = h; end->clip.nodeId = -1; }
|
|
1825
|
+
}
|
|
1826
|
+
return true;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1654
1829
|
void recordTransformedEllipseFill(const Node &node, uint8_t parentAlpha)
|
|
1655
1830
|
{
|
|
1656
1831
|
const int x = node.layout.x;
|
|
@@ -1694,12 +1869,17 @@ void recordTransformedEllipseFill(const Node &node, uint8_t parentAlpha)
|
|
|
1694
1869
|
if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
1695
1870
|
}
|
|
1696
1871
|
|
|
1697
|
-
void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha)
|
|
1872
|
+
void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha, int backgroundClip = 0)
|
|
1698
1873
|
{
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1874
|
+
int inset[4]{};
|
|
1875
|
+
if (backgroundClip > 0)
|
|
1876
|
+
for (int i = 0; i < 4; ++i)
|
|
1877
|
+
inset[i] = computedBorderWidth(node.style, i) +
|
|
1878
|
+
(backgroundClip == 2 ? std::max<int>(0, node.style.padding[i]) : 0);
|
|
1879
|
+
const int x = node.layout.x + inset[3];
|
|
1880
|
+
const int y = node.layout.y + inset[0];
|
|
1881
|
+
const int w = node.layout.width - inset[3] - inset[1];
|
|
1882
|
+
const int h = node.layout.height - inset[0] - inset[2];
|
|
1703
1883
|
if (w <= 0 || h <= 0) return;
|
|
1704
1884
|
|
|
1705
1885
|
int16_t xs[4], ys[4];
|
|
@@ -1711,6 +1891,10 @@ void recordTransformedRoundedRectFill(const Node &node, uint8_t parentAlpha)
|
|
|
1711
1891
|
int16_t rx8[4]{};
|
|
1712
1892
|
int16_t ry8[4]{};
|
|
1713
1893
|
resolvedBorderRadii8(node, rx8, ry8);
|
|
1894
|
+
for (int i = 0; i < 4; ++i) {
|
|
1895
|
+
rx8[i] = std::max(0, int(rx8[i]) - 8 * inset[i == 0 || i == 3 ? 3 : 1]);
|
|
1896
|
+
ry8[i] = std::max(0, int(ry8[i]) - 8 * inset[i < 2 ? 0 : 2]);
|
|
1897
|
+
}
|
|
1714
1898
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
1715
1899
|
if (cmd) {
|
|
1716
1900
|
cmd->type = DisplayCommandType::FillTransformedRoundedRect;
|
|
@@ -1748,7 +1932,7 @@ void recordTransformedEllipseStroke(const Node &node, uint8_t parentAlpha)
|
|
|
1748
1932
|
|
|
1749
1933
|
int bx0, by0, bx1, by1;
|
|
1750
1934
|
ViewRenderer::transformedBounds(node, false, &bx0, &by0, &bx1, &by1);
|
|
1751
|
-
const uint8_t effectiveAlpha = combineAlpha(parentAlpha, node.style
|
|
1935
|
+
const uint8_t effectiveAlpha = combineAlpha(parentAlpha, borderPaintAlpha(node.style, 0));
|
|
1752
1936
|
if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
1753
1937
|
|
|
1754
1938
|
const float cx = static_cast<float>(x) + static_cast<float>(w) * 0.5f;
|
|
@@ -1776,7 +1960,7 @@ void recordTransformedEllipseStroke(const Node &node, uint8_t parentAlpha)
|
|
|
1776
1960
|
int16_t px, py;
|
|
1777
1961
|
ViewGeometry::projectPoint(projector, localX, localY, 0.0f, &px, &py);
|
|
1778
1962
|
if (i > 0)
|
|
1779
|
-
appendStrokeSegmentBandRaw(prevX, prevY, px, py, screenStroke, node.style
|
|
1963
|
+
appendStrokeSegmentBandRaw(prevX, prevY, px, py, screenStroke, borderPaintColor(node.style, 0),
|
|
1780
1964
|
prevLocalX, prevLocalY, localX, localY, true);
|
|
1781
1965
|
prevX = px;
|
|
1782
1966
|
prevY = py;
|
|
@@ -1844,6 +2028,7 @@ void appendBackgroundGridRectRaw(const Node &node, int x, int y, int w, int h)
|
|
|
1844
2028
|
void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
|
|
1845
2029
|
{
|
|
1846
2030
|
if (rstyle(node.style).bg_grid_axes == 0) return;
|
|
2031
|
+
const auto placement = StyleValues::backgroundPlacement(node.style, ViewGeometry::nodeIndex(node), 0, node.layout.x, node.layout.y, node.layout.width, node.layout.height);
|
|
1847
2032
|
const int x0 = node.layout.x;
|
|
1848
2033
|
const int y0 = node.layout.y;
|
|
1849
2034
|
const int x1 = node.layout.x + node.layout.width;
|
|
@@ -1857,7 +2042,7 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
|
|
|
1857
2042
|
if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
1858
2043
|
|
|
1859
2044
|
if ((rstyle(node.style).bg_grid_axes & 1) != 0 && rstyle(node.style).bg_grid_line_x > 0) {
|
|
1860
|
-
const int step = rstyle(node.style).bg_grid_step_x > 0 ? rstyle(node.style).bg_grid_step_x : rstyle(node.style).bg_grid_line_x;
|
|
2045
|
+
const int step = rstyle(node.style).bg_size_list >= 0 ? placement.width : rstyle(node.style).bg_grid_step_x > 0 ? rstyle(node.style).bg_grid_step_x : rstyle(node.style).bg_grid_line_x;
|
|
1861
2046
|
if (step > 0) {
|
|
1862
2047
|
for (int x = x0; x < x1; x += step) {
|
|
1863
2048
|
const int w = std::min<int>(rstyle(node.style).bg_grid_line_x, x1 - x);
|
|
@@ -1866,7 +2051,7 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
|
|
|
1866
2051
|
}
|
|
1867
2052
|
}
|
|
1868
2053
|
if ((rstyle(node.style).bg_grid_axes & 2) != 0 && rstyle(node.style).bg_grid_line_y > 0) {
|
|
1869
|
-
const int step = rstyle(node.style).bg_grid_step_y > 0 ? rstyle(node.style).bg_grid_step_y : rstyle(node.style).bg_grid_line_y;
|
|
2054
|
+
const int step = rstyle(node.style).bg_size_list >= 0 ? placement.height : rstyle(node.style).bg_grid_step_y > 0 ? rstyle(node.style).bg_grid_step_y : rstyle(node.style).bg_grid_line_y;
|
|
1870
2055
|
if (step > 0) {
|
|
1871
2056
|
for (int y = y0; y < y1; y += step) {
|
|
1872
2057
|
const int h = std::min<int>(rstyle(node.style).bg_grid_line_y, y1 - y);
|
|
@@ -1878,6 +2063,7 @@ void recordBackgroundGrid(const Node &node, uint8_t parentAlpha)
|
|
|
1878
2063
|
if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1);
|
|
1879
2064
|
}
|
|
1880
2065
|
|
|
2066
|
+
#if GEA_CSS_BOX_SHADOW
|
|
1881
2067
|
uint8_t insetShadowAlphaAt(int depth, int solidDepth, int blurRadius, uint8_t baseAlpha)
|
|
1882
2068
|
{
|
|
1883
2069
|
if (baseAlpha == 0) return 0;
|
|
@@ -1902,7 +2088,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
1902
2088
|
boundsFromCorners(xs, ys, &bx0, &by0, &bx1, &by1);
|
|
1903
2089
|
appendFillQuadWithAlpha(xs,
|
|
1904
2090
|
ys,
|
|
1905
|
-
rstyle(node.style).box_shadow_color,
|
|
2091
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0),
|
|
1906
2092
|
alpha,
|
|
1907
2093
|
parentAlpha,
|
|
1908
2094
|
bx0,
|
|
@@ -1917,7 +2103,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
1917
2103
|
return;
|
|
1918
2104
|
}
|
|
1919
2105
|
if (!hasAnyRadius(node)) {
|
|
1920
|
-
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);
|
|
1921
2107
|
return;
|
|
1922
2108
|
}
|
|
1923
2109
|
int runX0 = 0;
|
|
@@ -1930,7 +2116,7 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
1930
2116
|
runY,
|
|
1931
2117
|
runX1 - runX0 + 1,
|
|
1932
2118
|
runH,
|
|
1933
|
-
rstyle(node.style).box_shadow_color,
|
|
2119
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0),
|
|
1934
2120
|
alpha,
|
|
1935
2121
|
parentAlpha,
|
|
1936
2122
|
runX0,
|
|
@@ -1960,20 +2146,175 @@ void appendInsetShadowBand(const Node &node, uint8_t parentAlpha, int x, int y,
|
|
|
1960
2146
|
flushRun();
|
|
1961
2147
|
}
|
|
1962
2148
|
|
|
2149
|
+
// The inset shadow is the padding contour minus an offset, spread-adjusted
|
|
2150
|
+
// hole. Represent both contours explicitly: independent edge bands overlap at
|
|
2151
|
+
// corners and cannot describe rounded holes or negative spread.
|
|
2152
|
+
struct ShadowContour {
|
|
2153
|
+
float x, y, w, h;
|
|
2154
|
+
float rx[4]{}, ry[4]{};
|
|
2155
|
+
};
|
|
2156
|
+
|
|
2157
|
+
void constrainShadowRadii(ShadowContour &shape)
|
|
2158
|
+
{
|
|
2159
|
+
float scale = 1.0f;
|
|
2160
|
+
auto constrain = [&](float limit, float sum) {
|
|
2161
|
+
if (sum > limit && sum > 0) scale = std::min(scale, std::max(0.0f, limit) / sum);
|
|
2162
|
+
};
|
|
2163
|
+
constrain(shape.w, shape.rx[0] + shape.rx[1]);
|
|
2164
|
+
constrain(shape.w, shape.rx[3] + shape.rx[2]);
|
|
2165
|
+
constrain(shape.h, shape.ry[0] + shape.ry[3]);
|
|
2166
|
+
constrain(shape.h, shape.ry[1] + shape.ry[2]);
|
|
2167
|
+
for (int i = 0; i < 4; ++i) { shape.rx[i] *= scale; shape.ry[i] *= scale; }
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
ShadowContour insetShadowClip(const Node &node)
|
|
2171
|
+
{
|
|
2172
|
+
int border[4];
|
|
2173
|
+
for (int i = 0; i < 4; ++i) border[i] = computedBorderWidth(node.style, i);
|
|
2174
|
+
ShadowContour shape{float(node.layout.x + border[3]), float(node.layout.y + border[0]),
|
|
2175
|
+
float(std::max(0, node.layout.width - border[3] - border[1])),
|
|
2176
|
+
float(std::max(0, node.layout.height - border[0] - border[2]))};
|
|
2177
|
+
int16_t rx8[4], ry8[4];
|
|
2178
|
+
resolvedBorderRadii8(node, rx8, ry8);
|
|
2179
|
+
for (int i = 0; i < 4; ++i) {
|
|
2180
|
+
shape.rx[i] = std::max(0.0f, rx8[i] * 0.125f - border[(i == 0 || i == 3) ? 3 : 1]);
|
|
2181
|
+
shape.ry[i] = std::max(0.0f, ry8[i] * 0.125f - border[i < 2 ? 0 : 2]);
|
|
2182
|
+
}
|
|
2183
|
+
constrainShadowRadii(shape);
|
|
2184
|
+
return shape;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
ShadowContour insetShadowHole(const ShadowContour &clip, int spread, int ox, int oy)
|
|
2188
|
+
{
|
|
2189
|
+
ShadowContour hole = clip;
|
|
2190
|
+
hole.x += spread + ox;
|
|
2191
|
+
hole.y += spread + oy;
|
|
2192
|
+
hole.w = std::max(0.0f, hole.w - 2 * spread);
|
|
2193
|
+
hole.h = std::max(0.0f, hole.h - 2 * spread);
|
|
2194
|
+
auto radius = [spread](float r) {
|
|
2195
|
+
float adjustment = float(spread);
|
|
2196
|
+
if (spread < 0 && r < -spread) {
|
|
2197
|
+
const float ratio = r / -spread - 1.0f;
|
|
2198
|
+
adjustment *= 1.0f + ratio * ratio * ratio;
|
|
2199
|
+
}
|
|
2200
|
+
return std::max(0.0f, r - adjustment);
|
|
2201
|
+
};
|
|
2202
|
+
for (int i = 0; i < 4; ++i) { hole.rx[i] = radius(hole.rx[i]); hole.ry[i] = radius(hole.ry[i]); }
|
|
2203
|
+
constrainShadowRadii(hole);
|
|
2204
|
+
return hole;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
bool shadowContourRow(const ShadowContour &shape, int y, int &left, int &right)
|
|
2208
|
+
{
|
|
2209
|
+
const float py = y + 0.5f;
|
|
2210
|
+
if (shape.w <= 0 || shape.h <= 0 || py < shape.y || py >= shape.y + shape.h) return false;
|
|
2211
|
+
float x0 = shape.x, x1 = shape.x + shape.w;
|
|
2212
|
+
for (int i = 0; i < 4; ++i) {
|
|
2213
|
+
const bool top = i < 2, isLeft = i == 0 || i == 3;
|
|
2214
|
+
const float rx = shape.rx[i], ry = shape.ry[i];
|
|
2215
|
+
if (rx <= 0 || ry <= 0) continue;
|
|
2216
|
+
const float cy = top ? shape.y + ry : shape.y + shape.h - ry;
|
|
2217
|
+
if (top ? py >= cy : py <= cy) continue;
|
|
2218
|
+
const float dy = (py - cy) / ry;
|
|
2219
|
+
const float inset = rx * (1.0f - std::sqrt(std::max(0.0f, 1.0f - dy * dy)));
|
|
2220
|
+
if (isLeft) x0 = std::max(x0, shape.x + inset);
|
|
2221
|
+
else x1 = std::min(x1, shape.x + shape.w - inset);
|
|
2222
|
+
}
|
|
2223
|
+
left = static_cast<int>(std::ceil(x0 - 0.5f));
|
|
2224
|
+
right = static_cast<int>(std::ceil(x1 - 0.5f)) - 1;
|
|
2225
|
+
return left <= right;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
void appendShadowRect(const Node &node, uint8_t parentAlpha, int x, int y, int w, int h)
|
|
2229
|
+
{
|
|
2230
|
+
if (w <= 0 || h <= 0) return;
|
|
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);
|
|
2233
|
+
if (!ViewGeometry::hasTransformChain(node, false)) {
|
|
2234
|
+
appendFillRectWithAlpha(x, y, w, h, color, alpha, parentAlpha, x, y, w, h);
|
|
2235
|
+
return;
|
|
2236
|
+
}
|
|
2237
|
+
int16_t xs[4], ys[4];
|
|
2238
|
+
ViewGeometry::transformRectCorners(node, false, x, y, w, h, xs, ys);
|
|
2239
|
+
int x0, y0, x1, y1;
|
|
2240
|
+
boundsFromCorners(xs, ys, &x0, &y0, &x1, &y1);
|
|
2241
|
+
appendFillQuadWithAlpha(xs, ys, color, alpha, parentAlpha, x0, y0, x1 - x0 + 1, y1 - y0 + 1, x, y, w, h, true);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
void recordSharpInsetShadow(const Node &node, uint8_t parentAlpha, const ShadowContour &clip, int spread, int ox, int oy)
|
|
2245
|
+
{
|
|
2246
|
+
if (clip.w <= 0 || clip.h <= 0) return;
|
|
2247
|
+
const ShadowContour hole = insetShadowHole(clip, spread, ox, oy);
|
|
2248
|
+
// A centered, opaque circular ring can use the same native stroke primitive
|
|
2249
|
+
// as a border. All other contours use disjoint spans, composited exactly once.
|
|
2250
|
+
bool circular = true;
|
|
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;
|
|
2252
|
+
if (ox == 0 && oy == 0 && spread > 0 && hole.w > 0 && hole.h > 0 && circular &&
|
|
2253
|
+
combineAlpha(parentAlpha, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_alpha : 0)) == 255 &&
|
|
2254
|
+
!ViewGeometry::hasTransformChain(node, false)) {
|
|
2255
|
+
DisplayCommand *cmd = DisplayList::instance().append();
|
|
2256
|
+
if (cmd) {
|
|
2257
|
+
cmd->type = DisplayCommandType::StrokeRoundedRect;
|
|
2258
|
+
cmd->strokeRoundedRect = {};
|
|
2259
|
+
cmd->bx = cmd->strokeRoundedRect.x = static_cast<int16_t>(clip.x);
|
|
2260
|
+
cmd->by = cmd->strokeRoundedRect.y = static_cast<int16_t>(clip.y);
|
|
2261
|
+
cmd->bw = cmd->strokeRoundedRect.w = static_cast<int16_t>(clip.w);
|
|
2262
|
+
cmd->bh = cmd->strokeRoundedRect.h = static_cast<int16_t>(clip.h);
|
|
2263
|
+
cmd->strokeRoundedRect.tl = static_cast<int16_t>(clip.rx[0]);
|
|
2264
|
+
cmd->strokeRoundedRect.tr = static_cast<int16_t>(clip.rx[1]);
|
|
2265
|
+
cmd->strokeRoundedRect.br = static_cast<int16_t>(clip.rx[2]);
|
|
2266
|
+
cmd->strokeRoundedRect.bl = static_cast<int16_t>(clip.rx[3]);
|
|
2267
|
+
cmd->strokeRoundedRect.lineWidth = spread;
|
|
2268
|
+
cmd->strokeRoundedRect.color = (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_color : 0);
|
|
2269
|
+
}
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
struct Run { int left = 0, right = -1, y = 0, height = 0; } runs[2];
|
|
2273
|
+
auto flush = [&](Run &run) {
|
|
2274
|
+
if (run.height > 0) appendShadowRect(node, parentAlpha, run.left, run.y, run.right - run.left + 1, run.height);
|
|
2275
|
+
run.height = 0;
|
|
2276
|
+
};
|
|
2277
|
+
for (int y = static_cast<int>(clip.y); y < clip.y + clip.h; ++y) {
|
|
2278
|
+
int left = 0, right = -1, holeLeft = 0, holeRight = -1;
|
|
2279
|
+
const bool hasClip = shadowContourRow(clip, y, left, right);
|
|
2280
|
+
const bool hasHole = shadowContourRow(hole, y, holeLeft, holeRight);
|
|
2281
|
+
int starts[2] = {left, 0}, ends[2] = {right, -1};
|
|
2282
|
+
if (!hasClip) ends[0] = starts[0] - 1;
|
|
2283
|
+
else if (hasHole && holeLeft <= right && holeRight >= left) {
|
|
2284
|
+
ends[0] = std::min(right, holeLeft - 1);
|
|
2285
|
+
starts[1] = std::max(left, holeRight + 1);
|
|
2286
|
+
ends[1] = right;
|
|
2287
|
+
}
|
|
2288
|
+
for (int i = 0; i < 2; ++i) {
|
|
2289
|
+
auto &run = runs[i];
|
|
2290
|
+
if (starts[i] > ends[i]) { flush(run); continue; }
|
|
2291
|
+
if (run.height && run.left == starts[i] && run.right == ends[i]) { ++run.height; continue; }
|
|
2292
|
+
flush(run);
|
|
2293
|
+
run = Run{starts[i], ends[i], y, 1};
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
for (auto &run : runs) flush(run);
|
|
2297
|
+
}
|
|
2298
|
+
|
|
1963
2299
|
void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
|
|
1964
2300
|
{
|
|
1965
|
-
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;
|
|
1966
2302
|
const int x = node.layout.x;
|
|
1967
2303
|
const int y = node.layout.y;
|
|
1968
2304
|
const int w = node.layout.width;
|
|
1969
2305
|
const int h = node.layout.height;
|
|
1970
2306
|
if (w <= 0 || h <= 0) return;
|
|
1971
2307
|
|
|
1972
|
-
const int blur = std::max<int>(0, rstyle(node.style).box_shadow_blur_radius);
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
2308
|
+
const int blur = std::max<int>(0, (GEA_CSS_BOX_SHADOW ? rstyle(node.style).box_shadow_blur_radius : 0));
|
|
2309
|
+
if (blur == 0) {
|
|
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));
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
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);
|
|
1977
2318
|
|
|
1978
2319
|
const int leftSolid = spread + std::max(0, ox);
|
|
1979
2320
|
const int rightSolid = spread + std::max(0, -ox);
|
|
@@ -1994,6 +2335,8 @@ void recordInsetBoxShadow(const Node &node, uint8_t parentAlpha)
|
|
|
1994
2335
|
appendInsetShadowBand(node, parentAlpha, x + w - d - 1, y, 1, h, insetShadowAlphaAt(d, rightSolid, blur, baseAlpha));
|
|
1995
2336
|
}
|
|
1996
2337
|
|
|
2338
|
+
#endif
|
|
2339
|
+
|
|
1997
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)
|
|
1998
2341
|
{
|
|
1999
2342
|
const Node *n = &node;
|
|
@@ -2023,7 +2366,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_bounds") ViewRenderer:
|
|
|
2023
2366
|
int rotate = use_prev ? n->render.previous_transform_rotate : rstyle(n->style).transform_rotate;
|
|
2024
2367
|
|
|
2025
2368
|
auto expandForBlur = [&]() {
|
|
2026
|
-
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);
|
|
2027
2370
|
if (radius <= 0) return;
|
|
2028
2371
|
const int extentX = std::max(1, radius) * 5;
|
|
2029
2372
|
const int extentY = std::max(1, radius) * 5;
|
|
@@ -2065,6 +2408,18 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_point") ViewRenderer::
|
|
|
2065
2408
|
ViewGeometry::transformPoint(node, usePrevious, x, y, z, outX, outY);
|
|
2066
2409
|
}
|
|
2067
2410
|
|
|
2411
|
+
bool ViewRenderer::backfaceSubtreeHidden(const Node &node)
|
|
2412
|
+
{
|
|
2413
|
+
const auto &state = treeState();
|
|
2414
|
+
for (int id = ViewGeometry::nodeIndex(node); id >= 0 && id < state.nodeCount; id = state.nodes[id].parent) {
|
|
2415
|
+
const auto &ancestor = state.nodes[id];
|
|
2416
|
+
if (ViewGeometry::hasTransformableBox(ancestor) && ancestor.style.backface_hidden &&
|
|
2417
|
+
!preserves3D(ancestor.style) && ViewGeometry::backFacing(ancestor))
|
|
2418
|
+
return true;
|
|
2419
|
+
}
|
|
2420
|
+
return false;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2068
2423
|
void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_rect_corners") ViewRenderer::transformedRectCorners(const Node &node, bool usePrevious, int x, int y, int w, int h, int16_t *xs, int16_t *ys,
|
|
2069
2424
|
int16_t *xs8, int16_t *ys8)
|
|
2070
2425
|
{
|
|
@@ -2076,6 +2431,11 @@ int GEA_VIEW_HOT_SRAM_SECTION("view_renderer_transformed_depth") ViewRenderer::t
|
|
|
2076
2431
|
return ViewGeometry::averageDepth(node, usePrevious);
|
|
2077
2432
|
}
|
|
2078
2433
|
|
|
2434
|
+
bool ViewRenderer::isTransformableBox(const Node &node)
|
|
2435
|
+
{
|
|
2436
|
+
return ViewGeometry::hasTransformableBox(node);
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2079
2439
|
bool GEA_VIEW_HOT_SRAM_SECTION("view_renderer_any_transform_active") ViewRenderer::anyTransformActive()
|
|
2080
2440
|
{
|
|
2081
2441
|
return ViewGeometry::anyTransformPresent();
|
|
@@ -2088,17 +2448,15 @@ bool ViewRenderer::recordClipBegin(const Node &node)
|
|
|
2088
2448
|
if (!isViewLikeNodeType(n->type) || n->style.overflow == 0) return 0;
|
|
2089
2449
|
if (n->first_child < 0) return 0;
|
|
2090
2450
|
|
|
2451
|
+
int x, y, w, h;
|
|
2452
|
+
overflowClipBounds(node, x, y, w, h);
|
|
2091
2453
|
DisplayCommand *cmd = DisplayList::instance().append();
|
|
2092
2454
|
if (cmd) {
|
|
2093
2455
|
cmd->type = DisplayCommandType::PushClip;
|
|
2094
|
-
cmd->bx =
|
|
2095
|
-
cmd->by =
|
|
2096
|
-
cmd->bw =
|
|
2097
|
-
cmd->bh =
|
|
2098
|
-
cmd->clip.x = n->layout.x;
|
|
2099
|
-
cmd->clip.y = n->layout.y;
|
|
2100
|
-
cmd->clip.w = n->layout.width;
|
|
2101
|
-
cmd->clip.h = n->layout.height;
|
|
2456
|
+
cmd->bx = cmd->clip.x = x;
|
|
2457
|
+
cmd->by = cmd->clip.y = y;
|
|
2458
|
+
cmd->bw = cmd->clip.w = w;
|
|
2459
|
+
cmd->bh = cmd->clip.h = h;
|
|
2102
2460
|
cmd->clip.nodeId = static_cast<int16_t>(&node - Tree::instance().nodes());
|
|
2103
2461
|
}
|
|
2104
2462
|
return 1;
|
|
@@ -2106,19 +2464,27 @@ bool ViewRenderer::recordClipBegin(const Node &node)
|
|
|
2106
2464
|
|
|
2107
2465
|
int ViewRenderer::scrollMaxX(const Node &node)
|
|
2108
2466
|
{
|
|
2467
|
+
#if GEA_CSS_SCROLLING
|
|
2109
2468
|
if (node.type == NodeType::VirtualList) return 0;
|
|
2110
2469
|
int max_x = node.layout.scroll_content_width - node.layout.width;
|
|
2111
2470
|
return max_x > 0 ? max_x : 0;
|
|
2471
|
+
#else
|
|
2472
|
+
(void)node; return 0;
|
|
2473
|
+
#endif
|
|
2112
2474
|
}
|
|
2113
2475
|
|
|
2114
2476
|
int ViewRenderer::scrollMaxY(const Node &node)
|
|
2115
2477
|
{
|
|
2478
|
+
#if GEA_CSS_SCROLLING
|
|
2116
2479
|
if (node.type == NodeType::VirtualList) {
|
|
2117
2480
|
const int id = static_cast<int>(&node - Tree::instance().nodes());
|
|
2118
2481
|
return VirtualListRenderer::scrollMaxY(id);
|
|
2119
2482
|
}
|
|
2120
2483
|
int max_y = node.layout.scroll_content_height - node.layout.height;
|
|
2121
2484
|
return max_y > 0 ? max_y : 0;
|
|
2485
|
+
#else
|
|
2486
|
+
(void)node; return 0;
|
|
2487
|
+
#endif
|
|
2122
2488
|
}
|
|
2123
2489
|
|
|
2124
2490
|
void ViewRenderer::recordClipEnd(const Node &node)
|
|
@@ -2134,6 +2500,22 @@ void ViewRenderer::recordClipEnd(const Node &node)
|
|
|
2134
2500
|
cmd->clip.nodeId = static_cast<int16_t>(&node - Tree::instance().nodes());
|
|
2135
2501
|
}
|
|
2136
2502
|
|
|
2503
|
+
int ViewRenderer::canvasBackgroundSource()
|
|
2504
|
+
{
|
|
2505
|
+
const auto &state = treeState();
|
|
2506
|
+
const int root = state.mountedRoot;
|
|
2507
|
+
if (root < 0 || root >= state.nodeCount || !isDocumentCanvasRoot(state.nodes[root])) return -1;
|
|
2508
|
+
const Node &html = state.nodes[root];
|
|
2509
|
+
// CSS Backgrounds: a transparent root with no images takes the first
|
|
2510
|
+
// direct body's background. Its used background is then transparent.
|
|
2511
|
+
if (!(GEA_CSS_CONTAINMENT ? rstyle(html.style).containment : 0) && (!html.style.has_bg || html.style.bg_alpha == 0) && !styleHasBackgroundImage(html.style)) {
|
|
2512
|
+
for (int child = html.first_child; child >= 0; child = state.nodes[child].next_sibling)
|
|
2513
|
+
if (std::string_view(tagFromId(state.nodes[child].tag_id)) == "body")
|
|
2514
|
+
return (GEA_CSS_CONTAINMENT ? rstyle(state.nodes[child].style).containment : 0) ? root : child;
|
|
2515
|
+
}
|
|
2516
|
+
return root;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2137
2519
|
void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordBox(const Node &node, uint8_t parentAlpha)
|
|
2138
2520
|
{
|
|
2139
2521
|
const Node *n = &node;
|
|
@@ -2141,43 +2523,78 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
|
|
|
2141
2523
|
int y = n->layout.y;
|
|
2142
2524
|
int w = n->layout.width;
|
|
2143
2525
|
int h = n->layout.height;
|
|
2526
|
+
const int canvasSource = canvasBackgroundSource();
|
|
2527
|
+
const bool canvasRoot = isDocumentCanvasRoot(node);
|
|
2528
|
+
if (canvasRoot && canvasSource >= 0) {
|
|
2529
|
+
const auto &state = treeState();
|
|
2530
|
+
const auto &source = state.nodes[canvasSource].style;
|
|
2531
|
+
if (source.display != 1 && source.has_bg && source.bg_alpha > 0)
|
|
2532
|
+
appendFillRectWithAlpha(0, 0, state.mountedWidth, state.mountedHeight,
|
|
2533
|
+
source.bg_color, source.bg_alpha, parentAlpha, 0, 0, state.mountedWidth, state.mountedHeight);
|
|
2534
|
+
if (source.display != 1) {
|
|
2535
|
+
const auto &imageSource = state.nodes[canvasSource];
|
|
2536
|
+
if (!recordPlacedBackgrounds(node, imageSource, true)) {
|
|
2537
|
+
if (source.bg_fill == 1) recordLinearGradientBackground(imageSource, parentAlpha);
|
|
2538
|
+
recordRadialGradientBackground(imageSource); recordOverlayLinearGradientBackground(imageSource);
|
|
2539
|
+
}
|
|
2540
|
+
recordBackgroundGrid(imageSource, parentAlpha);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2144
2543
|
if (w <= 0 || h <= 0) return;
|
|
2145
2544
|
|
|
2146
2545
|
if (n->style.has_bg) {
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
ViewGeometry::transformCorners(*n, false, xs, ys);
|
|
2160
|
-
appendFillQuadWithAlpha(xs, ys, n->style.bg_color, n->style.bg_alpha, parentAlpha,
|
|
2161
|
-
bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1,
|
|
2162
|
-
x, y, w, h, true);
|
|
2163
|
-
}
|
|
2164
|
-
recordBackgroundGrid(*n, parentAlpha);
|
|
2165
|
-
} else {
|
|
2166
|
-
if (hasAnyRadius(*n)) {
|
|
2167
|
-
if (hasAnyPercentRadius(*n) && !appendResolvedCircularRoundedRectWithAlpha(*n, parentAlpha))
|
|
2546
|
+
// The color is the bottom layer; image longhands never replace it.
|
|
2547
|
+
if (n->style.bg_alpha > 0 && !canvasRoot &&
|
|
2548
|
+
(canvasSource < 0 || &treeState().nodes[canvasSource] != n)) {
|
|
2549
|
+
const int clip = StyleValues::backgroundClip(n->style, rstyle(n->style).bg_image_layer_count - 1);
|
|
2550
|
+
TextBackgroundClipScope textClip(*n, clip);
|
|
2551
|
+
if (clip == 1 || clip == 2) {
|
|
2552
|
+
recordTransformedRoundedRectFill(*n, parentAlpha, clip);
|
|
2553
|
+
} else if (ViewGeometry::hasTransformChain(*n, false)) {
|
|
2554
|
+
int16_t xs[4], ys[4];
|
|
2555
|
+
int bx0, by0, bx1, by1;
|
|
2556
|
+
ViewRenderer::transformedBounds(*n, false, &bx0, &by0, &bx1, &by1);
|
|
2557
|
+
if (hasAnyRadius(*n)) {
|
|
2168
2558
|
recordTransformedRoundedRectFill(*n, parentAlpha);
|
|
2169
|
-
else
|
|
2170
|
-
|
|
2559
|
+
} else {
|
|
2560
|
+
ViewGeometry::transformCorners(*n, false, xs, ys);
|
|
2561
|
+
appendFillQuadWithAlpha(xs, ys, n->style.bg_color, n->style.bg_alpha, parentAlpha,
|
|
2562
|
+
bx0, by0, bx1 - bx0 + 1, by1 - by0 + 1,
|
|
2563
|
+
x, y, w, h, true);
|
|
2564
|
+
}
|
|
2171
2565
|
} else {
|
|
2172
|
-
|
|
2566
|
+
if (hasAnyRadius(*n)) {
|
|
2567
|
+
if (!appendResolvedCircularRoundedRectWithAlpha(*n, parentAlpha))
|
|
2568
|
+
recordTransformedRoundedRectFill(*n, parentAlpha);
|
|
2569
|
+
} else {
|
|
2570
|
+
appendFillRectWithAlpha(x, y, w, h, n->style.bg_color, n->style.bg_alpha, parentAlpha, x, y, w, h);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
if (!canvasRoot && (canvasSource < 0 || &treeState().nodes[canvasSource] != n)) {
|
|
2575
|
+
if (!recordPlacedBackgrounds(*n, *n, false)) {
|
|
2576
|
+
if (n->style.bg_fill == 1) {
|
|
2577
|
+
TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_gradient_layer));
|
|
2578
|
+
recordLinearGradientBackground(*n, parentAlpha);
|
|
2579
|
+
}
|
|
2580
|
+
{
|
|
2581
|
+
TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_radial_gradient_layer));
|
|
2582
|
+
recordRadialGradientBackground(*n);
|
|
2583
|
+
}
|
|
2584
|
+
{
|
|
2585
|
+
TextBackgroundClipScope textClip(*n, StyleValues::backgroundClip(n->style, rstyle(n->style).bg_overlay_gradient_layer));
|
|
2586
|
+
recordOverlayLinearGradientBackground(*n);
|
|
2587
|
+
}
|
|
2173
2588
|
}
|
|
2174
2589
|
recordBackgroundGrid(*n, parentAlpha);
|
|
2175
2590
|
}
|
|
2176
2591
|
}
|
|
2177
2592
|
|
|
2593
|
+
#if GEA_CSS_BOX_SHADOW
|
|
2178
2594
|
recordInsetBoxShadow(*n, parentAlpha);
|
|
2595
|
+
#endif
|
|
2179
2596
|
|
|
2180
|
-
if (n->style.border_width > 0 && !borderIsSameOpaqueSolidBackground(*n, parentAlpha)) {
|
|
2597
|
+
if (n->style.border_width > 0 && !hasBorderRelief(n->style) && !hasSideBorder(n->style) && !borderColorsDiffer(n->style) && !borderIsSameOpaqueSolidBackground(*n, parentAlpha)) {
|
|
2181
2598
|
if (ViewGeometry::hasTransformChain(*n, false)) {
|
|
2182
2599
|
if (isFullyRoundedShape(*n)) recordTransformedEllipseStroke(*n, parentAlpha);
|
|
2183
2600
|
} else {
|
|
@@ -2189,6 +2606,7 @@ void GEA_VIEW_HOT_SRAM_SECTION("view_renderer_record_box") ViewRenderer::recordB
|
|
|
2189
2606
|
|
|
2190
2607
|
void ViewRenderer::recordScrollbar(const Node &node)
|
|
2191
2608
|
{
|
|
2609
|
+
#if GEA_CSS_SCROLLING
|
|
2192
2610
|
const Node *n = &node;
|
|
2193
2611
|
if (!isViewLikeNodeType(n->type) || (n->type != NodeType::VirtualList && !scrollsOverflowY(n->style))) return;
|
|
2194
2612
|
if (n->layout.height <= 0 || n->layout.scroll_content_height <= n->layout.height) return;
|
|
@@ -2227,6 +2645,9 @@ void ViewRenderer::recordScrollbar(const Node &node)
|
|
|
2227
2645
|
// constant would not fit. 0x8C8E94 is the exact RGB888 expansion of the RGB565
|
|
2228
2646
|
// 0x8C72 this used to spell, so 16-bit panels emit the identical pixel.
|
|
2229
2647
|
cmd->fillRoundedRect.color = gea::framework::graphics::pixel::nativeFromRrggbbaa(0x8C8E94FFu);
|
|
2648
|
+
#else
|
|
2649
|
+
(void)node;
|
|
2650
|
+
#endif
|
|
2230
2651
|
}
|
|
2231
2652
|
|
|
2232
2653
|
} // namespace gea::embedded::ui
|