@geastack/engine 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas.cpp +24 -0
- package/image_store.cpp +308 -1
- package/package.json +1 -1
- package/ui/canvas_element.cpp +12 -16
- package/ui/canvas_store.cpp +7 -0
- package/ui/core.cpp +10 -7
- package/ui/document.cpp +25 -0
- package/ui/input.cpp +332 -11
- package/ui/input_render.cpp +62 -17
- package/ui/input_retirement.h +3 -0
- package/ui/internal.h +34 -0
- package/ui/layout.cpp +68 -16
- package/ui/layout_snapshot.cpp +119 -70
- package/ui/layout_snapshot.h +1 -0
- package/ui/node_model.h +6 -1
- package/ui/render.cpp +1126 -64
- package/ui/root_scroll_refresh.cpp +372 -66
- package/ui/root_scroll_refresh.h +4 -0
- package/ui/style.cpp +38 -21
- package/ui/svg_element.h +5 -2
- package/ui/svg_element_impl.h +475 -36
- package/ui/svg_geometry.h +78 -13
- package/ui/text.cpp +7 -6
- package/ui/tree_internal.h +17 -0
- package/ui/tree_nodes.cpp +1 -0
- package/ui/tree_render.cpp +290 -24
- package/ui/tree_state.h +9 -0
- package/ui/tree_style.cpp +8 -0
- package/ui/view.cpp +27 -9
- package/ui/viewport_region.cpp +53 -0
- package/ui/viewport_region.h +3 -0
- package/ui/virtual_keyboard.cpp +279 -23
- package/ui/virtual_keyboard_icons.h +114 -0
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
#include "display.h"
|
|
5
5
|
#include "internal.h"
|
|
6
6
|
#include "layout_snapshot.h"
|
|
7
|
+
#include "memory.h"
|
|
7
8
|
#include "refresh_perf.h"
|
|
8
9
|
#include "tree_state.h"
|
|
9
10
|
#include "viewport_region.h"
|
|
10
11
|
|
|
11
12
|
#include <algorithm>
|
|
12
13
|
#include <cstdlib>
|
|
14
|
+
#include <cstring>
|
|
15
|
+
#include <vector>
|
|
13
16
|
|
|
14
17
|
// When the platform's Display::scrollRect needs no framebuffer flush of the
|
|
15
18
|
// scrolled region itself (e.g. rp2350 driving the panel's hardware vertical
|
|
@@ -27,6 +30,20 @@
|
|
|
27
30
|
#define GEA_EMBEDDED_ROOT_SCROLL_TRANSLATE 1
|
|
28
31
|
#endif
|
|
29
32
|
|
|
33
|
+
// A display may decide at run time that its scrollRect publishes itself (the
|
|
34
|
+
// ESP32-S3 RGB panel's ring scroll); the weak default defers to the macro.
|
|
35
|
+
extern "C" __attribute__((weak)) bool gea_display_scroll_rect_self_flushing() { return false; }
|
|
36
|
+
// A display that can run a sideways scroll's shifted copy on another core while
|
|
37
|
+
// this one repaints the exposed strip starts it here (false: it cannot, and the
|
|
38
|
+
// caller blits with Display::scrollRect) and joins it in the end call.
|
|
39
|
+
extern "C" __attribute__((weak)) bool gea_display_scroll_rect_begin(int, int, int, int, int, int) { return false; }
|
|
40
|
+
extern "C" __attribute__((weak)) void gea_display_prepare_repaint(const gea::platform::display::DisplayFlushRect *, int) {}
|
|
41
|
+
// Per screen row from y0: what the coming sideways scroll copy leaves unchanged
|
|
42
|
+
// (DisplayList::scrollRowSignatures), so the display may skip rows its back
|
|
43
|
+
// buffer already holds. Taken by the next gea_display_scroll_rect_begin.
|
|
44
|
+
extern "C" __attribute__((weak)) void gea_display_scroll_rect_rows(const std::uint32_t *, int, int) {}
|
|
45
|
+
extern "C" __attribute__((weak)) void gea_display_scroll_rect_end() {}
|
|
46
|
+
|
|
30
47
|
namespace gea::embedded::ui {
|
|
31
48
|
|
|
32
49
|
#if GEA_CSS_SCROLLING
|
|
@@ -61,7 +78,10 @@ bool hasTransformState(const Node &node)
|
|
|
61
78
|
node.render.previous_perspective > 0;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
|
|
81
|
+
// Animated content inside a scroller (the CrowPanel Analytics meters: arcs,
|
|
82
|
+
// needles, legends and readouts) dirties a dozen or more nodes per frame; at 8
|
|
83
|
+
// every such scroll frame fell to the full relayout + repaint (~220 ms there).
|
|
84
|
+
constexpr int kMaxExtraDirtyNodes = 32;
|
|
65
85
|
// One full recycled-slot pool: a fast fling can rewindow every slot of a
|
|
66
86
|
// <virtual-list> in a single tick.
|
|
67
87
|
constexpr int kMaxSlotRepositionNodes = 24;
|
|
@@ -294,6 +314,59 @@ bool dirtyBounds(const Node &n, int width, int height, RootScrollOnlyRefresh::Di
|
|
|
294
314
|
return true;
|
|
295
315
|
}
|
|
296
316
|
|
|
317
|
+
// An overlay's painted box: its layout box widened by its box shadow.
|
|
318
|
+
bool overlayBounds(const Node &n, int width, int height, RootScrollOnlyRefresh::DirtyNode *out)
|
|
319
|
+
{
|
|
320
|
+
if (!dirtyBounds(n, width, height, out)) return false;
|
|
321
|
+
const auto &style = rstyle(n.computedStyle());
|
|
322
|
+
const int reach = std::abs(static_cast<int>(style.box_shadow_blur_radius)) +
|
|
323
|
+
std::abs(static_cast<int>(style.box_shadow_spread)) +
|
|
324
|
+
std::max(std::abs(static_cast<int>(style.box_shadow_offset_x)),
|
|
325
|
+
std::abs(static_cast<int>(style.box_shadow_offset_y)));
|
|
326
|
+
out->x0 = std::max(0, out->x0 - reach);
|
|
327
|
+
out->y0 = std::max(0, out->y0 - reach);
|
|
328
|
+
out->x1 = std::min(width - 1, out->x1 + reach);
|
|
329
|
+
out->y1 = std::min(height - 1, out->y1 + reach);
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// A plain <div> that paints nothing of its own: no background, border, or box
|
|
334
|
+
// shadow, and no scrollbar. Its pixels are whatever lies under it, so a scroll
|
|
335
|
+
// blit cannot drag anything of its own (a transparent hit target over a chart).
|
|
336
|
+
bool paintsNothingOwn(int id, const Node &n)
|
|
337
|
+
{
|
|
338
|
+
if (n.type != NodeType::View) return false;
|
|
339
|
+
const char *tag = Tree::instance().tagName(id);
|
|
340
|
+
if (!tag || std::strcmp(tag, "div") != 0) return false;
|
|
341
|
+
const auto &style = n.computedStyle();
|
|
342
|
+
if (style.has_bg || style.border_width != 0) return false;
|
|
343
|
+
if (scrollsOverflowX(style) || scrollsOverflowY(style)) return false;
|
|
344
|
+
const auto &rare = rstyle(style);
|
|
345
|
+
return rare.box_shadow_blur_radius == 0 && rare.box_shadow_spread == 0 && rare.box_shadow_offset_x == 0 &&
|
|
346
|
+
rare.box_shadow_offset_y == 0;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
} // namespace
|
|
350
|
+
|
|
351
|
+
// A border or a rounded corner on the scroller itself: pixels a scroll blit
|
|
352
|
+
// must not move (see blitScroll in refresh()).
|
|
353
|
+
static bool scrollerHasBoxFrame(const Node &n)
|
|
354
|
+
{
|
|
355
|
+
if (hasAnyBorder(n.computedStyle())) return true;
|
|
356
|
+
for (int r = 0; r < 4; r++) {
|
|
357
|
+
if (n.computedStyle().border_radius[GEA_CSS_RADIUS_INDEX(r)] != 0) return true;
|
|
358
|
+
#if GEA_CSS_PERCENT_RADIUS
|
|
359
|
+
if (n.computedStyle().border_radius_percent[GEA_CSS_RADIUS_INDEX(r)] != kUnset) return true;
|
|
360
|
+
#endif
|
|
361
|
+
}
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
namespace {
|
|
366
|
+
// The nodes a scroll fast-path frame found dirty, in id order: pass 2 of
|
|
367
|
+
// refreshNode classifies only these, and the frame's snapshot captures only
|
|
368
|
+
// these and the scroller's subtree, instead of reading every node from PSRAM.
|
|
369
|
+
std::vector<int> gScrollFrameDirty;
|
|
297
370
|
} // namespace
|
|
298
371
|
|
|
299
372
|
int RootScrollOnlyRefresh::refreshNode(int root,
|
|
@@ -313,9 +386,14 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
313
386
|
if (LayoutEngine::containsViewportFixed(root)) return -1;
|
|
314
387
|
|
|
315
388
|
// Pass 1: exactly one pure-scroll node.
|
|
389
|
+
gScrollFrameDirty.clear();
|
|
316
390
|
for (int i = 0; i < state.nodeCount; i++) {
|
|
317
391
|
Node *n = &state.nodes[i];
|
|
318
|
-
if (!n->render.dirty)
|
|
392
|
+
if (!n->render.dirty) {
|
|
393
|
+
if (n->render.bg_recolor_pending || n->render.canvas_pixels_only_dirty) gScrollFrameDirty.push_back(i);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
gScrollFrameDirty.push_back(i);
|
|
319
397
|
|
|
320
398
|
if (n->render.scroll_dirty && !n->render.non_scroll_dirty) {
|
|
321
399
|
if (foundNode >= 0) return -1;
|
|
@@ -333,20 +411,20 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
333
411
|
if (!vertical && !horizontal) return -1;
|
|
334
412
|
if (!layoutUnchanged(*n)) return -1;
|
|
335
413
|
if (hasTransformState(*n)) return -1;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
414
|
+
// A bordered or rounded scroller (a card that scrolls its list) is
|
|
415
|
+
// accepted too: refresh() repaints its box from the translated list
|
|
416
|
+
// instead of blitting it, which would drag the border and the
|
|
417
|
+
// corners along with the content. Rejecting it sent every scroll
|
|
418
|
+
// frame of the Shop tab's product card through a full relayout and
|
|
419
|
+
// a whole-screen replay (~180 ms a frame).
|
|
420
|
+
if (n->computedStyle().opacity != 255) return -1;
|
|
343
421
|
foundNode = i;
|
|
344
422
|
continue;
|
|
345
423
|
}
|
|
346
424
|
|
|
347
425
|
if (n->render.scroll_dirty) return -1;
|
|
348
426
|
}
|
|
349
|
-
if (foundNode < 0) return -1;
|
|
427
|
+
if (foundNode < 0) return -1; // no scroll
|
|
350
428
|
|
|
351
429
|
// Overlay guard: scrollRect shifts EVERY framebuffer pixel in the scroll
|
|
352
430
|
// viewport, so it is only valid when those pixels belong to the scroll
|
|
@@ -356,7 +434,41 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
356
434
|
// that branch overlapping siblings are composited afresh, so rejecting them
|
|
357
435
|
// would unnecessarily force a full-tree refresh (the weather city rail has
|
|
358
436
|
// exactly this shape because its negative margin overlaps the hero).
|
|
359
|
-
|
|
437
|
+
// The overlays found for this scroller stay valid while nothing outside it
|
|
438
|
+
// changes: no other node is dirty and the display list has not been
|
|
439
|
+
// re-recorded since (any layout or style change records it). Re-deriving
|
|
440
|
+
// them read every node's style and box from PSRAM, ~1.7 ms of each frame of
|
|
441
|
+
// a CrowPanel chart scroll.
|
|
442
|
+
static int overlayCacheNode = -1, overlayCacheRoot = -1;
|
|
443
|
+
static std::uint32_t overlayCacheSerial = 0;
|
|
444
|
+
static int overlayCacheCount = 0;
|
|
445
|
+
static DirtyNode overlayCache[kMaxExtraDirtyNodes];
|
|
446
|
+
// Other dirty nodes (the Analytics meters animate under a scrolling chart)
|
|
447
|
+
// leave it valid while they keep their boxes clear of the viewport: only a
|
|
448
|
+
// node over the viewport can be an overlay.
|
|
449
|
+
bool onlyScrollerDirty = true;
|
|
450
|
+
{
|
|
451
|
+
const Node &sn = state.nodes[foundNode];
|
|
452
|
+
for (const int i : gScrollFrameDirty) {
|
|
453
|
+
if (i == foundNode) continue;
|
|
454
|
+
const Node &o = state.nodes[i];
|
|
455
|
+
if (o.render.layout_dirty || !layoutUnchanged(o) ||
|
|
456
|
+
!(o.layout.x > sn.layout.x + sn.layout.width - 1 || o.layout.x + o.layout.width - 1 < sn.layout.x ||
|
|
457
|
+
o.layout.y > sn.layout.y + sn.layout.height - 1 || o.layout.y + o.layout.height - 1 < sn.layout.y)) {
|
|
458
|
+
onlyScrollerDirty = false;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const bool overlaysCached = onlyScrollerDirty && overlayCacheNode == foundNode && overlayCacheRoot == root &&
|
|
464
|
+
overlayCacheSerial == DisplayList::instance().recordSerial();
|
|
465
|
+
if (overlaysCached) {
|
|
466
|
+
for (int e = 0; e < overlayCacheCount; e++) extraDirtyNodes[e] = overlayCache[e];
|
|
467
|
+
*extraDirtyCount = overlayCacheCount;
|
|
468
|
+
} else {
|
|
469
|
+
overlayCacheNode = -1;
|
|
470
|
+
}
|
|
471
|
+
if (!overlaysCached && !hasRightFadeMask(state, foundNode)) {
|
|
360
472
|
const Node &sn = state.nodes[foundNode];
|
|
361
473
|
const int svx0 = sn.layout.x, svy0 = sn.layout.y;
|
|
362
474
|
const int svx1 = sn.layout.x + sn.layout.width - 1;
|
|
@@ -366,6 +478,12 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
366
478
|
const Node &o = state.nodes[i];
|
|
367
479
|
if (o.computedStyle().display == 1 || o.computedStyle().opacity == 0) continue;
|
|
368
480
|
if (o.layout.width <= 0 || o.layout.height <= 0) continue;
|
|
481
|
+
// Only a node over the viewport can be dragged by the blit. Test that
|
|
482
|
+
// first: the ancestor walks below, run for every node of the tree,
|
|
483
|
+
// cost ~4 ms of each CrowPanel chart scroll frame.
|
|
484
|
+
if (o.layout.x > svx1 || o.layout.x + o.layout.width - 1 < svx0 ||
|
|
485
|
+
o.layout.y > svy1 || o.layout.y + o.layout.height - 1 < svy0)
|
|
486
|
+
continue;
|
|
369
487
|
// Skip the scroll node's own subtree and its ancestor chain — and any
|
|
370
488
|
// node inside a display:none subtree: a hidden ancestor removes the
|
|
371
489
|
// whole branch from painting even though the descendants' own display
|
|
@@ -383,13 +501,43 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
383
501
|
if (a == i) { related = true; break; }
|
|
384
502
|
}
|
|
385
503
|
if (related) continue;
|
|
386
|
-
if (
|
|
387
|
-
|
|
504
|
+
if (paintsNothingOwn(i, o)) continue;
|
|
505
|
+
// An overlay: repaint it after the blit instead of giving up the
|
|
506
|
+
// blit. Its descendants widen the entry of the top-most listed
|
|
507
|
+
// ancestor rather than taking entries of their own.
|
|
508
|
+
RootScrollOnlyRefresh::DirtyNode box{};
|
|
509
|
+
if (!overlayBounds(o, width, height, &box)) continue;
|
|
510
|
+
RootScrollOnlyRefresh::DirtyNode *owner = nullptr;
|
|
511
|
+
for (int a = o.parent; a >= 0 && !owner; a = state.nodes[a].parent) {
|
|
512
|
+
for (int e = 0; e < *extraDirtyCount; e++) {
|
|
513
|
+
if (extraDirtyNodes[e].overlay && extraDirtyNodes[e].id == a) {
|
|
514
|
+
owner = &extraDirtyNodes[e];
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (owner) {
|
|
520
|
+
owner->x0 = std::min(owner->x0, box.x0);
|
|
521
|
+
owner->y0 = std::min(owner->y0, box.y0);
|
|
522
|
+
owner->x1 = std::max(owner->x1, box.x1);
|
|
523
|
+
owner->y1 = std::max(owner->y1, box.y1);
|
|
388
524
|
continue;
|
|
389
|
-
|
|
525
|
+
}
|
|
526
|
+
if (*extraDirtyCount >= kMaxExtraDirtyNodes) return -1;
|
|
527
|
+
box.id = i;
|
|
528
|
+
box.overlay = true;
|
|
529
|
+
extraDirtyNodes[(*extraDirtyCount)++] = box;
|
|
390
530
|
}
|
|
391
531
|
}
|
|
392
532
|
|
|
533
|
+
if (onlyScrollerDirty && !overlaysCached) {
|
|
534
|
+
// Taken before pass 2 adds this frame's own dirty nodes.
|
|
535
|
+
for (int e = 0; e < *extraDirtyCount; e++) overlayCache[e] = extraDirtyNodes[e];
|
|
536
|
+
overlayCacheCount = *extraDirtyCount;
|
|
537
|
+
overlayCacheNode = foundNode;
|
|
538
|
+
overlayCacheRoot = root;
|
|
539
|
+
overlayCacheSerial = DisplayList::instance().recordSerial();
|
|
540
|
+
}
|
|
393
541
|
// Pass 2: classify every other dirty node. Recycled slot children of a
|
|
394
542
|
// scrolling <virtual-list> get repositioned natively by refresh(); their
|
|
395
543
|
// dirty descendants (rebound label text, recolored row content) are covered
|
|
@@ -397,7 +545,7 @@ int RootScrollOnlyRefresh::refreshNode(int root,
|
|
|
397
545
|
// are skipped here — including ones whose pre-measured text box changed,
|
|
398
546
|
// which would otherwise reject the whole frame back to the full-relayout
|
|
399
547
|
// path on every fling tick.
|
|
400
|
-
for (int i
|
|
548
|
+
for (const int i : gScrollFrameDirty) {
|
|
401
549
|
Node *n = &state.nodes[i];
|
|
402
550
|
if (!n->render.dirty || i == foundNode) continue;
|
|
403
551
|
|
|
@@ -577,21 +725,19 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
577
725
|
GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
|
|
578
726
|
return 1;
|
|
579
727
|
}
|
|
580
|
-
|
|
581
728
|
// The scroll replay needs a display list whose commands match the
|
|
582
729
|
// post-shift layout, and recordNode drops commands for nodes outside the
|
|
583
730
|
// record clip — so off-viewport content has no commands until it scrolls
|
|
584
731
|
// in. Historically that forced a full clear()+recordNode() every scroll
|
|
585
732
|
// frame (~2ms). The translate-only path below skips it, mirroring the
|
|
586
733
|
// horizontal-pan fast path: record ONCE with the record clip expanded
|
|
587
|
-
//
|
|
588
|
-
//
|
|
589
|
-
//
|
|
590
|
-
//
|
|
591
|
-
//
|
|
592
|
-
//
|
|
593
|
-
//
|
|
594
|
-
// scrolls) keep the plain full rebuild — a translate can't express them.
|
|
734
|
+
// along the scrolled axis around the viewport (coverage), then per scroll
|
|
735
|
+
// frame just translate the scroll subtree's recorded commands in place
|
|
736
|
+
// (they follow shiftDescendantLayoutX/Y), un-translate the scroll node's
|
|
737
|
+
// own viewport-fixed box, and patch the scrollbar thumb. Coverage is
|
|
738
|
+
// re-recorded when the accumulated scroll leaves the padded window or any
|
|
739
|
+
// other record replaced the list (recordSerial). Virtual-list slot rebinds
|
|
740
|
+
// keep the plain full rebuild — a translate can't express them.
|
|
595
741
|
// (An earlier hybrid that recorded/cleared subtrees incrementally failed
|
|
596
742
|
// because DisplayList::replay() walks state.commands[] linearly and
|
|
597
743
|
// orphaned ranges kept replaying; wholesale translate avoids that
|
|
@@ -600,74 +746,117 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
600
746
|
static std::uint32_t coverageSerial = 0;
|
|
601
747
|
static int coverageRoot = -1;
|
|
602
748
|
static int coverageNode = -1;
|
|
603
|
-
static
|
|
604
|
-
static int
|
|
605
|
-
static int
|
|
606
|
-
|
|
749
|
+
static bool coverageHorizontal = false;
|
|
750
|
+
static int coverageScroll = 0;
|
|
751
|
+
static int coveragePadBefore = 0;
|
|
752
|
+
static int coveragePadAfter = 0;
|
|
753
|
+
// Window fallback for content too long to pre-record in one pass
|
|
607
754
|
// (command coords are int16, and the command buffer is finite).
|
|
608
755
|
constexpr int kScrollRecordFallbackPadding = 512;
|
|
609
|
-
constexpr int
|
|
756
|
+
constexpr int kMaxFullContentExtent = 16000;
|
|
610
757
|
|
|
611
758
|
auto &list = DisplayList::instance();
|
|
612
|
-
|
|
759
|
+
// The coverage window runs along the scrolled axis: rows for a vertical
|
|
760
|
+
// scroller, columns for a horizontal one (a tab pager), so a pager's
|
|
761
|
+
// pages are recorded once and every frame of a swipe only translates
|
|
762
|
+
// them -- a whole-list rebuild cost ~32 ms a frame on the CrowPanel.
|
|
763
|
+
const int scrollNow = horizontal ? n->layout.scroll_x : n->layout.scroll_y;
|
|
764
|
+
const int viewExtent = horizontal ? n->layout.width : n->layout.height;
|
|
765
|
+
const int contentExtent = horizontal ? n->layout.scroll_content_width : n->layout.scroll_content_height;
|
|
766
|
+
// Overlays only need repainting; their commands do not change.
|
|
767
|
+
int changedExtras = 0;
|
|
768
|
+
for (int e = 0; e < extraDirtyCount; e++)
|
|
769
|
+
if (!extraDirtyNodes[e].overlay) changedExtras++;
|
|
613
770
|
const bool translateEligible = GEA_EMBEDDED_ROOT_SCROLL_TRANSLATE != 0 &&
|
|
614
|
-
!horizontal &&
|
|
615
771
|
n->type != NodeType::VirtualList &&
|
|
616
|
-
slotCount == 0
|
|
617
|
-
|
|
618
|
-
const int coverageDelta = scrollYNow - coverageScrollY;
|
|
772
|
+
slotCount == 0;
|
|
773
|
+
const int coverageDelta = scrollNow - coverageScroll;
|
|
619
774
|
const bool coverageValid = translateEligible &&
|
|
620
775
|
coverageRoot == root &&
|
|
621
776
|
coverageNode == scroll_node &&
|
|
777
|
+
coverageHorizontal == horizontal &&
|
|
622
778
|
coverageSerial == list.recordSerial() &&
|
|
623
|
-
coverageDelta >= -
|
|
624
|
-
coverageDelta <=
|
|
779
|
+
coverageDelta >= -coveragePadBefore &&
|
|
780
|
+
coverageDelta <= coveragePadAfter;
|
|
781
|
+
// The coverage window as it lies on screen now, moved by the scroll since
|
|
782
|
+
// it was recorded.
|
|
783
|
+
auto coverageWindow = [&](int padBefore, int padAfter, int delta, int *x0, int *y0, int *x1, int *y1) {
|
|
784
|
+
*x0 = vx;
|
|
785
|
+
*y0 = vy;
|
|
786
|
+
*x1 = vx + vw - 1;
|
|
787
|
+
*y1 = vy + vh - 1;
|
|
788
|
+
if (horizontal) {
|
|
789
|
+
*x0 = vx - padBefore - delta;
|
|
790
|
+
*x1 = vx + vw - 1 + padAfter - delta;
|
|
791
|
+
} else {
|
|
792
|
+
*y0 = vy - padBefore - delta;
|
|
793
|
+
*y1 = vy + vh - 1 + padAfter - delta;
|
|
794
|
+
}
|
|
795
|
+
};
|
|
625
796
|
|
|
626
797
|
const std::int64_t rebuildStartUs = refreshPerfNowUs();
|
|
627
798
|
bool listReady = false;
|
|
628
799
|
if (coverageValid) {
|
|
629
|
-
|
|
800
|
+
const int mx = horizontal ? move : 0;
|
|
801
|
+
const int my = horizontal ? 0 : move;
|
|
802
|
+
list.translateSubtreeCommands(scroll_node, mx, my);
|
|
630
803
|
// translateSubtreeCommands includes the scroll node's own box
|
|
631
804
|
// commands (background/border), which are viewport-fixed — undo.
|
|
632
|
-
list.translateNodeCommands(scroll_node,
|
|
805
|
+
list.translateNodeCommands(scroll_node, -mx, -my);
|
|
633
806
|
listReady = list.patchScrollbarThumb(scroll_node);
|
|
807
|
+
// Changed content re-records in place at its shifted layout, under the
|
|
808
|
+
// coverage window the list was recorded with (now moved by the scroll
|
|
809
|
+
// since), so nodes off screen keep their commands for when they scroll
|
|
810
|
+
// in. Rebuilding the whole list for them cost 100+ ms per frame on a
|
|
811
|
+
// tab of animated meters.
|
|
812
|
+
int wx0, wy0, wx1, wy1;
|
|
813
|
+
coverageWindow(coveragePadBefore, coveragePadAfter, coverageDelta, &wx0, &wy0, &wx1, &wy1);
|
|
814
|
+
for (int e = 0; e < extraDirtyCount && listReady; e++) {
|
|
815
|
+
if (extraDirtyNodes[e].overlay) continue;
|
|
816
|
+
listReady = list.rerecordNodeCommandsWithExpandedClip(extraDirtyNodes[e].id, scroll_node, wx0, wy0, wx1, wy1);
|
|
817
|
+
}
|
|
634
818
|
}
|
|
635
819
|
if (!listReady && translateEligible) {
|
|
636
820
|
// Pre-record the WHOLE scroll content when it fits: one record,
|
|
637
821
|
// replayed (translated) forever — scrolling never re-records. For
|
|
638
|
-
// very
|
|
822
|
+
// very long content, fall back to a padded window around the
|
|
639
823
|
// viewport; a truncated record (command-buffer overflow) also
|
|
640
824
|
// falls back so coverage is never silently incomplete.
|
|
641
|
-
int
|
|
642
|
-
int
|
|
643
|
-
if (
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
825
|
+
int padBefore = scrollNow;
|
|
826
|
+
int padAfter = contentExtent - scrollNow - viewExtent;
|
|
827
|
+
if (padAfter < 0) padAfter = 0;
|
|
828
|
+
// A pager swipe ends one page over, so a horizontal record stops a page
|
|
829
|
+
// either side of the viewport: recording all three of the CrowPanel
|
|
830
|
+
// demo's pages cost ~71 ms on a swipe's first frame. A drag that goes
|
|
831
|
+
// further leaves the window and re-records, like any other scroll.
|
|
832
|
+
if (horizontal) {
|
|
833
|
+
padBefore = padBefore < viewExtent ? padBefore : viewExtent;
|
|
834
|
+
padAfter = padAfter < viewExtent ? padAfter : viewExtent;
|
|
835
|
+
}
|
|
836
|
+
if (contentExtent > kMaxFullContentExtent) {
|
|
837
|
+
padBefore = padBefore < kScrollRecordFallbackPadding ? padBefore : kScrollRecordFallbackPadding;
|
|
838
|
+
padAfter = padAfter < kScrollRecordFallbackPadding ? padAfter : kScrollRecordFallbackPadding;
|
|
647
839
|
}
|
|
648
840
|
for (int attempt = 0; attempt < 2 && !listReady; attempt++) {
|
|
841
|
+
int wx0, wy0, wx1, wy1;
|
|
842
|
+
coverageWindow(padBefore, padAfter, 0, &wx0, &wy0, &wx1, &wy1);
|
|
649
843
|
list.clear();
|
|
650
|
-
list.recordNodeWithExpandedClip(root,
|
|
651
|
-
255,
|
|
652
|
-
scroll_node,
|
|
653
|
-
vx,
|
|
654
|
-
vy - padTop,
|
|
655
|
-
vx + vw - 1,
|
|
656
|
-
vy + vh - 1 + padBottom);
|
|
844
|
+
list.recordNodeWithExpandedClip(root, 255, scroll_node, wx0, wy0, wx1, wy1);
|
|
657
845
|
list.weldTransformedFaces();
|
|
658
846
|
if (!list.commandOverflow()) {
|
|
659
847
|
listReady = true;
|
|
660
848
|
coverageSerial = list.recordSerial();
|
|
661
849
|
coverageRoot = root;
|
|
662
850
|
coverageNode = scroll_node;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
851
|
+
coverageHorizontal = horizontal;
|
|
852
|
+
coverageScroll = scrollNow;
|
|
853
|
+
coveragePadBefore = padBefore;
|
|
854
|
+
coveragePadAfter = padAfter;
|
|
666
855
|
break;
|
|
667
856
|
}
|
|
668
857
|
// Overflowed: retry once with the small window.
|
|
669
|
-
|
|
670
|
-
|
|
858
|
+
padBefore = padBefore < kScrollRecordFallbackPadding ? padBefore : kScrollRecordFallbackPadding;
|
|
859
|
+
padAfter = padAfter < kScrollRecordFallbackPadding ? padAfter : kScrollRecordFallbackPadding;
|
|
671
860
|
}
|
|
672
861
|
if (listReady) state.displayListDirty = false;
|
|
673
862
|
}
|
|
@@ -686,7 +875,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
686
875
|
|
|
687
876
|
gea::platform::display::Display::resetClip();
|
|
688
877
|
gea::platform::display::Display::setAlpha(255);
|
|
689
|
-
|
|
878
|
+
const bool kSelfFlushingScroll = GEA_EMBEDDED_DISPLAY_SCROLLRECT_SELF_FLUSHING != 0 || gea_display_scroll_rect_self_flushing();
|
|
690
879
|
constexpr int kMaxDamageRects = 24;
|
|
691
880
|
gea::platform::display::DisplayFlushRect damageRects[kMaxDamageRects];
|
|
692
881
|
int damageCount = 0;
|
|
@@ -707,7 +896,9 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
707
896
|
auto replayScrollNodeRegion = [&](int rx, int ry, int rw, int rh) {
|
|
708
897
|
noteDamage(rx, ry, rw, rh);
|
|
709
898
|
gScrollStripReplayActive = holdImages;
|
|
710
|
-
|
|
899
|
+
// The revealed band lands right beside rows the panel is scanning: always
|
|
900
|
+
// stage it (a drag's band is one to three strips).
|
|
901
|
+
ViewportRegion::replayDisplayRegionStaged(rx, ry, rw, rh);
|
|
711
902
|
gScrollStripReplayActive = false;
|
|
712
903
|
};
|
|
713
904
|
|
|
@@ -726,7 +917,11 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
726
917
|
// row remap nor the pixel blit shifts it correctly, and the stale pixels
|
|
727
918
|
// left behind showed as content drawn over itself. Re-rasterize the whole
|
|
728
919
|
// viewport from the rebuilt display list instead.
|
|
729
|
-
|
|
920
|
+
// A bordered or rounded scroller (a card that scrolls its list) repaints its
|
|
921
|
+
// whole box from the translated list: a blit would drag the frame along,
|
|
922
|
+
// and a partial-width blit on a ring-scrolled RGB panel relayouts and
|
|
923
|
+
// moves the scanout buffers, which garbled the card on the CrowPanel.
|
|
924
|
+
bool blitScroll = !contentHasRightFadeMask && !scrollerHasBoxFrame(*n);
|
|
730
925
|
#if GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE
|
|
731
926
|
if (auto *canvas = gea::platform::display::Display::canvas(); canvas && canvas->isLandscapeRotated()) blitScroll = false;
|
|
732
927
|
#endif
|
|
@@ -734,7 +929,58 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
734
929
|
const int viewportExtent = horizontal ? vw : vh;
|
|
735
930
|
if (blitScroll && abs_move > 0 && abs_move < viewportExtent) {
|
|
736
931
|
const std::int64_t scrollRectStartUs = refreshPerfNowUs();
|
|
737
|
-
|
|
932
|
+
// A sideways copy started above overlaps the strip repaint: the strip is
|
|
933
|
+
// exactly the columns the copy leaves alone.
|
|
934
|
+
// The copy starts only now, after the display list is up to date: the
|
|
935
|
+
// rebuild touches no pixels, so it runs while the frame waits for the
|
|
936
|
+
// panel to release the back buffer, and the copy (bus-bound, ~21 ms for a
|
|
937
|
+
// CrowPanel chart) shares PSRAM with nothing but the strip repaint. Started
|
|
938
|
+
// before the rebuild, the two contended and a chart frame missed the panel
|
|
939
|
+
// period by ~3 ms.
|
|
940
|
+
// The exposed strip, the repositioned slots and the overlay boxes all
|
|
941
|
+
// replay from one display-list walk, filtered for the box holding them
|
|
942
|
+
// all (each region otherwise walked the whole list: ~1.2 ms apiece).
|
|
943
|
+
// Filtered before the copy starts, while the frame still waits for the
|
|
944
|
+
// back buffer.
|
|
945
|
+
if (horizontal) {
|
|
946
|
+
int ux0 = move < 0 ? vx + vw - abs_move : vx, uy0 = vy;
|
|
947
|
+
int ux1 = ux0 + abs_move - 1, uy1 = vy + vh - 1;
|
|
948
|
+
auto unite = [&](int x0, int y0, int x1, int y1) {
|
|
949
|
+
ux0 = std::min(ux0, x0); uy0 = std::min(uy0, y0);
|
|
950
|
+
ux1 = std::max(ux1, x1); uy1 = std::max(uy1, y1);
|
|
951
|
+
};
|
|
952
|
+
for (int s = 0; s < slotCount; s++) {
|
|
953
|
+
unite(slotDamage[s].oldX0, slotDamage[s].oldY0, slotDamage[s].oldX1, slotDamage[s].oldY1);
|
|
954
|
+
if (slotDamage[s].moved) unite(slotDamage[s].newX0, slotDamage[s].newY0, slotDamage[s].newX1, slotDamage[s].newY1);
|
|
955
|
+
}
|
|
956
|
+
for (int i = 0; i < extraDirtyCount; i++)
|
|
957
|
+
unite(extraDirtyNodes[i].x0 - abs_move, extraDirtyNodes[i].y0, extraDirtyNodes[i].x1 + abs_move, extraDirtyNodes[i].y1);
|
|
958
|
+
int uw = ux1 - ux0 + 1, uh = uy1 - uy0 + 1;
|
|
959
|
+
if (ViewportRegion::clipRect(width, height, &ux0, &uy0, &uw, &uh)) {
|
|
960
|
+
gea::platform::display::Display::resetClip();
|
|
961
|
+
gea::platform::display::Display::pushClip(ux0, uy0, uw, uh);
|
|
962
|
+
DisplayList::instance().beginRegionReplay();
|
|
963
|
+
gea::platform::display::Display::popClip();
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
bool asyncCopy = false;
|
|
967
|
+
if (horizontal) {
|
|
968
|
+
gea::platform::display::Display::resetClip();
|
|
969
|
+
// Rows only full-width fills touch (a chart's empty band and rules) look
|
|
970
|
+
// the same after the shift; the display skips those its back buffer
|
|
971
|
+
// already holds, cutting the bus-bound copy.
|
|
972
|
+
constexpr int kMaxSigRows = 1024;
|
|
973
|
+
GEA_EXT_BSS static std::uint32_t rowSig[kMaxSigRows];
|
|
974
|
+
// No signatures (a filter blur, too tall) must be said too: the
|
|
975
|
+
// buffer may hold a half-written walk.
|
|
976
|
+
if (vh <= kMaxSigRows && DisplayList::instance().scrollRowSignatures(vx, vy, vw, vh, rowSig))
|
|
977
|
+
gea_display_scroll_rect_rows(rowSig, vy, vh);
|
|
978
|
+
else
|
|
979
|
+
gea_display_scroll_rect_rows(nullptr, 0, 0);
|
|
980
|
+
asyncCopy = gea_display_scroll_rect_begin(vx, vy, vw, vh, move, 0);
|
|
981
|
+
}
|
|
982
|
+
if (!asyncCopy)
|
|
983
|
+
gea::platform::display::Display::scrollRect(vx, vy, vw, vh, horizontal ? move : 0, horizontal ? 0 : move);
|
|
738
984
|
GEA_REFRESH_PERF(perf.rootScrollScrollRectUs += refreshPerfNowUs() - scrollRectStartUs);
|
|
739
985
|
|
|
740
986
|
const std::int64_t stripReplayStartUs = refreshPerfNowUs();
|
|
@@ -747,6 +993,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
747
993
|
} else {
|
|
748
994
|
replayScrollNodeRegion(vx, vy, vw, abs_move);
|
|
749
995
|
}
|
|
996
|
+
if (asyncCopy) gea_display_scroll_rect_end();
|
|
750
997
|
GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - stripReplayStartUs);
|
|
751
998
|
|
|
752
999
|
// Scrollbar damage is vertical-only: the horizontal forecast/rail rows use
|
|
@@ -787,6 +1034,18 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
787
1034
|
}
|
|
788
1035
|
} else {
|
|
789
1036
|
const std::int64_t fullReplayStartUs = refreshPerfNowUs();
|
|
1037
|
+
// The viewport is about to be painted whole when an opaque fill covers it:
|
|
1038
|
+
// ready a double-buffered panel's back buffer without first copying the
|
|
1039
|
+
// previous frame's pixels into the viewport. That copy cost as much as the
|
|
1040
|
+
// sideways blit it replaces (~20 ms for a CrowPanel chart).
|
|
1041
|
+
gea::platform::display::Display::pushClip(vx, vy, vw, vh);
|
|
1042
|
+
DisplayList::instance().replayCullStart();
|
|
1043
|
+
const bool viewportCovered = DisplayList::instance().replayCullCovered();
|
|
1044
|
+
gea::platform::display::Display::popClip();
|
|
1045
|
+
if (viewportCovered) {
|
|
1046
|
+
const gea::platform::display::DisplayFlushRect whole = {vx, vy, vx + vw - 1, vy + vh - 1};
|
|
1047
|
+
gea_display_prepare_repaint(&whole, 1);
|
|
1048
|
+
}
|
|
790
1049
|
replayScrollNodeRegion(vx, vy, vw, vh);
|
|
791
1050
|
GEA_REFRESH_PERF(perf.rootScrollFullReplayUs += refreshPerfNowUs() - fullReplayStartUs);
|
|
792
1051
|
}
|
|
@@ -818,8 +1077,37 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
818
1077
|
GEA_REFRESH_PERF(perf.rootScrollStripReplayUs += refreshPerfNowUs() - slotReplayStartUs);
|
|
819
1078
|
|
|
820
1079
|
const std::int64_t extraReplayStartUs = refreshPerfNowUs();
|
|
1080
|
+
// Every extra box is collected, overlapping ones merged (an animated meter's
|
|
1081
|
+
// arc, needle and readout share one box), and each merged box is staged
|
|
1082
|
+
// through SRAM strips. Painted directly, a scroll frame's dozen meter boxes
|
|
1083
|
+
// left hundreds of KB of dirty framebuffer lines in the cache, which the
|
|
1084
|
+
// bounce refill's reads then evicted -- written back inside its window, so
|
|
1085
|
+
// it overran and the panel showed a half-refilled band (thin flickering
|
|
1086
|
+
// lines while scrolling the CrowPanel Analytics tab).
|
|
1087
|
+
struct ExtraBox { int x0, y0, x1, y1; };
|
|
1088
|
+
ExtraBox boxes[kMaxExtraDirtyNodes * 2];
|
|
1089
|
+
int boxCount = 0;
|
|
1090
|
+
auto addBox = [&](int x0, int y0, int x1, int y1) {
|
|
1091
|
+
x0 = std::max(x0, 0);
|
|
1092
|
+
y0 = std::max(y0, 0);
|
|
1093
|
+
x1 = std::min(x1, width - 1);
|
|
1094
|
+
y1 = std::min(y1, height - 1);
|
|
1095
|
+
if (x0 > x1 || y0 > y1) return;
|
|
1096
|
+
boxes[boxCount++] = {x0, y0, x1, y1};
|
|
1097
|
+
};
|
|
821
1098
|
for (int i = 0; i < extraDirtyCount; i++) {
|
|
822
1099
|
DirtyNode dirty = extraDirtyNodes[i];
|
|
1100
|
+
if (dirty.overlay) {
|
|
1101
|
+
// The blit dragged the overlay's pixels by `move` inside the viewport:
|
|
1102
|
+
// repaint that shifted box (clipped to the viewport) as well as the box.
|
|
1103
|
+
int sx0 = dirty.x0 + (horizontal ? move : 0), sy0 = dirty.y0 + (horizontal ? 0 : move);
|
|
1104
|
+
int sx1 = dirty.x1 + (horizontal ? move : 0), sy1 = dirty.y1 + (horizontal ? 0 : move);
|
|
1105
|
+
sx0 = std::max(sx0, vx);
|
|
1106
|
+
sy0 = std::max(sy0, vy);
|
|
1107
|
+
sx1 = std::min(sx1, vx + vw - 1);
|
|
1108
|
+
sy1 = std::min(sy1, vy + vh - 1);
|
|
1109
|
+
if (sx0 <= sx1 && sy0 <= sy1) addBox(sx0, sy0, sx1, sy1);
|
|
1110
|
+
}
|
|
823
1111
|
// Bounds were computed before the scroll shift; content inside the
|
|
824
1112
|
// scrolled container has since moved by `move` along the scrolled axis.
|
|
825
1113
|
// Cover both the stale and shifted positions.
|
|
@@ -830,14 +1118,32 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
830
1118
|
if (move < 0) dirty.y0 += move; else dirty.y1 += move;
|
|
831
1119
|
}
|
|
832
1120
|
}
|
|
1121
|
+
addBox(dirty.x0, dirty.y0, dirty.x1, dirty.y1);
|
|
1122
|
+
}
|
|
1123
|
+
for (bool merged = true; merged;) {
|
|
1124
|
+
merged = false;
|
|
1125
|
+
for (int a = 0; a < boxCount; a++) {
|
|
1126
|
+
for (int b = a + 1; b < boxCount; b++) {
|
|
1127
|
+
if (boxes[a].x0 > boxes[b].x1 || boxes[b].x0 > boxes[a].x1 ||
|
|
1128
|
+
boxes[a].y0 > boxes[b].y1 || boxes[b].y0 > boxes[a].y1)
|
|
1129
|
+
continue;
|
|
1130
|
+
boxes[a] = {std::min(boxes[a].x0, boxes[b].x0), std::min(boxes[a].y0, boxes[b].y0),
|
|
1131
|
+
std::max(boxes[a].x1, boxes[b].x1), std::max(boxes[a].y1, boxes[b].y1)};
|
|
1132
|
+
boxes[b] = boxes[--boxCount];
|
|
1133
|
+
merged = true;
|
|
1134
|
+
--b;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
for (int i = 0; i < boxCount; i++) {
|
|
1139
|
+
const ExtraBox &b = boxes[i];
|
|
833
1140
|
gea::platform::display::Display::resetClip();
|
|
834
1141
|
gea::platform::display::Display::setAlpha(255);
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
DisplayList::instance().replay();
|
|
838
|
-
gea::platform::display::Display::popClip();
|
|
1142
|
+
noteDamage(b.x0, b.y0, b.x1 - b.x0 + 1, b.y1 - b.y0 + 1);
|
|
1143
|
+
ViewportRegion::replayDisplayRegionStaged(b.x0, b.y0, b.x1 - b.x0 + 1, b.y1 - b.y0 + 1);
|
|
839
1144
|
}
|
|
840
1145
|
GEA_REFRESH_PERF(perf.rootScrollExtraReplayUs += refreshPerfNowUs() - extraReplayStartUs);
|
|
1146
|
+
DisplayList::instance().endRegionReplay();
|
|
841
1147
|
|
|
842
1148
|
const std::int64_t flushStartUs = refreshPerfNowUs();
|
|
843
1149
|
if (kSelfFlushingScroll && !damageOverflow) {
|
|
@@ -849,7 +1155,7 @@ int RootScrollOnlyRefresh::refresh(int root, int width, int height)
|
|
|
849
1155
|
GEA_REFRESH_PERF(perf.rootScrollFlushUs += refreshPerfNowUs() - flushStartUs);
|
|
850
1156
|
|
|
851
1157
|
const std::int64_t snapshotStartUs = refreshPerfNowUs();
|
|
852
|
-
LayoutSnapshot::
|
|
1158
|
+
LayoutSnapshot::captureNodes(gScrollFrameDirty.data(), static_cast<int>(gScrollFrameDirty.size()), scroll_node);
|
|
853
1159
|
GEA_REFRESH_PERF(perf.rootScrollSnapshotUs += refreshPerfNowUs() - snapshotStartUs);
|
|
854
1160
|
|
|
855
1161
|
return 1;
|
package/ui/root_scroll_refresh.h
CHANGED
|
@@ -11,6 +11,10 @@ public:
|
|
|
11
11
|
int y0;
|
|
12
12
|
int x1;
|
|
13
13
|
int y1;
|
|
14
|
+
// A node outside the scroll subtree that overlaps the viewport (a
|
|
15
|
+
// floating button): the blit drags its pixels by the scroll distance, so
|
|
16
|
+
// it is repainted at its own box and at the box shifted by the scroll.
|
|
17
|
+
bool overlay = false;
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
static int refresh(int root, int width, int height);
|