@geastack/engine 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas.cpp +150 -27
- package/image_store.cpp +308 -1
- package/package.json +1 -1
- package/ui/CSS_FEATURES.md +51 -0
- package/ui/canvas_element.cpp +12 -16
- package/ui/core.cpp +10 -7
- package/ui/document.cpp +25 -0
- package/ui/input.cpp +341 -11
- package/ui/input_render.cpp +62 -17
- package/ui/input_retirement.h +3 -0
- package/ui/internal.h +38 -1
- package/ui/layout.cpp +68 -16
- package/ui/layout_snapshot.cpp +119 -70
- package/ui/layout_snapshot.h +1 -0
- package/ui/node_features.h +6 -0
- package/ui/node_model.h +23 -2
- package/ui/render.cpp +1154 -64
- package/ui/root_scroll_refresh.cpp +372 -66
- package/ui/root_scroll_refresh.h +4 -0
- package/ui/style.cpp +74 -21
- package/ui/style.h +18 -1
- package/ui/svg_element.h +98 -0
- package/ui/svg_element_impl.h +1589 -0
- package/ui/svg_geometry.h +1767 -0
- package/ui/text.cpp +7 -6
- package/ui/tree_events.cpp +15 -0
- package/ui/tree_internal.h +12 -0
- package/ui/tree_nodes.cpp +37 -2
- package/ui/tree_render.cpp +290 -22
- package/ui/tree_state.h +9 -0
- package/ui/tree_style.cpp +32 -0
- package/ui/view.cpp +27 -9
- package/ui/viewport_region.cpp +53 -0
- package/ui/viewport_region.h +3 -0
- package/ui/virtual_keyboard.cpp +279 -23
- package/ui/virtual_keyboard_icons.h +114 -0
package/ui/render.cpp
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
#include "state_init.h"
|
|
11
11
|
#include "style_values.h"
|
|
12
12
|
#include "tree_state.h"
|
|
13
|
+
#include "svg_element.h"
|
|
13
14
|
#include <pixel.h>
|
|
14
15
|
|
|
15
16
|
#include <algorithm>
|
|
16
17
|
#include <array>
|
|
17
18
|
#include <cctype>
|
|
19
|
+
#include <climits>
|
|
18
20
|
#include <cmath>
|
|
19
21
|
#include <cstdint>
|
|
20
22
|
#include <cstdio>
|
|
@@ -185,6 +187,31 @@ extern "C" __attribute__((weak)) int gea_current_render_core() { return 0; }
|
|
|
185
187
|
extern "C" __attribute__((weak)) int gea_replay_stage_rows() { return 0; }
|
|
186
188
|
extern "C" __attribute__((weak)) bool gea_replay_stage_begin(int, int, int, int) { return false; }
|
|
187
189
|
extern "C" __attribute__((weak)) void gea_replay_stage_end() {}
|
|
190
|
+
// True while this core has a stage open: its draws already land in SRAM.
|
|
191
|
+
extern "C" __attribute__((weak)) bool gea_replay_stage_active() { return false; }
|
|
192
|
+
extern "C" __attribute__((weak)) int gea_bulk_replay_stage_rows() { return 0; }
|
|
193
|
+
// Rows a staged window `width` pixels wide may span; a display packing narrow
|
|
194
|
+
// windows tighter returns more than gea_bulk_replay_stage_rows().
|
|
195
|
+
extern "C" __attribute__((weak)) int gea_bulk_replay_stage_rows_for_width(int) { return gea_bulk_replay_stage_rows(); }
|
|
196
|
+
extern "C" __attribute__((weak)) void gea_replay_stage_skip_seed(bool) {}
|
|
197
|
+
extern "C" __attribute__((weak)) void gea_replay_stage_pipeline(bool) {}
|
|
198
|
+
// A replay is about to draw straight into the framebuffer (no stage open), so
|
|
199
|
+
// its rows sit dirty in the cache until the publish writes them back.
|
|
200
|
+
extern "C" __attribute__((weak)) void gea_display_note_direct_draw() {}
|
|
201
|
+
namespace {
|
|
202
|
+
// A repaint this large (a quarter of an 800x480 panel) is a burst: a tab's
|
|
203
|
+
// first scroll, a content swap. Raster it through the display's SRAM strips
|
|
204
|
+
// even where per-frame repaints go direct -- unstaged, its PSRAM writes starve
|
|
205
|
+
// a bounce-buffered panel's scanout refill (a visible tear). Steady per-frame
|
|
206
|
+
// repaints stay below it, so the per-strip list walk never taxes animation.
|
|
207
|
+
constexpr long kBulkStagePixels = 96000;
|
|
208
|
+
int replayStageRowsForArea(long area)
|
|
209
|
+
{
|
|
210
|
+
const int rows = gea_replay_stage_rows();
|
|
211
|
+
if (rows > 0) return rows;
|
|
212
|
+
return area >= kBulkStagePixels ? gea_bulk_replay_stage_rows() : 0;
|
|
213
|
+
}
|
|
214
|
+
} // namespace
|
|
188
215
|
|
|
189
216
|
// Share (permille of the split region's rows) the SUBMITTING core keeps in the
|
|
190
217
|
// coarse 2-core replay split. 500 = even split. A target whose render core pays a
|
|
@@ -253,6 +280,7 @@ extern "C" __attribute__((weak)) void gea_rgb565_lut_blend_const_alpha_span(std:
|
|
|
253
280
|
namespace gea::embedded::ui
|
|
254
281
|
{
|
|
255
282
|
|
|
283
|
+
|
|
256
284
|
bool gScrollStripReplayActive = false;
|
|
257
285
|
bool gScrollRanThisFrame = false;
|
|
258
286
|
bool gScrollImageHoldPending = false;
|
|
@@ -335,6 +363,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
335
363
|
return "BlitImageProjected";
|
|
336
364
|
case DisplayCommandType::ReplayCanvasBatch:
|
|
337
365
|
return "ReplayCanvasBatch";
|
|
366
|
+
case DisplayCommandType::DrawSvg:
|
|
367
|
+
return "DrawSvg";
|
|
338
368
|
case DisplayCommandType::BeginFilterBlur:
|
|
339
369
|
return "BeginFilterBlur";
|
|
340
370
|
case DisplayCommandType::ApplyFilterBlur:
|
|
@@ -541,6 +571,18 @@ int gLastScrollUiFrame = -1000;
|
|
|
541
571
|
int commandCount = 0;
|
|
542
572
|
bool imageReferences[gea::framework::graphics::kImageMax]{};
|
|
543
573
|
bool textClippedBackgrounds = false;
|
|
574
|
+
// Scrollbar thumbs in the command stream (recorded after their
|
|
575
|
+
// container's children, so outside every node's command range). Direct
|
|
576
|
+
// dirty-region replay walks node ranges and never draws them; a frame
|
|
577
|
+
// whose dirty rects touch one must take the full-list path instead.
|
|
578
|
+
static constexpr int kMaxScrollbarBoxes = 16;
|
|
579
|
+
std::int16_t scrollbarBoxes[kMaxScrollbarBoxes][4]{};
|
|
580
|
+
// Each thumb's own command, so direct replay can repaint it.
|
|
581
|
+
int scrollbarCommands[kMaxScrollbarBoxes]{};
|
|
582
|
+
// Each thumb's scroll container, so a subtree translate can move it.
|
|
583
|
+
int scrollbarNodes[kMaxScrollbarBoxes]{};
|
|
584
|
+
int scrollbarBoxCount = 0;
|
|
585
|
+
bool scrollbarBoxOverflow = false;
|
|
544
586
|
// Sticky: an append() was dropped because the command buffer is full.
|
|
545
587
|
// Reset by clear(); lets a caller detect a truncated record.
|
|
546
588
|
bool commandOverflow = false;
|
|
@@ -801,6 +843,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
801
843
|
commandsExternal = false;
|
|
802
844
|
commandCount = 0;
|
|
803
845
|
textClippedBackgrounds = false;
|
|
846
|
+
scrollbarBoxCount = 0;
|
|
847
|
+
scrollbarBoxOverflow = false;
|
|
804
848
|
appendOverride = nullptr;
|
|
805
849
|
appendOverrideCount = nullptr;
|
|
806
850
|
appendOverrideCapacity = 0;
|
|
@@ -851,6 +895,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
851
895
|
if (nodeDrawEnd[i] >= old_end)
|
|
852
896
|
nodeDrawEnd[i] += delta;
|
|
853
897
|
}
|
|
898
|
+
// Scrollbar thumbs sit outside every node range but are addressed by
|
|
899
|
+
// command index too (scrollbarThumbsPaintLast, replayScrollbarThumbsInRegion).
|
|
900
|
+
for (int i = 0; i < scrollbarBoxCount; i++)
|
|
901
|
+
if (scrollbarCommands[i] >= old_end)
|
|
902
|
+
scrollbarCommands[i] += delta;
|
|
854
903
|
}
|
|
855
904
|
};
|
|
856
905
|
|
|
@@ -5345,9 +5394,9 @@ int gLastScrollUiFrame = -1000;
|
|
|
5345
5394
|
// Memoize per node per refresh. The child z-sort runs at every tree level,
|
|
5346
5395
|
// so an ancestor's sort recurses a subtree that a descendant's sort then
|
|
5347
5396
|
// re-walks. Caching collapses those repeated O(subtree) walks to O(1).
|
|
5348
|
-
static int memo[kMaxNodes];
|
|
5349
|
-
static uint64_t memoSerial[kMaxNodes];
|
|
5350
|
-
static int memoContextRoot[kMaxNodes];
|
|
5397
|
+
GEA_EXT_BSS static int memo[kMaxNodes];
|
|
5398
|
+
GEA_EXT_BSS static uint64_t memoSerial[kMaxNodes];
|
|
5399
|
+
GEA_EXT_BSS static int memoContextRoot[kMaxNodes];
|
|
5351
5400
|
const uint64_t serial = tree.refreshSerial();
|
|
5352
5401
|
if (node < kMaxNodes && memoSerial[node] == serial && memoContextRoot[node] == contextRoot)
|
|
5353
5402
|
return memo[node];
|
|
@@ -5538,6 +5587,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
5538
5587
|
c->canvasBatch.x += dx;
|
|
5539
5588
|
c->canvasBatch.y += dy;
|
|
5540
5589
|
break;
|
|
5590
|
+
case DisplayCommandType::DrawSvg:
|
|
5591
|
+
c->svg.x += dx;
|
|
5592
|
+
c->svg.y += dy;
|
|
5593
|
+
break;
|
|
5541
5594
|
case DisplayCommandType::BlitImageProjected:
|
|
5542
5595
|
c->projectedBlit.x += dx;
|
|
5543
5596
|
c->projectedBlit.y += dy;
|
|
@@ -6946,6 +6999,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
6946
6999
|
CanvasRenderingContext2D::replayRetainedCanvas(c.canvasBatch.nodeId, c.canvasBatch.identity,
|
|
6947
7000
|
c.canvasBatch.x, c.canvasBatch.y, c.canvasBatch.width, c.canvasBatch.height);
|
|
6948
7001
|
break;
|
|
7002
|
+
case DisplayCommandType::DrawSvg:
|
|
7003
|
+
#if GEA_UI_SVG
|
|
7004
|
+
svg::paint(c);
|
|
7005
|
+
#endif
|
|
7006
|
+
break;
|
|
6949
7007
|
case DisplayCommandType::BlitImageProjected:
|
|
6950
7008
|
drawProjectedImage(c);
|
|
6951
7009
|
break;
|
|
@@ -7041,6 +7099,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
7041
7099
|
break;
|
|
7042
7100
|
case DisplayCommandType::BlitImage:
|
|
7043
7101
|
case DisplayCommandType::ReplayCanvasBatch:
|
|
7102
|
+
case DisplayCommandType::DrawSvg:
|
|
7044
7103
|
case DisplayCommandType::BlitImageProjected:
|
|
7045
7104
|
case DisplayCommandType::BlitImageScaled:
|
|
7046
7105
|
GEA_REFRESH_PERF(__perf.treeReplayImageUs += __replayDt);
|
|
@@ -7334,6 +7393,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
7334
7393
|
{
|
|
7335
7394
|
CanvasRenderer::record(*n);
|
|
7336
7395
|
}
|
|
7396
|
+
#if GEA_UI_SVG
|
|
7397
|
+
else if (paintsOwnBox && svg::isRoot(*n))
|
|
7398
|
+
{
|
|
7399
|
+
svg::record(*n);
|
|
7400
|
+
}
|
|
7401
|
+
#endif
|
|
7337
7402
|
else if (paintsOwnBox && n->type == NodeType::Camera)
|
|
7338
7403
|
{
|
|
7339
7404
|
CameraRenderer::record(*n);
|
|
@@ -7850,6 +7915,22 @@ int gLastScrollUiFrame = -1000;
|
|
|
7850
7915
|
}
|
|
7851
7916
|
};
|
|
7852
7917
|
|
|
7918
|
+
// The commands one region's strips replay (DisplayCommandReplayer::
|
|
7919
|
+
// buildRegionIndex). The list itself lives in PSRAM, and a strip-by-strip
|
|
7920
|
+
// replay walked all of it per 24-row strip: ~800 commands, ~1.1 ms a strip,
|
|
7921
|
+
// about a third of a CrowPanel chart scroll frame.
|
|
7922
|
+
// Sized to the list on demand (a static of kMaxCommands took 32 KB of
|
|
7923
|
+
// PSRAM, which the CrowPanel app could not spare).
|
|
7924
|
+
static std::uint16_t *gRegionIndex = nullptr;
|
|
7925
|
+
static int gRegionIndexCapacity = 0;
|
|
7926
|
+
// Per thread: the render worker replays bands on the other core while the
|
|
7927
|
+
// list is active, and must walk the whole list as before.
|
|
7928
|
+
static thread_local int gRegionIndexCount = -1;
|
|
7929
|
+
// The clip the list was filtered under: a replay under any clip inside it
|
|
7930
|
+
// may use the list, any other walks the whole list.
|
|
7931
|
+
static thread_local int gRegionX0, gRegionY0, gRegionX1, gRegionY1;
|
|
7932
|
+
static thread_local bool gRegionCovered = false;
|
|
7933
|
+
|
|
7853
7934
|
struct DisplayCommandReplayer
|
|
7854
7935
|
{
|
|
7855
7936
|
static bool transformedRoundedRectPaintsRegion(const DisplayCommand &command, int x0, int y0, int x1, int y1)
|
|
@@ -7947,6 +8028,75 @@ int gLastScrollUiFrame = -1000;
|
|
|
7947
8028
|
y1);
|
|
7948
8029
|
}
|
|
7949
8030
|
|
|
8031
|
+
// What state.drawNodeBBox (one packed box per draw-order slot) holds. The
|
|
8032
|
+
// simple dirty replay keeps node layout boxes there; the region replays
|
|
8033
|
+
// below keep the union of each node's command boxes there instead, for one
|
|
8034
|
+
// replay scope (beginSimpleReplayScope..endSimpleReplayScope, inside which
|
|
8035
|
+
// the tree and the display list hold still). A frame takes one path or the
|
|
8036
|
+
// other, and whichever fills the mirror marks the other's contents stale.
|
|
8037
|
+
// No new memory: PSRAM on the 800x480 panels has no 10 KB to spare.
|
|
8038
|
+
static inline std::uint64_t gDrawNodeBBoxLayoutSerial = ~0ull; // serial whose layout boxes it holds
|
|
8039
|
+
static inline bool gDrawNodeBBoxCommandScope = false; // inside a replay scope
|
|
8040
|
+
static inline bool gDrawNodeBBoxHoldsCommandUnions = false; // filled for this scope
|
|
8041
|
+
|
|
8042
|
+
static void fillDrawNodeCommandUnions()
|
|
8043
|
+
{
|
|
8044
|
+
for (int oi = 0; oi < state.drawNodeOrderCount; oi++)
|
|
8045
|
+
{
|
|
8046
|
+
// Empty marker: x0 = INT16_MAX, x1 = INT16_MIN.
|
|
8047
|
+
int bx0 = 32767, by0 = 32767, bx1 = -32768, by1 = -32768;
|
|
8048
|
+
const int id = state.drawNodeOrder[oi];
|
|
8049
|
+
if (state.hasNodeScratchFor(id))
|
|
8050
|
+
{
|
|
8051
|
+
const int start = state.nodeDrawStart[id];
|
|
8052
|
+
const int end = state.nodeDrawEnd[id];
|
|
8053
|
+
if (start >= 0 && end > start && end <= state.commandCount)
|
|
8054
|
+
{
|
|
8055
|
+
bx0 = by0 = INT_MAX;
|
|
8056
|
+
bx1 = by1 = INT_MIN;
|
|
8057
|
+
for (int ci = start; ci < end; ci++)
|
|
8058
|
+
{
|
|
8059
|
+
// Same box arithmetic as commandBBoxOverlapsRegion, degenerate
|
|
8060
|
+
// boxes included, so the union passes every box that test passes.
|
|
8061
|
+
const DisplayCommand &c = state.commands[ci];
|
|
8062
|
+
bx0 = std::min(bx0, static_cast<int>(c.bx));
|
|
8063
|
+
by0 = std::min(by0, static_cast<int>(c.by));
|
|
8064
|
+
bx1 = std::max(bx1, c.bx + c.bw - 1);
|
|
8065
|
+
by1 = std::max(by1, c.by + c.bh - 1);
|
|
8066
|
+
}
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8069
|
+
int16_t *bb = &state.drawNodeBBox[oi * 4];
|
|
8070
|
+
bb[0] = static_cast<int16_t>(std::clamp(bx0, -32768, 32767));
|
|
8071
|
+
bb[1] = static_cast<int16_t>(std::clamp(by0, -32768, 32767));
|
|
8072
|
+
bb[2] = static_cast<int16_t>(std::clamp(bx1, -32768, 32767));
|
|
8073
|
+
bb[3] = static_cast<int16_t>(std::clamp(by1, -32768, 32767));
|
|
8074
|
+
}
|
|
8075
|
+
gDrawNodeBBoxHoldsCommandUnions = true;
|
|
8076
|
+
gDrawNodeBBoxLayoutSerial = ~0ull;
|
|
8077
|
+
}
|
|
8078
|
+
|
|
8079
|
+
// Whether any of the node in draw slot `oi` has a recorded command whose box
|
|
8080
|
+
// reaches the region. The region loops ask it of every node in draw order,
|
|
8081
|
+
// once per region; with every tab page mounted that is ~400 nodes, nearly
|
|
8082
|
+
// all far from the region, so inside a replay scope the answer comes from
|
|
8083
|
+
// the packed union rather than the node's commands scattered through PSRAM.
|
|
8084
|
+
// A miss is exact; a hit on the union may still be a near miss, which
|
|
8085
|
+
// replayNodeCommandRange then turns away command by command.
|
|
8086
|
+
static bool GEA_RENDER_HOT_SRAM nodeCommandsReachRegion(int oi, int node_id, int x0, int y0, int x1, int y1)
|
|
8087
|
+
{
|
|
8088
|
+
if (!state.hasNodeScratchFor(node_id))
|
|
8089
|
+
return false;
|
|
8090
|
+
if (!gDrawNodeBBoxCommandScope || !state.drawNodeBBox)
|
|
8091
|
+
return commandRangeBBoxOverlaps(state.nodeDrawStart[node_id], state.nodeDrawEnd[node_id], x0, y0, x1, y1);
|
|
8092
|
+
if (!gDrawNodeBBoxHoldsCommandUnions)
|
|
8093
|
+
fillDrawNodeCommandUnions();
|
|
8094
|
+
const int16_t *bb = &state.drawNodeBBox[oi * 4];
|
|
8095
|
+
if (bb[0] == 32767 && bb[2] == -32768)
|
|
8096
|
+
return false;
|
|
8097
|
+
return ClipMath::rectsOverlap(bb[0], bb[1], bb[2], bb[3], x0, y0, x1, y1);
|
|
8098
|
+
}
|
|
8099
|
+
|
|
7950
8100
|
static bool commandRangeOverlaps(int start, int end, int x0, int y0, int x1, int y1)
|
|
7951
8101
|
{
|
|
7952
8102
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
@@ -7985,6 +8135,58 @@ int gLastScrollUiFrame = -1000;
|
|
|
7985
8135
|
return false;
|
|
7986
8136
|
}
|
|
7987
8137
|
|
|
8138
|
+
// nodeHasTransformChain for every node of one pass: each node's own state is
|
|
8139
|
+
// tested once and each answer reused by its descendants, where asking per node
|
|
8140
|
+
// walks every ancestor chain again (N x depth tests of the 20-field state).
|
|
8141
|
+
// Bit 0: some node on the chain to the root (self included) holds transform
|
|
8142
|
+
// state; bit 1: this node itself does. Valid only while the tree is unchanged.
|
|
8143
|
+
struct TransformChainMemo
|
|
8144
|
+
{
|
|
8145
|
+
std::vector<std::int8_t> memo;
|
|
8146
|
+
std::vector<int> path;
|
|
8147
|
+
// With no transform anywhere this frame or last (the cached whole-tree scan
|
|
8148
|
+
// every transform path consults), every answer is 0 without a node read.
|
|
8149
|
+
bool none = false;
|
|
8150
|
+
void reset(int nodeCount)
|
|
8151
|
+
{
|
|
8152
|
+
none = !ViewRenderer::anyTransformActive();
|
|
8153
|
+
if (!none)
|
|
8154
|
+
memo.assign(static_cast<std::size_t>(nodeCount), -1);
|
|
8155
|
+
}
|
|
8156
|
+
int at(int node_id, Node *nodes, int nodeCount)
|
|
8157
|
+
{
|
|
8158
|
+
if (none)
|
|
8159
|
+
return 0;
|
|
8160
|
+
path.clear();
|
|
8161
|
+
int cursor = node_id;
|
|
8162
|
+
int above = 0;
|
|
8163
|
+
while (cursor >= 0 && cursor < nodeCount)
|
|
8164
|
+
{
|
|
8165
|
+
if (memo[cursor] >= 0)
|
|
8166
|
+
{
|
|
8167
|
+
above = memo[cursor] & 1;
|
|
8168
|
+
break;
|
|
8169
|
+
}
|
|
8170
|
+
path.push_back(cursor);
|
|
8171
|
+
cursor = nodes[cursor].parent;
|
|
8172
|
+
}
|
|
8173
|
+
for (int k = static_cast<int>(path.size()) - 1; k >= 0; --k)
|
|
8174
|
+
{
|
|
8175
|
+
const int self = hasRetainedTransformState(nodes[path[k]]) ? 1 : 0;
|
|
8176
|
+
above |= self;
|
|
8177
|
+
memo[path[k]] = static_cast<std::int8_t>(above | (self << 1));
|
|
8178
|
+
}
|
|
8179
|
+
return memo[node_id];
|
|
8180
|
+
}
|
|
8181
|
+
bool retained(int node_id, Node *nodes, int nodeCount) { return (at(node_id, nodes, nodeCount) & 2) != 0; }
|
|
8182
|
+
bool chain(int node_id, Node *nodes, int nodeCount) { return (at(node_id, nodes, nodeCount) & 1) != 0; }
|
|
8183
|
+
};
|
|
8184
|
+
static TransformChainMemo &transformChainMemo()
|
|
8185
|
+
{
|
|
8186
|
+
static TransformChainMemo memo;
|
|
8187
|
+
return memo;
|
|
8188
|
+
}
|
|
8189
|
+
|
|
7988
8190
|
static bool nodeRecordsOverflowClip(int node_id, Node *nodes, int nodeCount)
|
|
7989
8191
|
{
|
|
7990
8192
|
if (node_id < 0 || node_id >= nodeCount)
|
|
@@ -8045,6 +8247,93 @@ int gLastScrollUiFrame = -1000;
|
|
|
8045
8247
|
return pushed;
|
|
8046
8248
|
}
|
|
8047
8249
|
|
|
8250
|
+
// The ancestor chain of the node replayNodeCommandRange last resolved, root
|
|
8251
|
+
// first, with what pushNodeReplayClips and effectiveAlphaForNode read at
|
|
8252
|
+
// each level. Those walk every ancestor's style for each node replayed, and
|
|
8253
|
+
// draw order is depth-first, so the next node's chain is almost all this
|
|
8254
|
+
// one: only the levels below the shared ancestor are read again. The tree
|
|
8255
|
+
// holds still inside a replay scope, the only place this is used (it is
|
|
8256
|
+
// emptied when one opens); the answers match the two walks exactly.
|
|
8257
|
+
struct ReplayChainMemo
|
|
8258
|
+
{
|
|
8259
|
+
int depth; // zero-initialized (static storage)
|
|
8260
|
+
int id[kScratchDepth];
|
|
8261
|
+
std::uint8_t alpha[kScratchDepth]; // opacity product, root..level, as effectiveAlphaForNode folds it
|
|
8262
|
+
bool fixed[kScratchDepth]; // LayoutEngine::isViewportFixed
|
|
8263
|
+
bool clips[kScratchDepth]; // nodeRecordsOverflowClip
|
|
8264
|
+
int clip[kScratchDepth][4]; // its overflowClipBounds
|
|
8265
|
+
};
|
|
8266
|
+
static inline ReplayChainMemo gReplayChain;
|
|
8267
|
+
|
|
8268
|
+
// Brings gReplayChain to `node_id`'s chain. False when the chain is deeper
|
|
8269
|
+
// than the walks allow (they give up there); the caller then uses them.
|
|
8270
|
+
static bool GEA_RENDER_HOT_SRAM resolveReplayChain(int node_id, Node *nodes, int nodeCount)
|
|
8271
|
+
{
|
|
8272
|
+
auto &m = gReplayChain;
|
|
8273
|
+
int below[kScratchDepth]; // node_id and the ancestors not in the memo, leaf first
|
|
8274
|
+
int belowCount = 0;
|
|
8275
|
+
int keep = 0; // memo levels that stay: the shared ancestor's chain
|
|
8276
|
+
for (int cursor = node_id; cursor >= 0 && cursor < nodeCount; cursor = nodes[cursor].parent)
|
|
8277
|
+
{
|
|
8278
|
+
int level = -1;
|
|
8279
|
+
for (int k = m.depth - 1; k >= 0; --k)
|
|
8280
|
+
if (m.id[k] == cursor)
|
|
8281
|
+
{
|
|
8282
|
+
level = k;
|
|
8283
|
+
break;
|
|
8284
|
+
}
|
|
8285
|
+
if (level >= 0)
|
|
8286
|
+
{
|
|
8287
|
+
keep = level + 1;
|
|
8288
|
+
break;
|
|
8289
|
+
}
|
|
8290
|
+
if (belowCount >= kScratchDepth)
|
|
8291
|
+
return false;
|
|
8292
|
+
below[belowCount++] = cursor;
|
|
8293
|
+
}
|
|
8294
|
+
if (keep + belowCount > kScratchDepth)
|
|
8295
|
+
return false;
|
|
8296
|
+
m.depth = keep;
|
|
8297
|
+
for (int i = belowCount - 1; i >= 0; --i)
|
|
8298
|
+
{
|
|
8299
|
+
const int id = below[i];
|
|
8300
|
+
const int k = m.depth++;
|
|
8301
|
+
const int parentAlpha = k > 0 ? m.alpha[k - 1] : 255;
|
|
8302
|
+
m.id[k] = id;
|
|
8303
|
+
m.alpha[k] = static_cast<std::uint8_t>((parentAlpha * static_cast<int>(nodes[id].computedStyle().opacity)) / 255);
|
|
8304
|
+
m.fixed[k] = LayoutEngine::isViewportFixed(nodes[id]);
|
|
8305
|
+
m.clips[k] = nodeRecordsOverflowClip(id, nodes, nodeCount);
|
|
8306
|
+
if (m.clips[k])
|
|
8307
|
+
{
|
|
8308
|
+
overflowClipBounds(nodes[id], m.clip[k][0], m.clip[k][1], m.clip[k][2], m.clip[k][3]);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
return m.depth > 0;
|
|
8312
|
+
}
|
|
8313
|
+
|
|
8314
|
+
// pushNodeReplayClips from the resolved chain: the clipping ancestors from
|
|
8315
|
+
// the nearest viewport-fixed level (the node's own included) down to its parent.
|
|
8316
|
+
static int GEA_RENDER_HOT_SRAM pushReplayChainClips()
|
|
8317
|
+
{
|
|
8318
|
+
const auto &m = gReplayChain;
|
|
8319
|
+
int first = 0;
|
|
8320
|
+
for (int k = m.depth - 1; k >= 0; --k)
|
|
8321
|
+
if (m.fixed[k])
|
|
8322
|
+
{
|
|
8323
|
+
first = k;
|
|
8324
|
+
break;
|
|
8325
|
+
}
|
|
8326
|
+
int pushed = 0;
|
|
8327
|
+
for (int k = first; k < m.depth - 1; ++k)
|
|
8328
|
+
{
|
|
8329
|
+
if (!m.clips[k])
|
|
8330
|
+
continue;
|
|
8331
|
+
gea::platform::display::Display::pushClip(m.clip[k][0], m.clip[k][1], m.clip[k][2], m.clip[k][3]);
|
|
8332
|
+
pushed++;
|
|
8333
|
+
}
|
|
8334
|
+
return pushed;
|
|
8335
|
+
}
|
|
8336
|
+
|
|
8048
8337
|
static void replayCommandRange(int start, int end, int x0, int y0, int x1, int y1, UniformRoundedRectBatch &roundedRects)
|
|
8049
8338
|
{
|
|
8050
8339
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
@@ -8120,11 +8409,13 @@ int gLastScrollUiFrame = -1000;
|
|
|
8120
8409
|
// content-only frames (markNodeDisplayCommandsDirty patches a node's commands
|
|
8121
8410
|
// without a full re-record), so a moved absolute leaf would carry a stale bbox
|
|
8122
8411
|
// here and get wrongly AABB-skipped in the chunk it actually occupies.
|
|
8123
|
-
|
|
8412
|
+
// The region replays may have left command unions in the mirror
|
|
8413
|
+
// (gDrawNodeBBoxLayoutSerial says whose boxes it holds).
|
|
8124
8414
|
const std::uint64_t serial = tree.refreshSerial();
|
|
8125
|
-
if (
|
|
8415
|
+
if (gDrawNodeBBoxLayoutSerial == serial)
|
|
8126
8416
|
return;
|
|
8127
|
-
|
|
8417
|
+
gDrawNodeBBoxLayoutSerial = serial;
|
|
8418
|
+
gDrawNodeBBoxHoldsCommandUnions = false;
|
|
8128
8419
|
for (int oi = 0; oi < state.drawNodeOrderCount; oi++)
|
|
8129
8420
|
{
|
|
8130
8421
|
const int id = state.drawNodeOrder[oi];
|
|
@@ -8185,7 +8476,151 @@ int gLastScrollUiFrame = -1000;
|
|
|
8185
8476
|
}
|
|
8186
8477
|
};
|
|
8187
8478
|
|
|
8479
|
+
// The simple-replay verdict walks every node and every command, and the
|
|
8480
|
+
// unified flush asks it once per dirty region: on a busy screen (Analytics,
|
|
8481
|
+
// 238 nodes, 8 regions) that walk was ~5 ms a region, most of the frame's
|
|
8482
|
+
// replay. Only the transformed-ink test depends on the region, so inside a
|
|
8483
|
+
// replay scope -- the display list and tree held still -- the rest is
|
|
8484
|
+
// computed once and the region test runs over the transformed nodes alone.
|
|
8485
|
+
struct SimpleReplayVerdictCache
|
|
8486
|
+
{
|
|
8487
|
+
static constexpr int kMaxTransformed = 64;
|
|
8488
|
+
int scopeDepth = 0;
|
|
8489
|
+
bool valid = false;
|
|
8490
|
+
int width = 0;
|
|
8491
|
+
int height = 0;
|
|
8492
|
+
bool baseOk = false; // every region-independent check passed
|
|
8493
|
+
bool anyRetainedTransform = false; // fails a region-less query
|
|
8494
|
+
bool transformOverflow = false; // too many transformed nodes to list
|
|
8495
|
+
bool transformMissingScratch = false;
|
|
8496
|
+
int transformedCount = 0;
|
|
8497
|
+
int transformed[kMaxTransformed];
|
|
8498
|
+
};
|
|
8499
|
+
static SimpleReplayVerdictCache &simpleReplayVerdictCache()
|
|
8500
|
+
{
|
|
8501
|
+
static SimpleReplayVerdictCache cache;
|
|
8502
|
+
return cache;
|
|
8503
|
+
}
|
|
8504
|
+
|
|
8505
|
+
static void beginSimpleReplayScope()
|
|
8506
|
+
{
|
|
8507
|
+
auto &cache = simpleReplayVerdictCache();
|
|
8508
|
+
if (cache.scopeDepth++ == 0)
|
|
8509
|
+
{
|
|
8510
|
+
cache.valid = false;
|
|
8511
|
+
gDrawNodeBBoxCommandScope = true;
|
|
8512
|
+
gDrawNodeBBoxHoldsCommandUnions = false;
|
|
8513
|
+
gReplayChain.depth = 0;
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
|
|
8517
|
+
static void endSimpleReplayScope()
|
|
8518
|
+
{
|
|
8519
|
+
auto &cache = simpleReplayVerdictCache();
|
|
8520
|
+
if (cache.scopeDepth > 0 && --cache.scopeDepth == 0)
|
|
8521
|
+
{
|
|
8522
|
+
cache.valid = false;
|
|
8523
|
+
gDrawNodeBBoxCommandScope = false;
|
|
8524
|
+
gDrawNodeBBoxHoldsCommandUnions = false;
|
|
8525
|
+
gReplayChain.depth = 0;
|
|
8526
|
+
}
|
|
8527
|
+
}
|
|
8528
|
+
|
|
8188
8529
|
static bool canUseSimpleDirtyReplay(int width, int height, const DisplayReplayRegion *regions = nullptr, int count = 0)
|
|
8530
|
+
{
|
|
8531
|
+
auto &cache = simpleReplayVerdictCache();
|
|
8532
|
+
if (cache.scopeDepth <= 0)
|
|
8533
|
+
return canUseSimpleDirtyReplayUncached(width, height, regions, count);
|
|
8534
|
+
if (!cache.valid || cache.width != width || cache.height != height)
|
|
8535
|
+
fillSimpleReplayVerdictCache(width, height);
|
|
8536
|
+
if (cache.transformOverflow)
|
|
8537
|
+
return canUseSimpleDirtyReplayUncached(width, height, regions, count);
|
|
8538
|
+
if (!cache.baseOk)
|
|
8539
|
+
return false;
|
|
8540
|
+
if (cache.transformedCount == 0)
|
|
8541
|
+
return true;
|
|
8542
|
+
// The uncached walk: any retained transform fails a region-less query;
|
|
8543
|
+
// a transform chain only counts once regions are given.
|
|
8544
|
+
if (!regions || count <= 0)
|
|
8545
|
+
return !cache.anyRetainedTransform;
|
|
8546
|
+
if (cache.transformMissingScratch)
|
|
8547
|
+
return false;
|
|
8548
|
+
for (int t = 0; t < cache.transformedCount; ++t)
|
|
8549
|
+
{
|
|
8550
|
+
const int i = cache.transformed[t];
|
|
8551
|
+
for (int ri = 0; ri < count; ++ri)
|
|
8552
|
+
if (commandRangeBBoxOverlaps(state.nodeDrawStart[i], state.nodeDrawEnd[i],
|
|
8553
|
+
regions[ri].x0, regions[ri].y0, regions[ri].x1, regions[ri].y1))
|
|
8554
|
+
return false;
|
|
8555
|
+
}
|
|
8556
|
+
return true;
|
|
8557
|
+
}
|
|
8558
|
+
|
|
8559
|
+
// Region-independent half of canUseSimpleDirtyReplayUncached, plus the list
|
|
8560
|
+
// of nodes its transformed-ink test would visit.
|
|
8561
|
+
static void fillSimpleReplayVerdictCache(int width, int height)
|
|
8562
|
+
{
|
|
8563
|
+
auto &cache = simpleReplayVerdictCache();
|
|
8564
|
+
cache.valid = true;
|
|
8565
|
+
cache.width = width;
|
|
8566
|
+
cache.height = height;
|
|
8567
|
+
cache.baseOk = false;
|
|
8568
|
+
cache.anyRetainedTransform = false;
|
|
8569
|
+
cache.transformOverflow = false;
|
|
8570
|
+
cache.transformMissingScratch = false;
|
|
8571
|
+
cache.transformedCount = 0;
|
|
8572
|
+
if (DisplayList::instance().hasTextClippedBackgrounds())
|
|
8573
|
+
return;
|
|
8574
|
+
Tree &tree = Tree::instance();
|
|
8575
|
+
Node *nodes = tree.nodes();
|
|
8576
|
+
const int nodeCount = tree.nodeCount();
|
|
8577
|
+
auto &chains = transformChainMemo();
|
|
8578
|
+
chains.reset(nodeCount);
|
|
8579
|
+
for (int i = 0; i < nodeCount; i++)
|
|
8580
|
+
{
|
|
8581
|
+
const Node &node = nodes[i];
|
|
8582
|
+
if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0)
|
|
8583
|
+
return;
|
|
8584
|
+
if (node.computedStyle().opacity != 255 && node.computedStyle().opacity != 0)
|
|
8585
|
+
if (!simpleTextAlphaNode(i, nodes, nodeCount))
|
|
8586
|
+
return;
|
|
8587
|
+
if (node.computedStyle().mask_right_fade_width > 0)
|
|
8588
|
+
return;
|
|
8589
|
+
const bool retained = chains.retained(i, nodes, nodeCount);
|
|
8590
|
+
if (chains.chain(i, nodes, nodeCount))
|
|
8591
|
+
{
|
|
8592
|
+
if (retained)
|
|
8593
|
+
cache.anyRetainedTransform = true;
|
|
8594
|
+
if (!state.hasNodeScratchFor(i))
|
|
8595
|
+
cache.transformMissingScratch = true;
|
|
8596
|
+
else if (cache.transformedCount < SimpleReplayVerdictCache::kMaxTransformed)
|
|
8597
|
+
cache.transformed[cache.transformedCount++] = i;
|
|
8598
|
+
else
|
|
8599
|
+
cache.transformOverflow = true;
|
|
8600
|
+
}
|
|
8601
|
+
}
|
|
8602
|
+
// A transformed node without scratch fails every query, region-less ones
|
|
8603
|
+
// included (it is listed so the region-less path sees a transform).
|
|
8604
|
+
if (cache.transformMissingScratch && cache.transformedCount == 0)
|
|
8605
|
+
cache.transformed[cache.transformedCount++] = 0;
|
|
8606
|
+
for (int ci = 0; ci < state.commandCount; ci++)
|
|
8607
|
+
{
|
|
8608
|
+
const DisplayCommand &command = state.commands[ci];
|
|
8609
|
+
const bool plainTextAlpha = command.type == DisplayCommandType::SetAlpha &&
|
|
8610
|
+
command.alpha.recordParentAlpha == 255 &&
|
|
8611
|
+
simpleTextAlphaNode(command.alpha.nodeId, nodes, nodeCount);
|
|
8612
|
+
if ((command.type == DisplayCommandType::SetAlpha && command.alpha.alpha != 255 && !plainTextAlpha) ||
|
|
8613
|
+
command.type == DisplayCommandType::BeginFilterBlur ||
|
|
8614
|
+
command.type == DisplayCommandType::ApplyFilterBlur)
|
|
8615
|
+
return;
|
|
8616
|
+
if (command.type == DisplayCommandType::PushClip &&
|
|
8617
|
+
!clipCoversViewport(command, width, height))
|
|
8618
|
+
return;
|
|
8619
|
+
}
|
|
8620
|
+
cache.baseOk = true;
|
|
8621
|
+
}
|
|
8622
|
+
|
|
8623
|
+
static bool canUseSimpleDirtyReplayUncached(int width, int height, const DisplayReplayRegion *regions, int count)
|
|
8189
8624
|
{
|
|
8190
8625
|
if (DisplayList::instance().hasTextClippedBackgrounds()) return false;
|
|
8191
8626
|
#if GEA_EMBEDDED_SIMPLE_REPLAY_DEBUG
|
|
@@ -8198,6 +8633,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
8198
8633
|
Tree &tree = Tree::instance();
|
|
8199
8634
|
Node *nodes = tree.nodes();
|
|
8200
8635
|
const int nodeCount = tree.nodeCount();
|
|
8636
|
+
auto &chains = transformChainMemo();
|
|
8637
|
+
chains.reset(nodeCount);
|
|
8201
8638
|
for (int i = 0; i < nodeCount; i++)
|
|
8202
8639
|
{
|
|
8203
8640
|
const Node &node = nodes[i];
|
|
@@ -8208,7 +8645,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
8208
8645
|
{ SRDBG("opacity node", i); return false; }
|
|
8209
8646
|
if (node.computedStyle().mask_right_fade_width > 0)
|
|
8210
8647
|
{ SRDBG("mask node", i); return false; }
|
|
8211
|
-
if (
|
|
8648
|
+
if (chains.retained(i, nodes, nodeCount) || (regions && chains.chain(i, nodes, nodeCount)))
|
|
8212
8649
|
{
|
|
8213
8650
|
if (!regions || count <= 0 || !state.hasNodeScratchFor(i))
|
|
8214
8651
|
{ SRDBG("transform node", i); return false; }
|
|
@@ -8616,19 +9053,37 @@ int gLastScrollUiFrame = -1000;
|
|
|
8616
9053
|
const int nodeCount = tree.nodeCount();
|
|
8617
9054
|
if (node_id < 0 || node_id >= nodeCount)
|
|
8618
9055
|
return;
|
|
8619
|
-
if (retainedBackgroundNodeCanBeSkippedInRegion(node_id, x0, y0, x1, y1))
|
|
8620
|
-
return;
|
|
8621
9056
|
if (!state.hasNodeScratchFor(node_id))
|
|
8622
9057
|
return;
|
|
8623
9058
|
const int start = state.nodeDrawStart[node_id];
|
|
8624
9059
|
const int end = state.nodeDrawEnd[node_id];
|
|
8625
9060
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
8626
9061
|
return;
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
9062
|
+
// A node none of whose commands reach the region paints nothing in it
|
|
9063
|
+
// (the loop below filters every draw by the same box), so skip its
|
|
9064
|
+
// ancestor clip and opacity walks too, as the multi-region path does.
|
|
9065
|
+
// With every tab page mounted the draw order holds ~400 nodes, and
|
|
9066
|
+
// those walks for each of them in each of a frame's ~7 small regions
|
|
9067
|
+
// were most of the CrowPanel Analytics meters' replay time.
|
|
9068
|
+
if (!commandRangeBBoxOverlaps(start, end, x0, y0, x1, y1))
|
|
8630
9069
|
return;
|
|
8631
|
-
|
|
9070
|
+
if (retainedBackgroundNodeCanBeSkippedInRegion(node_id, x0, y0, x1, y1))
|
|
9071
|
+
return;
|
|
9072
|
+
|
|
9073
|
+
int pushedClips;
|
|
9074
|
+
std::uint8_t alpha;
|
|
9075
|
+
if (gDrawNodeBBoxCommandScope && resolveReplayChain(node_id, nodes, nodeCount))
|
|
9076
|
+
{
|
|
9077
|
+
pushedClips = pushReplayChainClips();
|
|
9078
|
+
alpha = gReplayChain.alpha[gReplayChain.depth - 1];
|
|
9079
|
+
}
|
|
9080
|
+
else
|
|
9081
|
+
{
|
|
9082
|
+
pushedClips = pushNodeReplayClips(node_id, nodes, nodeCount);
|
|
9083
|
+
if (pushedClips < 0)
|
|
9084
|
+
return;
|
|
9085
|
+
alpha = effectiveAlphaForNode(node_id, nodes, nodeCount);
|
|
9086
|
+
}
|
|
8632
9087
|
const bool stateChanged = pushedClips > 0 || alpha != 255;
|
|
8633
9088
|
if (stateChanged)
|
|
8634
9089
|
{
|
|
@@ -8745,6 +9200,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
8745
9200
|
int node_id = state.drawNodeOrder[oi];
|
|
8746
9201
|
if (node_id < 0 || node_id >= tree.nodeCount())
|
|
8747
9202
|
continue;
|
|
9203
|
+
// The command boxes first: they are what replayNodeCommandRange filters
|
|
9204
|
+
// by, ancestors included (one that reaches no pixel of the region paints
|
|
9205
|
+
// none), and most of the ~400 nodes reach none, so they are turned away
|
|
9206
|
+
// before their Node is read.
|
|
9207
|
+
if (!nodeCommandsReachRegion(oi, node_id, x0, y0, x1, y1))
|
|
9208
|
+
continue;
|
|
8748
9209
|
Node *n = &nodes[node_id];
|
|
8749
9210
|
if (n->computedStyle().display == 1)
|
|
8750
9211
|
continue;
|
|
@@ -8759,11 +9220,6 @@ int gLastScrollUiFrame = -1000;
|
|
|
8759
9220
|
!nodeOrAncestorRenderDirty(node_id, nodes, tree.nodeCount()))
|
|
8760
9221
|
continue;
|
|
8761
9222
|
|
|
8762
|
-
const int start = state.nodeDrawStart[node_id];
|
|
8763
|
-
const int end = state.nodeDrawEnd[node_id];
|
|
8764
|
-
const bool isAncestor = nodeInList(node_id, ancestors, ancestorCount);
|
|
8765
|
-
if (!isAncestor && !commandRangeBBoxOverlaps(start, end, x0, y0, x1, y1))
|
|
8766
|
-
continue;
|
|
8767
9223
|
replayNodeCommandRange(node_id, x0, y0, x1, y1, roundedRects);
|
|
8768
9224
|
}
|
|
8769
9225
|
roundedRects.flush();
|
|
@@ -8794,6 +9250,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
8794
9250
|
const int savedH = canvas->height();
|
|
8795
9251
|
const int savedStride = canvas->strideBytes() / static_cast<int>(sizeof(gea::framework::graphics::pixel::native_t));
|
|
8796
9252
|
const std::uint8_t savedAlpha = gea::platform::display::Display::alpha();
|
|
9253
|
+
// bindPixels clears the scroll region; a ring-scrolling display keeps its
|
|
9254
|
+
// framebuffer rows rotated across frames, so drawing on after the bake
|
|
9255
|
+
// without the region would land in the wrong rows.
|
|
9256
|
+
const int savedRegionY = canvas->scrollRegionY();
|
|
9257
|
+
const int savedRegionH = canvas->scrollRegionH();
|
|
9258
|
+
const int savedRegionOffset = canvas->scrollOffsetY();
|
|
8797
9259
|
|
|
8798
9260
|
gBackdropBaking = true;
|
|
8799
9261
|
canvas->bindPixels(bg, width, height, width);
|
|
@@ -8830,6 +9292,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
8830
9292
|
gea::platform::display::Display::popClip();
|
|
8831
9293
|
|
|
8832
9294
|
canvas->bindPixels(savedPixels, savedW, savedH, savedStride);
|
|
9295
|
+
if (savedRegionH > 0)
|
|
9296
|
+
canvas->setScrollRegion(savedRegionY, savedRegionH, savedRegionOffset);
|
|
8833
9297
|
canvas->resetDirty();
|
|
8834
9298
|
gea::platform::display::Display::resetClip();
|
|
8835
9299
|
gea::platform::display::Display::setAlpha(savedAlpha);
|
|
@@ -8852,6 +9316,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
8852
9316
|
constexpr int kMinPixelsToSplitFrame = GEA_EMBEDDED_RENDER_PARALLEL_MIN_PIXELS;
|
|
8853
9317
|
const int regionW = x1 - x0 + 1;
|
|
8854
9318
|
const int regionH = y1 - y0 + 1;
|
|
9319
|
+
// Staging runs on this core's strip; a band handed to the other core
|
|
9320
|
+
// could not stage, so a bulk-staged region is not split.
|
|
9321
|
+
const int stageRows = gea_replay_stage_active() ? 0 : replayStageRowsForArea(static_cast<long>(regionW) * regionH);
|
|
9322
|
+
if (stageRows > 0 && gea_replay_stage_rows() <= 0)
|
|
9323
|
+
allowSplit = false;
|
|
8855
9324
|
if (GEA_EMBEDDED_RENDER_PARALLEL_DIRTY_REPLAY && GEA_RENDER_SPLIT_ALLOWED && allowSplit && regionW > 0 && regionH >= kMinRowsToSplitFrame &&
|
|
8856
9325
|
regionW * regionH >= kMinPixelsToSplitFrame)
|
|
8857
9326
|
{
|
|
@@ -8888,7 +9357,6 @@ int gLastScrollUiFrame = -1000;
|
|
|
8888
9357
|
// byte-identical to the direct path for any scene. Composes with the 2-core
|
|
8889
9358
|
// band split above: each band re-enters here with allowSplit=false and
|
|
8890
9359
|
// strip-stages its own rows on its own core.
|
|
8891
|
-
const int stageRows = gea_replay_stage_rows();
|
|
8892
9360
|
if (stageRows > 0)
|
|
8893
9361
|
{
|
|
8894
9362
|
for (int sy0 = y0; sy0 <= y1; sy0 += stageRows)
|
|
@@ -9024,6 +9492,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
9024
9492
|
continue;
|
|
9025
9493
|
if (!state.hasNodeScratchFor(node_id))
|
|
9026
9494
|
continue;
|
|
9495
|
+
// A node whose commands reach none of the region covers none of it;
|
|
9496
|
+
// inside a replay scope the packed union says so without the command.
|
|
9497
|
+
if (gDrawNodeBBoxCommandScope && !nodeCommandsReachRegion(oi, node_id, x0, y0, x1, y1))
|
|
9498
|
+
continue;
|
|
9027
9499
|
const int start = state.nodeDrawStart[node_id];
|
|
9028
9500
|
const int end = state.nodeDrawEnd[node_id];
|
|
9029
9501
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
@@ -9048,6 +9520,18 @@ int gLastScrollUiFrame = -1000;
|
|
|
9048
9520
|
spanX1 = c.blit.dx + c.blit.sourceWidth - 1;
|
|
9049
9521
|
}
|
|
9050
9522
|
}
|
|
9523
|
+
// A rounded card covers a region that lies inside its corners (one
|
|
9524
|
+
// pixel of slack: an edge pixel can still be antialiased), the same
|
|
9525
|
+
// rule regionHasOpaqueBase uses. Without it every dirty region on a
|
|
9526
|
+
// card replayed the page backgrounds underneath it as well.
|
|
9527
|
+
else if (c.type == DisplayCommandType::FillRoundedRect)
|
|
9528
|
+
{
|
|
9529
|
+
if (regionInsideRetainedBackground(c, x0 - 1, y0 - 1, x1 + 1, y1 + 1))
|
|
9530
|
+
{
|
|
9531
|
+
spanX0 = x0;
|
|
9532
|
+
spanX1 = x1;
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9051
9535
|
if (spanX0 < x0)
|
|
9052
9536
|
spanX0 = x0;
|
|
9053
9537
|
if (spanX1 > x1)
|
|
@@ -9149,6 +9633,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
9149
9633
|
int node_id = state.drawNodeOrder[oi];
|
|
9150
9634
|
if (node_id < 0 || node_id >= tree.nodeCount())
|
|
9151
9635
|
continue;
|
|
9636
|
+
if (!nodeCommandsReachRegion(oi, node_id, x0, y0, x1, y1)) // before the Node is read
|
|
9637
|
+
continue;
|
|
9152
9638
|
Node *n = &nodes[node_id];
|
|
9153
9639
|
if (n->computedStyle().display == 1)
|
|
9154
9640
|
continue;
|
|
@@ -9368,7 +9854,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9368
9854
|
gea::platform::display::Display::setAlpha(255);
|
|
9369
9855
|
}
|
|
9370
9856
|
|
|
9371
|
-
static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count, bool allowSplit = true)
|
|
9857
|
+
static void GEA_RENDER_HOT_SRAM replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count, bool allowSplit = true, bool allowStage = true)
|
|
9372
9858
|
{
|
|
9373
9859
|
GEA_REFRESH_PERF(refreshPerfStatsMutable().treeReplayDirectRegionsCalls++);
|
|
9374
9860
|
if (!regions || count <= 0)
|
|
@@ -9390,6 +9876,74 @@ int gLastScrollUiFrame = -1000;
|
|
|
9390
9876
|
regions[0].origin);
|
|
9391
9877
|
return;
|
|
9392
9878
|
}
|
|
9879
|
+
// SRAM-staged strips, as replayDirectDirtyRegion does for one region:
|
|
9880
|
+
// several regions (a scroll's exposed band plus ticking content) otherwise
|
|
9881
|
+
// draw straight into a framebuffer the panel is scanning, and their fills
|
|
9882
|
+
// at full speed, from both cores, starved the RGB panel's bounce refills.
|
|
9883
|
+
// Each strip stages the bbox of the regions clipped to it and replays them
|
|
9884
|
+
// there -- the same per-band clipping the 2-core split below applies, so
|
|
9885
|
+
// the pixels are the same. Inside a strip the stage is active, so the
|
|
9886
|
+
// nested calls draw into it.
|
|
9887
|
+
constexpr int kMaxStagedRegions = 32;
|
|
9888
|
+
long stageArea = 0;
|
|
9889
|
+
for (int i = 0; i < count; i++)
|
|
9890
|
+
if (regions[i].x0 <= regions[i].x1 && regions[i].y0 <= regions[i].y1)
|
|
9891
|
+
stageArea += static_cast<long>(regions[i].x1 - regions[i].x0 + 1) * (regions[i].y1 - regions[i].y0 + 1);
|
|
9892
|
+
const int stageRows = replayStageRowsForArea(stageArea);
|
|
9893
|
+
if (allowStage && stageRows > 0 && count <= kMaxStagedRegions && !gea_replay_stage_active())
|
|
9894
|
+
{
|
|
9895
|
+
int minY = 0x7fffffff, maxY = -0x7fffffff;
|
|
9896
|
+
for (int i = 0; i < count; i++)
|
|
9897
|
+
{
|
|
9898
|
+
if (regions[i].x0 > regions[i].x1 || regions[i].y0 > regions[i].y1)
|
|
9899
|
+
continue;
|
|
9900
|
+
minY = std::min(minY, regions[i].y0);
|
|
9901
|
+
maxY = std::max(maxY, regions[i].y1);
|
|
9902
|
+
}
|
|
9903
|
+
for (int sy0 = minY; sy0 <= maxY; sy0 += stageRows)
|
|
9904
|
+
{
|
|
9905
|
+
const int sy1 = std::min(maxY, sy0 + stageRows - 1);
|
|
9906
|
+
DisplayReplayRegion strip[kMaxStagedRegions];
|
|
9907
|
+
int n = 0;
|
|
9908
|
+
int bx0 = 0x7fffffff, by0 = 0x7fffffff, bx1 = -0x7fffffff, by1 = -0x7fffffff;
|
|
9909
|
+
for (int i = 0; i < count; i++)
|
|
9910
|
+
{
|
|
9911
|
+
DisplayReplayRegion r = regions[i];
|
|
9912
|
+
if (r.x0 > r.x1)
|
|
9913
|
+
continue;
|
|
9914
|
+
r.y0 = std::max(r.y0, sy0);
|
|
9915
|
+
r.y1 = std::min(r.y1, sy1);
|
|
9916
|
+
if (r.y0 > r.y1)
|
|
9917
|
+
continue;
|
|
9918
|
+
strip[n++] = r;
|
|
9919
|
+
bx0 = std::min(bx0, r.x0);
|
|
9920
|
+
by0 = std::min(by0, r.y0);
|
|
9921
|
+
bx1 = std::max(bx1, r.x1);
|
|
9922
|
+
by1 = std::max(by1, r.y1);
|
|
9923
|
+
}
|
|
9924
|
+
if (n == 0)
|
|
9925
|
+
continue;
|
|
9926
|
+
if (!gea_replay_stage_begin(bx0, by0, bx1, by1))
|
|
9927
|
+
{
|
|
9928
|
+
// No stage: the rest goes straight to the framebuffer, as before.
|
|
9929
|
+
DisplayReplayRegion rest[kMaxStagedRegions];
|
|
9930
|
+
int m = 0;
|
|
9931
|
+
for (int i = 0; i < count; i++)
|
|
9932
|
+
{
|
|
9933
|
+
DisplayReplayRegion r = regions[i];
|
|
9934
|
+
r.y0 = std::max(r.y0, sy0);
|
|
9935
|
+
if (r.x0 <= r.x1 && r.y0 <= r.y1)
|
|
9936
|
+
rest[m++] = r;
|
|
9937
|
+
}
|
|
9938
|
+
if (m > 0)
|
|
9939
|
+
replayDirectDirtyRegions(rest, m, /*allowSplit=*/false, /*allowStage=*/false);
|
|
9940
|
+
return;
|
|
9941
|
+
}
|
|
9942
|
+
replayDirectDirtyRegions(strip, n, /*allowSplit=*/false, /*allowStage=*/false);
|
|
9943
|
+
gea_replay_stage_end();
|
|
9944
|
+
}
|
|
9945
|
+
return;
|
|
9946
|
+
}
|
|
9393
9947
|
constexpr int kMaxRegionSplit = 32;
|
|
9394
9948
|
if (count <= kMaxRegionSplit)
|
|
9395
9949
|
{
|
|
@@ -9533,22 +10087,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
9533
10087
|
roundedRects.flush();
|
|
9534
10088
|
}
|
|
9535
10089
|
|
|
9536
|
-
|
|
10090
|
+
// Occlusion-cull start for the clip now in force (see replay()).
|
|
10091
|
+
static int GEA_RENDER_HOT_SRAM cullStartIndex()
|
|
9537
10092
|
{
|
|
9538
|
-
int cx0 = 0, cy0 = 0, cx1 = 0, cy1 = 0;
|
|
9539
|
-
int clip_dirty = 1;
|
|
9540
|
-
int clip_stack_depth = 0;
|
|
9541
|
-
UniformRoundedRectBatch roundedRects;
|
|
9542
|
-
|
|
9543
|
-
// Occlusion cull against the CALLER's clip (the conservative tree_render
|
|
9544
|
-
// path pushes each dirty rect around a full replay): start at the last
|
|
9545
|
-
// opaque full-cover fill's first command. Unlike the node walks, this
|
|
9546
|
-
// stream carries clip state INLINE, and an orphan PopClip at depth 0
|
|
9547
|
-
// pops the caller's region clip — so only cull when the cover has no
|
|
9548
|
-
// clipping ancestors (whose Pop would run unmatched), the skipped
|
|
9549
|
-
// prefix is Push/Pop balanced, and no filter-blur pair could straddle
|
|
9550
|
-
// the cut.
|
|
9551
10093
|
int startCi = 0;
|
|
10094
|
+
cullCovered = false;
|
|
9552
10095
|
{
|
|
9553
10096
|
int rx0 = 0, ry0 = 0, rx1 = -1, ry1 = -1;
|
|
9554
10097
|
gea::platform::display::Display::clip(&rx0, &ry0, &rx1, &ry1);
|
|
@@ -9574,6 +10117,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9574
10117
|
if (depth >= kCullClipDepth)
|
|
9575
10118
|
{
|
|
9576
10119
|
startCi = 0;
|
|
10120
|
+
cullCovered = false;
|
|
9577
10121
|
break;
|
|
9578
10122
|
}
|
|
9579
10123
|
clipX0[depth] = curX0;
|
|
@@ -9591,6 +10135,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9591
10135
|
if (--depth < 0)
|
|
9592
10136
|
{
|
|
9593
10137
|
startCi = 0;
|
|
10138
|
+
cullCovered = false;
|
|
9594
10139
|
break;
|
|
9595
10140
|
}
|
|
9596
10141
|
curX0 = clipX0[depth];
|
|
@@ -9606,6 +10151,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9606
10151
|
c.type == DisplayCommandType::ApplyFilterBlur)
|
|
9607
10152
|
{
|
|
9608
10153
|
startCi = 0;
|
|
10154
|
+
cullCovered = false;
|
|
9609
10155
|
break;
|
|
9610
10156
|
}
|
|
9611
10157
|
else if (c.type == DisplayCommandType::FillRect && alpha == 255 &&
|
|
@@ -9616,13 +10162,282 @@ int gLastScrollUiFrame = -1000;
|
|
|
9616
10162
|
c.bx + c.bw - 1 >= rx1 && c.by + c.bh - 1 >= ry1)
|
|
9617
10163
|
{
|
|
9618
10164
|
startCi = i;
|
|
10165
|
+
cullCovered = true;
|
|
9619
10166
|
}
|
|
9620
10167
|
}
|
|
9621
10168
|
}
|
|
9622
10169
|
}
|
|
9623
10170
|
|
|
9624
|
-
|
|
10171
|
+
return startCi;
|
|
10172
|
+
}
|
|
10173
|
+
|
|
10174
|
+
// One walk under the clip now in force keeps the clip/alpha commands and
|
|
10175
|
+
// the draws that can land inside it, drops clip scopes that miss it whole,
|
|
10176
|
+
// and finds the occlusion cull start as cullStartIndex() does (a cover
|
|
10177
|
+
// drops the draws kept before it). False (nothing filtered) on a filter
|
|
10178
|
+
// blur, whose backdrop capture depends on draws outside the clip.
|
|
10179
|
+
static bool buildRegionIndex()
|
|
10180
|
+
{
|
|
10181
|
+
gRegionIndexCount = -1;
|
|
10182
|
+
cullCovered = false;
|
|
10183
|
+
int rx0 = 0, ry0 = 0, rx1 = -1, ry1 = -1;
|
|
10184
|
+
gea::platform::display::Display::clip(&rx0, &ry0, &rx1, &ry1);
|
|
10185
|
+
if (rx1 < rx0 || ry1 < ry0) return false;
|
|
10186
|
+
gRegionX0 = rx0; gRegionY0 = ry0; gRegionX1 = rx1; gRegionY1 = ry1;
|
|
10187
|
+
if (gRegionIndexCapacity < state.commandCount)
|
|
10188
|
+
{
|
|
10189
|
+
const int capacity = (state.commandCount + 511) & ~511;
|
|
10190
|
+
void *grown = gea::framework::memory::Allocator::reallocatePreferSpiram(gRegionIndex, sizeof(std::uint16_t) * capacity);
|
|
10191
|
+
if (!grown) return false;
|
|
10192
|
+
gRegionIndex = static_cast<std::uint16_t *>(grown);
|
|
10193
|
+
gRegionIndexCapacity = capacity;
|
|
10194
|
+
}
|
|
10195
|
+
constexpr int kDepth = 64;
|
|
10196
|
+
int clipX0[kDepth], clipY0[kDepth], clipX1[kDepth], clipY1[kDepth], pushCmd[kDepth];
|
|
10197
|
+
int depth = 0, skip = 0, alpha = 255, n = 0, startCi = 0;
|
|
10198
|
+
int pendingAlpha = -1, emittedAlpha = -1;
|
|
10199
|
+
int curX0 = rx0, curY0 = ry0, curX1 = rx1, curY1 = ry1;
|
|
10200
|
+
for (int i = 0; i < state.commandCount; ++i)
|
|
9625
10201
|
{
|
|
10202
|
+
const DisplayCommand &c = state.commands[i];
|
|
10203
|
+
switch (c.type)
|
|
10204
|
+
{
|
|
10205
|
+
case DisplayCommandType::PushClip:
|
|
10206
|
+
{
|
|
10207
|
+
if (skip) { skip++; continue; }
|
|
10208
|
+
const int nx0 = std::max(curX0, static_cast<int>(c.clip.x));
|
|
10209
|
+
const int ny0 = std::max(curY0, static_cast<int>(c.clip.y));
|
|
10210
|
+
const int nx1 = std::min(curX1, static_cast<int>(c.clip.x) + static_cast<int>(c.clip.w) - 1);
|
|
10211
|
+
const int ny1 = std::min(curY1, static_cast<int>(c.clip.y) + static_cast<int>(c.clip.h) - 1);
|
|
10212
|
+
if (nx0 > nx1 || ny0 > ny1) { skip = 1; continue; } // nothing in the scope can show
|
|
10213
|
+
if (depth >= kDepth) return false;
|
|
10214
|
+
clipX0[depth] = curX0; clipY0[depth] = curY0; clipX1[depth] = curX1; clipY1[depth] = curY1;
|
|
10215
|
+
pushCmd[depth] = i;
|
|
10216
|
+
depth++;
|
|
10217
|
+
curX0 = nx0; curY0 = ny0; curX1 = nx1; curY1 = ny1;
|
|
10218
|
+
gRegionIndex[n++] = static_cast<std::uint16_t>(i);
|
|
10219
|
+
continue;
|
|
10220
|
+
}
|
|
10221
|
+
case DisplayCommandType::PopClip:
|
|
10222
|
+
if (skip) { skip--; continue; }
|
|
10223
|
+
if (depth > 0)
|
|
10224
|
+
{
|
|
10225
|
+
depth--;
|
|
10226
|
+
curX0 = clipX0[depth]; curY0 = clipY0[depth]; curX1 = clipX1[depth]; curY1 = clipY1[depth];
|
|
10227
|
+
// A scope that kept no draw is dropped whole (most clip scopes
|
|
10228
|
+
// overlap the region yet draw nothing inside it).
|
|
10229
|
+
if (n > 0 && gRegionIndex[n - 1] == pushCmd[depth]) { n--; continue; }
|
|
10230
|
+
}
|
|
10231
|
+
gRegionIndex[n++] = static_cast<std::uint16_t>(i); // at depth 0 it pops the caller's clip
|
|
10232
|
+
continue;
|
|
10233
|
+
case DisplayCommandType::SetAlpha:
|
|
10234
|
+
// Alpha is one value, not a stack: only the last one before each
|
|
10235
|
+
// kept draw matters (most scopes hold no draw in the region).
|
|
10236
|
+
alpha = c.alpha.alpha;
|
|
10237
|
+
pendingAlpha = i;
|
|
10238
|
+
continue;
|
|
10239
|
+
case DisplayCommandType::BeginFilterBlur:
|
|
10240
|
+
case DisplayCommandType::ApplyFilterBlur:
|
|
10241
|
+
cullCovered = false;
|
|
10242
|
+
return false;
|
|
10243
|
+
default:
|
|
10244
|
+
break;
|
|
10245
|
+
}
|
|
10246
|
+
if (skip) continue;
|
|
10247
|
+
if (c.bx > curX1 || c.by > curY1 || c.bx + c.bw - 1 < curX0 || c.by + c.bh - 1 < curY0) continue;
|
|
10248
|
+
if (c.type == DisplayCommandType::FillRect && alpha == 255 &&
|
|
10249
|
+
curX0 <= rx0 && curY0 <= ry0 && curX1 >= rx1 && curY1 >= ry1 &&
|
|
10250
|
+
c.fill.x <= rx0 && c.fill.y <= ry0 &&
|
|
10251
|
+
c.fill.x + c.fill.w - 1 >= rx1 && c.fill.y + c.fill.h - 1 >= ry1 &&
|
|
10252
|
+
c.bx <= rx0 && c.by <= ry0 && c.bx + c.bw - 1 >= rx1 && c.by + c.bh - 1 >= ry1)
|
|
10253
|
+
{
|
|
10254
|
+
// Everything drawn so far is hidden under this fill: keep only the
|
|
10255
|
+
// clip/alpha state kept before it.
|
|
10256
|
+
int kept = 0;
|
|
10257
|
+
for (int k = 0; k < n; ++k)
|
|
10258
|
+
{
|
|
10259
|
+
const DisplayCommandType t = state.commands[gRegionIndex[k]].type;
|
|
10260
|
+
if (t == DisplayCommandType::PushClip || t == DisplayCommandType::PopClip || t == DisplayCommandType::SetAlpha)
|
|
10261
|
+
gRegionIndex[kept++] = gRegionIndex[k];
|
|
10262
|
+
}
|
|
10263
|
+
n = kept;
|
|
10264
|
+
startCi = i;
|
|
10265
|
+
cullCovered = true;
|
|
10266
|
+
emittedAlpha = -1;
|
|
10267
|
+
}
|
|
10268
|
+
if (pendingAlpha != emittedAlpha)
|
|
10269
|
+
{
|
|
10270
|
+
gRegionIndex[n++] = static_cast<std::uint16_t>(pendingAlpha);
|
|
10271
|
+
emittedAlpha = pendingAlpha;
|
|
10272
|
+
}
|
|
10273
|
+
gRegionIndex[n++] = static_cast<std::uint16_t>(i);
|
|
10274
|
+
}
|
|
10275
|
+
// Leave alpha where the whole list leaves it: the next strip starts there.
|
|
10276
|
+
if (pendingAlpha != emittedAlpha) gRegionIndex[n++] = static_cast<std::uint16_t>(pendingAlpha);
|
|
10277
|
+
(void)startCi;
|
|
10278
|
+
gRegionCovered = cullCovered;
|
|
10279
|
+
gRegionIndexCount = n;
|
|
10280
|
+
return true;
|
|
10281
|
+
}
|
|
10282
|
+
|
|
10283
|
+
// Per row of the viewport (vx, vy, vw, vh): a signature of what a
|
|
10284
|
+
// horizontal scroll cannot change, or 0. A row that only full-width plain
|
|
10285
|
+
// fills touch (a background, a horizontal rule, a rounded rect's straight
|
|
10286
|
+
// middle) looks the same at every scroll offset, and its signature hashes
|
|
10287
|
+
// those fills in paint order; any other draw reaching the row, or a fill
|
|
10288
|
+
// cut short of either edge, makes it 0. False when it cannot tell (a
|
|
10289
|
+
// filter blur, a clip stack too deep).
|
|
10290
|
+
static bool scrollRowSignatures(int vx, int vy, int vw, int vh, std::uint32_t *sig)
|
|
10291
|
+
{
|
|
10292
|
+
const int vx1 = vx + vw - 1, vy1 = vy + vh - 1;
|
|
10293
|
+
for (int r = 0; r < vh; ++r) sig[r] = 2166136261u;
|
|
10294
|
+
constexpr int kDepth = 64;
|
|
10295
|
+
int clipX0[kDepth], clipY0[kDepth], clipX1[kDepth], clipY1[kDepth];
|
|
10296
|
+
int depth = 0, alpha = 255;
|
|
10297
|
+
int curX0 = vx, curY0 = vy, curX1 = vx1, curY1 = vy1;
|
|
10298
|
+
auto vary = [&](int y0, int y1) {
|
|
10299
|
+
y0 = std::max(y0, curY0); y1 = std::min(y1, curY1);
|
|
10300
|
+
for (int y = y0; y <= y1; ++y) sig[y - vy] = 0;
|
|
10301
|
+
};
|
|
10302
|
+
auto band = [&](int y0, int y1, std::uint32_t color) {
|
|
10303
|
+
y0 = std::max(y0, curY0); y1 = std::min(y1, curY1);
|
|
10304
|
+
const std::uint32_t mix = (color << 8) ^ static_cast<std::uint32_t>(alpha);
|
|
10305
|
+
for (int y = y0; y <= y1; ++y)
|
|
10306
|
+
if (sig[y - vy]) sig[y - vy] = ((sig[y - vy] ^ mix) * 16777619u) | 1u;
|
|
10307
|
+
};
|
|
10308
|
+
for (int i = 0; i < state.commandCount; ++i)
|
|
10309
|
+
{
|
|
10310
|
+
const DisplayCommand &c = state.commands[i];
|
|
10311
|
+
switch (c.type)
|
|
10312
|
+
{
|
|
10313
|
+
case DisplayCommandType::PushClip:
|
|
10314
|
+
if (depth >= kDepth) return false;
|
|
10315
|
+
clipX0[depth] = curX0; clipY0[depth] = curY0; clipX1[depth] = curX1; clipY1[depth] = curY1;
|
|
10316
|
+
depth++;
|
|
10317
|
+
curX0 = std::max(curX0, static_cast<int>(c.clip.x));
|
|
10318
|
+
curY0 = std::max(curY0, static_cast<int>(c.clip.y));
|
|
10319
|
+
curX1 = std::min(curX1, static_cast<int>(c.clip.x) + static_cast<int>(c.clip.w) - 1);
|
|
10320
|
+
curY1 = std::min(curY1, static_cast<int>(c.clip.y) + static_cast<int>(c.clip.h) - 1);
|
|
10321
|
+
continue;
|
|
10322
|
+
case DisplayCommandType::PopClip:
|
|
10323
|
+
if (depth > 0)
|
|
10324
|
+
{
|
|
10325
|
+
depth--;
|
|
10326
|
+
curX0 = clipX0[depth]; curY0 = clipY0[depth]; curX1 = clipX1[depth]; curY1 = clipY1[depth];
|
|
10327
|
+
}
|
|
10328
|
+
continue;
|
|
10329
|
+
case DisplayCommandType::SetAlpha:
|
|
10330
|
+
alpha = c.alpha.alpha;
|
|
10331
|
+
continue;
|
|
10332
|
+
case DisplayCommandType::BeginFilterBlur:
|
|
10333
|
+
case DisplayCommandType::ApplyFilterBlur:
|
|
10334
|
+
return false;
|
|
10335
|
+
default:
|
|
10336
|
+
break;
|
|
10337
|
+
}
|
|
10338
|
+
if (curX0 > curX1 || curY0 > curY1) continue;
|
|
10339
|
+
if (c.bx > curX1 || c.by > curY1 || c.bx + c.bw - 1 < curX0 || c.by + c.bh - 1 < curY0) continue;
|
|
10340
|
+
// Only a fill spanning the whole viewport width, with the clip
|
|
10341
|
+
// leaving it whole, is the same at every offset.
|
|
10342
|
+
const bool spans = curX0 <= vx && curX1 >= vx1;
|
|
10343
|
+
if (spans && c.type == DisplayCommandType::FillRect && c.textClipOwner < 0 &&
|
|
10344
|
+
c.fill.x <= vx && c.fill.x + c.fill.w - 1 >= vx1)
|
|
10345
|
+
{
|
|
10346
|
+
band(c.fill.y, c.fill.y + c.fill.h - 1, c.fill.color);
|
|
10347
|
+
continue;
|
|
10348
|
+
}
|
|
10349
|
+
if (spans && c.type == DisplayCommandType::FillRoundedRect && c.textClipOwner < 0 &&
|
|
10350
|
+
c.fillRoundedRect.x <= vx && c.fillRoundedRect.x + c.fillRoundedRect.w - 1 >= vx1)
|
|
10351
|
+
{
|
|
10352
|
+
const auto &f = c.fillRoundedRect;
|
|
10353
|
+
const int x1 = f.x + f.w - 1, y1 = f.y + f.h - 1;
|
|
10354
|
+
// Corners clear of the viewport leave every row straight; else
|
|
10355
|
+
// only the rows between the corners are.
|
|
10356
|
+
const int top = std::max(f.tl, f.tr), bottom = std::max(f.bl, f.br);
|
|
10357
|
+
const bool cornersOut = f.x + std::max(f.tl, f.bl) <= vx && x1 - std::max(f.tr, f.br) >= vx1;
|
|
10358
|
+
if (cornersOut || f.y + top > y1 - bottom)
|
|
10359
|
+
{
|
|
10360
|
+
if (cornersOut) band(f.y, y1, f.color);
|
|
10361
|
+
else vary(f.y, y1);
|
|
10362
|
+
}
|
|
10363
|
+
else
|
|
10364
|
+
{
|
|
10365
|
+
vary(f.y, f.y + top - 1);
|
|
10366
|
+
band(f.y + top, y1 - bottom, f.color);
|
|
10367
|
+
vary(y1 - bottom + 1, y1);
|
|
10368
|
+
}
|
|
10369
|
+
continue;
|
|
10370
|
+
}
|
|
10371
|
+
// A border whose side edges (corners included) lie outside the
|
|
10372
|
+
// viewport paints only its top and bottom bands inside it: a card's
|
|
10373
|
+
// outline around a scroller leaves the rows between untouched.
|
|
10374
|
+
if (c.type == DisplayCommandType::StrokeRect || c.type == DisplayCommandType::StrokeRoundedRect)
|
|
10375
|
+
{
|
|
10376
|
+
int sx, sy, sw, sh, reach = 1;
|
|
10377
|
+
if (c.type == DisplayCommandType::StrokeRect)
|
|
10378
|
+
{
|
|
10379
|
+
sx = c.stroke.x; sy = c.stroke.y; sw = c.stroke.w; sh = c.stroke.h;
|
|
10380
|
+
}
|
|
10381
|
+
else
|
|
10382
|
+
{
|
|
10383
|
+
const auto &st = c.strokeRoundedRect;
|
|
10384
|
+
sx = st.x; sy = st.y; sw = st.w; sh = st.h;
|
|
10385
|
+
reach = std::max<int>({st.tl, st.tr, st.br, st.bl, 0}) + std::max<int>(st.lineWidth, 1);
|
|
10386
|
+
if (st.cssRadii)
|
|
10387
|
+
for (int k = 0; k < 4; ++k) reach = std::max(reach, (std::max(st.rx8[k], st.ry8[k]) + 7) / 8 + std::max<int>(st.lineWidth, 1));
|
|
10388
|
+
}
|
|
10389
|
+
if (sx + reach < vx && sx + sw - 1 - reach > vx1 && sh > 2 * reach)
|
|
10390
|
+
{
|
|
10391
|
+
vary(std::min<int>(sy, c.by), sy + reach);
|
|
10392
|
+
vary(sy + sh - 1 - reach, std::max<int>(sy + sh - 1, c.by + c.bh - 1));
|
|
10393
|
+
continue;
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
vary(c.by, c.by + c.bh - 1);
|
|
10397
|
+
}
|
|
10398
|
+
return true;
|
|
10399
|
+
}
|
|
10400
|
+
|
|
10401
|
+
// A strip-by-strip replay of one region computes the cull once for the
|
|
10402
|
+
// whole region (a cover of the region covers every strip of it) instead
|
|
10403
|
+
// of re-scanning the list per strip.
|
|
10404
|
+
static inline int cullStartOverride = -1;
|
|
10405
|
+
// Whether the last cullStartIndex() found an opaque fill covering the clip.
|
|
10406
|
+
static inline bool cullCovered = false;
|
|
10407
|
+
|
|
10408
|
+
static void GEA_RENDER_HOT_SRAM replay()
|
|
10409
|
+
{
|
|
10410
|
+
int cx0 = 0, cy0 = 0, cx1 = 0, cy1 = 0;
|
|
10411
|
+
int clip_dirty = 1;
|
|
10412
|
+
int clip_stack_depth = 0;
|
|
10413
|
+
UniformRoundedRectBatch roundedRects;
|
|
10414
|
+
|
|
10415
|
+
// Occlusion cull against the CALLER's clip (the conservative tree_render
|
|
10416
|
+
// path pushes each dirty rect around a full replay): start at the last
|
|
10417
|
+
// opaque full-cover fill's first command. Unlike the node walks, this
|
|
10418
|
+
// stream carries clip state INLINE, and an orphan PopClip at depth 0
|
|
10419
|
+
// pops the caller's region clip — so only cull when the cover has no
|
|
10420
|
+
// clipping ancestors (whose Pop would run unmatched), the skipped
|
|
10421
|
+
// prefix is Push/Pop balanced, and no filter-blur pair could straddle
|
|
10422
|
+
// the cut.
|
|
10423
|
+
// A filtered region list already dropped the culled draws; replay()
|
|
10424
|
+
// below decides whether the clip lets it use the list.
|
|
10425
|
+
int startCi = -1;
|
|
10426
|
+
|
|
10427
|
+
int listed = gRegionIndexCount;
|
|
10428
|
+
if (listed >= 0)
|
|
10429
|
+
{
|
|
10430
|
+
int qx0 = 0, qy0 = 0, qx1 = -1, qy1 = -1;
|
|
10431
|
+
gea::platform::display::Display::clip(&qx0, &qy0, &qx1, &qy1);
|
|
10432
|
+
if (qx1 >= qx0 && qy1 >= qy0 &&
|
|
10433
|
+
(qx0 < gRegionX0 || qy0 < gRegionY0 || qx1 > gRegionX1 || qy1 > gRegionY1))
|
|
10434
|
+
listed = -1;
|
|
10435
|
+
}
|
|
10436
|
+
const int total = listed >= 0 ? listed : state.commandCount;
|
|
10437
|
+
if (startCi < 0) startCi = listed >= 0 ? 0 : cullStartOverride >= 0 ? cullStartOverride : cullStartIndex();
|
|
10438
|
+
for (int k = 0; k < total; k++)
|
|
10439
|
+
{
|
|
10440
|
+
const int i = listed >= 0 ? gRegionIndex[k] : k;
|
|
9626
10441
|
DisplayCommand *c = &state.commands[i];
|
|
9627
10442
|
|
|
9628
10443
|
// Occlusion cull: draws before the covering fill are invisible; only
|
|
@@ -9738,6 +10553,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
9738
10553
|
// the enclosing real context. Ordinary block/inline wrappers contribute
|
|
9739
10554
|
// separate entries so block backgrounds remain below floats and text.
|
|
9740
10555
|
auto walk = [&](auto &&self, int parent, bool withinGroup) -> void {
|
|
10556
|
+
#if GEA_UI_SVG
|
|
10557
|
+
// An svg's children are its scene, painted by its DrawSvg command.
|
|
10558
|
+
if (svg::isRoot(nodes[parent])) return;
|
|
10559
|
+
#endif
|
|
9741
10560
|
std::vector<int> children;
|
|
9742
10561
|
for (int child = nodes[parent].first_child; child >= 0; child = nodes[child].next_sibling)
|
|
9743
10562
|
if (!isStructuralNodeType(nodes[child].type) && !isDisplayNone(nodes[child].computedStyle())) children.push_back(child);
|
|
@@ -9771,7 +10590,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9771
10590
|
{
|
|
9772
10591
|
// This is also the recorder's traversal, so retained draws cannot invent a
|
|
9773
10592
|
// second hierarchy or lose document-order ties after a depth crossing.
|
|
9774
|
-
static int ranks[kMaxNodes];
|
|
10593
|
+
GEA_EXT_BSS static int ranks[kMaxNodes];
|
|
9775
10594
|
static uint64_t serial = ~0ull;
|
|
9776
10595
|
static uint32_t recordSerial = 0;
|
|
9777
10596
|
auto &tree = Tree::instance();
|
|
@@ -9888,6 +10707,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
9888
10707
|
|
|
9889
10708
|
void DisplayList::pruneImageReferences()
|
|
9890
10709
|
{
|
|
10710
|
+
// Runs after every re-recorded node: with no image held there is nothing
|
|
10711
|
+
// to release, and only blit commands can hold one.
|
|
10712
|
+
bool anyHeld = false;
|
|
10713
|
+
for (int id = 0; id < gea::framework::graphics::kImageMax && !anyHeld; ++id)
|
|
10714
|
+
anyHeld = state.imageReferences[id];
|
|
10715
|
+
if (!anyHeld) return;
|
|
9891
10716
|
bool referenced[gea::framework::graphics::kImageMax]{};
|
|
9892
10717
|
auto &images = gea::framework::graphics::ImageStore::instance();
|
|
9893
10718
|
for (int i = 0; i < state.commandCount; ++i) {
|
|
@@ -9896,6 +10721,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9896
10721
|
if (command.type == DisplayCommandType::BlitImage) pixels = command.blit.pixels;
|
|
9897
10722
|
else if (command.type == DisplayCommandType::BlitImageScaled) pixels = command.scaledBlit.pixels;
|
|
9898
10723
|
else if (command.type == DisplayCommandType::BlitImageProjected) pixels = command.projectedBlit.pixels;
|
|
10724
|
+
else continue;
|
|
9899
10725
|
const int id = images.idForPixels(pixels);
|
|
9900
10726
|
if (id >= 0) referenced[id] = true;
|
|
9901
10727
|
}
|
|
@@ -9909,6 +10735,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9909
10735
|
|
|
9910
10736
|
void DisplayList::clear()
|
|
9911
10737
|
{
|
|
10738
|
+
gRegionIndexCount = -1; // its indices name the old list
|
|
9912
10739
|
Tree &tree = Tree::instance();
|
|
9913
10740
|
state.displayListSerial++;
|
|
9914
10741
|
if (state.displayListSerial == 0)
|
|
@@ -9918,6 +10745,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
9918
10745
|
state.commandCount = 0;
|
|
9919
10746
|
pruneImageReferences();
|
|
9920
10747
|
state.textClippedBackgrounds = false;
|
|
10748
|
+
state.scrollbarBoxCount = 0;
|
|
10749
|
+
state.scrollbarBoxOverflow = false;
|
|
9921
10750
|
state.commandOverflow = false;
|
|
9922
10751
|
state.drawNodeOrderCount = 0;
|
|
9923
10752
|
if (!state.ensureNodeScratchCapacity(tree.nodeCount()))
|
|
@@ -9995,6 +10824,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
9995
10824
|
Tree &weldTree = Tree::instance();
|
|
9996
10825
|
Node *weldNodes = weldTree.nodes();
|
|
9997
10826
|
const int weldNodeCount = weldTree.nodeCount();
|
|
10827
|
+
// No transform-dirty node, no dynamic subtree: nothing below can weld. One
|
|
10828
|
+
// pass over a flag instead of an ancestor walk per node, on every refresh
|
|
10829
|
+
// of every screen without a transform animation.
|
|
10830
|
+
bool anyTransformDirty = false;
|
|
10831
|
+
for (int id = 0; id < weldNodeCount && !anyTransformDirty; id++)
|
|
10832
|
+
anyTransformDirty = weldNodes[id].render.transform_dirty;
|
|
10833
|
+
if (!anyTransformDirty)
|
|
10834
|
+
return;
|
|
9998
10835
|
for (int id = 0; id < weldNodeCount && wn + 4 <= kMaxWeld; id++)
|
|
9999
10836
|
{
|
|
10000
10837
|
bool nodeInDynamicSubtree = false;
|
|
@@ -10545,9 +11382,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
10545
11382
|
{
|
|
10546
11383
|
if ((GEA_CSS_FILTERS ? rstyle(nodes[i].computedStyle()).filter_blur_radius : 0) > 0)
|
|
10547
11384
|
return false;
|
|
10548
|
-
if (nodes[i].computedStyle().overflow == 2)
|
|
10549
|
-
return false;
|
|
10550
11385
|
}
|
|
11386
|
+
// Scroll containers replay like overflow:hidden ones (their clips come
|
|
11387
|
+
// from overflowClipBounds); only their scrollbar thumbs sit outside the
|
|
11388
|
+
// node ranges, and tree_render keeps frames that touch a thumb on the
|
|
11389
|
+
// full-list path (scrollbarOverlapsRegion).
|
|
10551
11390
|
(void)width;
|
|
10552
11391
|
(void)height;
|
|
10553
11392
|
|
|
@@ -10560,6 +11399,81 @@ int gLastScrollUiFrame = -1000;
|
|
|
10560
11399
|
return state.textClippedBackgrounds;
|
|
10561
11400
|
}
|
|
10562
11401
|
|
|
11402
|
+
void DisplayList::noteScrollbarBox(int node, int x, int y, int w, int h)
|
|
11403
|
+
{
|
|
11404
|
+
if (state.scrollbarBoxCount >= DisplayListState::kMaxScrollbarBoxes)
|
|
11405
|
+
{
|
|
11406
|
+
state.scrollbarBoxOverflow = true;
|
|
11407
|
+
return;
|
|
11408
|
+
}
|
|
11409
|
+
// Called right after the thumb's append(), so it is the last command.
|
|
11410
|
+
state.scrollbarCommands[state.scrollbarBoxCount] = state.commandCount - 1;
|
|
11411
|
+
state.scrollbarNodes[state.scrollbarBoxCount] = node;
|
|
11412
|
+
std::int16_t *box = state.scrollbarBoxes[state.scrollbarBoxCount++];
|
|
11413
|
+
box[0] = static_cast<std::int16_t>(x);
|
|
11414
|
+
box[1] = static_cast<std::int16_t>(y);
|
|
11415
|
+
box[2] = static_cast<std::int16_t>(x + w - 1);
|
|
11416
|
+
box[3] = static_cast<std::int16_t>(y + h - 1);
|
|
11417
|
+
}
|
|
11418
|
+
|
|
11419
|
+
bool DisplayList::scrollbarOverlapsRegion(int x0, int y0, int x1, int y1) const
|
|
11420
|
+
{
|
|
11421
|
+
if (state.scrollbarBoxOverflow)
|
|
11422
|
+
return true;
|
|
11423
|
+
for (int i = 0; i < state.scrollbarBoxCount; ++i)
|
|
11424
|
+
{
|
|
11425
|
+
const std::int16_t *box = state.scrollbarBoxes[i];
|
|
11426
|
+
if (box[0] <= x1 && box[2] >= x0 && box[1] <= y1 && box[3] >= y0)
|
|
11427
|
+
return true;
|
|
11428
|
+
}
|
|
11429
|
+
return false;
|
|
11430
|
+
}
|
|
11431
|
+
|
|
11432
|
+
// Direct replay walks node command ranges, which a thumb sits outside. It can
|
|
11433
|
+
// still serve a frame that touches a thumb by painting the thumb after the
|
|
11434
|
+
// nodes -- correct only while nothing recorded after the thumb paints over it
|
|
11435
|
+
// (an overlay above the scroll container would otherwise end up under it).
|
|
11436
|
+
bool DisplayList::scrollbarThumbsPaintLast() const
|
|
11437
|
+
{
|
|
11438
|
+
if (state.scrollbarBoxOverflow)
|
|
11439
|
+
return false;
|
|
11440
|
+
for (int i = 0; i < state.scrollbarBoxCount; ++i)
|
|
11441
|
+
{
|
|
11442
|
+
const int index = state.scrollbarCommands[i];
|
|
11443
|
+
if (index < 0 || index >= state.commandCount)
|
|
11444
|
+
return false;
|
|
11445
|
+
const std::int16_t *box = state.scrollbarBoxes[i];
|
|
11446
|
+
for (int ci = index + 1; ci < state.commandCount; ++ci)
|
|
11447
|
+
{
|
|
11448
|
+
const DisplayCommand &c = state.commands[ci];
|
|
11449
|
+
if (c.type == DisplayCommandType::PushClip || c.type == DisplayCommandType::PopClip)
|
|
11450
|
+
continue;
|
|
11451
|
+
if (c.bw <= 0 || c.bh <= 0)
|
|
11452
|
+
continue;
|
|
11453
|
+
if (ClipMath::rectsOverlap(c.bx, c.by, c.bx + c.bw - 1, c.by + c.bh - 1, box[0], box[1], box[2], box[3]))
|
|
11454
|
+
return false;
|
|
11455
|
+
}
|
|
11456
|
+
}
|
|
11457
|
+
return true;
|
|
11458
|
+
}
|
|
11459
|
+
|
|
11460
|
+
void DisplayList::replayScrollbarThumbsInRegion(int x0, int y0, int x1, int y1)
|
|
11461
|
+
{
|
|
11462
|
+
for (int i = 0; i < state.scrollbarBoxCount; ++i)
|
|
11463
|
+
{
|
|
11464
|
+
const std::int16_t *box = state.scrollbarBoxes[i];
|
|
11465
|
+
if (!(box[0] <= x1 && box[2] >= x0 && box[1] <= y1 && box[3] >= y0))
|
|
11466
|
+
continue;
|
|
11467
|
+
const int index = state.scrollbarCommands[i];
|
|
11468
|
+
if (index < 0 || index >= state.commandCount)
|
|
11469
|
+
continue;
|
|
11470
|
+
gea::platform::display::Display::setAlpha(255);
|
|
11471
|
+
gea::platform::display::Display::pushClip(x0, y0, x1 - x0 + 1, y1 - y0 + 1);
|
|
11472
|
+
DisplayCommandDrawer::replay(state.commands[index]);
|
|
11473
|
+
gea::platform::display::Display::popClip();
|
|
11474
|
+
}
|
|
11475
|
+
}
|
|
11476
|
+
|
|
10563
11477
|
void DisplayList::clearRetainedBackgroundRecolors()
|
|
10564
11478
|
{
|
|
10565
11479
|
state.retainedBackgroundRecolorCount = 0;
|
|
@@ -10748,23 +11662,65 @@ int gLastScrollUiFrame = -1000;
|
|
|
10748
11662
|
return;
|
|
10749
11663
|
Tree &tree = Tree::instance();
|
|
10750
11664
|
Node *nodes = tree.nodes();
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
11665
|
+
const int count = tree.nodeCount();
|
|
11666
|
+
// Mark the subtree in one walk down its child links. Testing every node's
|
|
11667
|
+
// ancestor chain instead cost O(nodes x depth) on every scroll frame: 4-12
|
|
11668
|
+
// ms of a CrowPanel chart scroll frame, on a tab of ~600 commands.
|
|
11669
|
+
static std::vector<std::uint32_t> subtreeMark;
|
|
11670
|
+
static std::uint32_t subtreeStamp = 0;
|
|
11671
|
+
if (subtreeMark.size() < static_cast<std::size_t>(count))
|
|
11672
|
+
subtreeMark.resize(static_cast<std::size_t>(count), 0);
|
|
11673
|
+
if (++subtreeStamp == 0)
|
|
10758
11674
|
{
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
11675
|
+
std::fill(subtreeMark.begin(), subtreeMark.end(), 0);
|
|
11676
|
+
subtreeStamp = 1;
|
|
11677
|
+
}
|
|
11678
|
+
for (int id = node; id >= 0;)
|
|
11679
|
+
{
|
|
11680
|
+
subtreeMark[id] = subtreeStamp;
|
|
11681
|
+
if (state.hasNodeScratchFor(id))
|
|
10764
11682
|
{
|
|
10765
|
-
|
|
10766
|
-
|
|
11683
|
+
const int start = state.nodeDrawStart[id];
|
|
11684
|
+
const int end = state.nodeDrawEnd[id];
|
|
11685
|
+
if (start >= 0 && end > start && end <= state.commandCount)
|
|
11686
|
+
{
|
|
11687
|
+
for (int ci = start; ci < end; ci++)
|
|
11688
|
+
DisplayCommandTranslator::translate(&state.commands[ci], dx, dy);
|
|
11689
|
+
}
|
|
11690
|
+
}
|
|
11691
|
+
if (nodes[id].first_child >= 0)
|
|
11692
|
+
{
|
|
11693
|
+
id = nodes[id].first_child;
|
|
11694
|
+
continue;
|
|
10767
11695
|
}
|
|
11696
|
+
while (id != node && nodes[id].next_sibling < 0)
|
|
11697
|
+
id = nodes[id].parent;
|
|
11698
|
+
if (id == node)
|
|
11699
|
+
break;
|
|
11700
|
+
id = nodes[id].next_sibling;
|
|
11701
|
+
}
|
|
11702
|
+
auto belongsToSubtree = [&](int id) {
|
|
11703
|
+
return id >= 0 && id < count && subtreeMark[id] == subtreeStamp;
|
|
11704
|
+
};
|
|
11705
|
+
// A scroll container's thumb sits outside every node paint range too. The
|
|
11706
|
+
// thumbs of containers inside the subtree move with it (the root's own
|
|
11707
|
+
// thumb stays: it is viewport-fixed like the root's box, and its caller
|
|
11708
|
+
// repositions it -- patchScrollbarThumb). Left behind, a scrolling page
|
|
11709
|
+
// replayed a nested list's thumb at its old place into every revealed
|
|
11710
|
+
// strip that crossed it, and the blit then dragged those stale pieces up
|
|
11711
|
+
// the screen with the content.
|
|
11712
|
+
for (int i = 0; i < state.scrollbarBoxCount; ++i)
|
|
11713
|
+
{
|
|
11714
|
+
const int owner = state.scrollbarNodes[i];
|
|
11715
|
+
const int ci = state.scrollbarCommands[i];
|
|
11716
|
+
if (owner == node || !belongsToSubtree(owner) || ci < 0 || ci >= state.commandCount)
|
|
11717
|
+
continue;
|
|
11718
|
+
DisplayCommandTranslator::translate(&state.commands[ci], dx, dy);
|
|
11719
|
+
std::int16_t *box = state.scrollbarBoxes[i];
|
|
11720
|
+
box[0] = static_cast<std::int16_t>(box[0] + dx);
|
|
11721
|
+
box[1] = static_cast<std::int16_t>(box[1] + dy);
|
|
11722
|
+
box[2] = static_cast<std::int16_t>(box[2] + dx);
|
|
11723
|
+
box[3] = static_cast<std::int16_t>(box[3] + dy);
|
|
10768
11724
|
}
|
|
10769
11725
|
// Clip scopes sit outside node paint ranges. Scan the command buffer once
|
|
10770
11726
|
// after translating all paint ranges, rather than once per descendant.
|
|
@@ -10800,10 +11756,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
10800
11756
|
if (ViewRenderer::anyTransformActive())
|
|
10801
11757
|
return false;
|
|
10802
11758
|
Node *nodes = tree.nodes();
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
int
|
|
11759
|
+
// Built inside out, so the screen bound goes on last: recordNode hands
|
|
11760
|
+
// the children of an expanded-clip node (recordNodeWithExpandedClip) the
|
|
11761
|
+
// coverage window in place of everything above it, screen included.
|
|
11762
|
+
int x0 = INT_MIN / 2;
|
|
11763
|
+
int y0 = INT_MIN / 2;
|
|
11764
|
+
int x1 = INT_MAX / 2;
|
|
11765
|
+
int y1 = INT_MAX / 2;
|
|
11766
|
+
bool expanded = false;
|
|
10807
11767
|
for (int a = LayoutEngine::isViewportFixed(nodes[id]) ? -1 : nodes[id].parent; a >= 0 && a < nodeCount; a = nodes[a].parent)
|
|
10808
11768
|
{
|
|
10809
11769
|
const Node &ancestor = nodes[a];
|
|
@@ -10812,9 +11772,25 @@ int gLastScrollUiFrame = -1000;
|
|
|
10812
11772
|
if (LayoutEngine::isViewportFixed(ancestor)) break;
|
|
10813
11773
|
continue;
|
|
10814
11774
|
}
|
|
11775
|
+
if (a == state.recordExpandedClipNode)
|
|
11776
|
+
{
|
|
11777
|
+
x0 = std::max(x0, state.recordExpandedClipX0);
|
|
11778
|
+
y0 = std::max(y0, state.recordExpandedClipY0);
|
|
11779
|
+
x1 = std::min(x1, state.recordExpandedClipX1);
|
|
11780
|
+
y1 = std::min(y1, state.recordExpandedClipY1);
|
|
11781
|
+
expanded = true;
|
|
11782
|
+
break;
|
|
11783
|
+
}
|
|
10815
11784
|
ClipMath::clampToNode(ancestor, &x0, &y0, &x1, &y1);
|
|
10816
11785
|
if (LayoutEngine::isViewportFixed(ancestor)) break;
|
|
10817
11786
|
}
|
|
11787
|
+
if (!expanded)
|
|
11788
|
+
{
|
|
11789
|
+
x0 = std::max(x0, 0);
|
|
11790
|
+
y0 = std::max(y0, 0);
|
|
11791
|
+
x1 = std::min(x1, width - 1);
|
|
11792
|
+
y1 = std::min(y1, height - 1);
|
|
11793
|
+
}
|
|
10818
11794
|
*cx0 = x0;
|
|
10819
11795
|
*cy0 = y0;
|
|
10820
11796
|
*cx1 = x1;
|
|
@@ -11788,6 +12764,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
11788
12764
|
case DisplayCommandType::DrawText:
|
|
11789
12765
|
case DisplayCommandType::BlitImage:
|
|
11790
12766
|
case DisplayCommandType::ReplayCanvasBatch:
|
|
12767
|
+
case DisplayCommandType::DrawSvg:
|
|
11791
12768
|
case DisplayCommandType::BlitImageProjected:
|
|
11792
12769
|
case DisplayCommandType::BlitImageScaled:
|
|
11793
12770
|
case DisplayCommandType::FillTransformedLinearGradient:
|
|
@@ -12382,7 +13359,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
12382
13359
|
const std::int64_t totalStartUs = refreshPerfNowUs();
|
|
12383
13360
|
FillBandDirty dMain{canvas->width(), canvas->height(), -1, -1};
|
|
12384
13361
|
FillBandDirty dWork{canvas->width(), canvas->height(), -1, -1};
|
|
12385
|
-
static RecolorPixelCache protectedPixelCaches[2];
|
|
13362
|
+
GEA_EXT_BSS static RecolorPixelCache protectedPixelCaches[2];
|
|
12386
13363
|
if (protectForegroundDuringFill)
|
|
12387
13364
|
{
|
|
12388
13365
|
protectedPixelCaches[0].clear();
|
|
@@ -12999,17 +13976,30 @@ int gLastScrollUiFrame = -1000;
|
|
|
12999
13976
|
return false;
|
|
13000
13977
|
int start = state.nodeDrawStart[node];
|
|
13001
13978
|
int end = state.nodeDrawEnd[node];
|
|
13979
|
+
// recordNode culls a node outside its ancestors' overflow clips to the
|
|
13980
|
+
// empty range (-1, -1). While it stays outside, a full record would cull it
|
|
13981
|
+
// again, so a change to it (a ticking legend just below a scroll view's
|
|
13982
|
+
// edge) leaves the list exactly as it is -- refusing here instead threw the
|
|
13983
|
+
// whole retained list away and re-recorded the screen every frame.
|
|
13984
|
+
if (start < 0 && end < 0 && !isDocumentCanvasRoot(nodes[node]) &&
|
|
13985
|
+
nodeOutsideRecordClip(node, tree.mountedWidth(), tree.mountedHeight()))
|
|
13986
|
+
return true;
|
|
13002
13987
|
if (start < 0 || end < start || end > state.commandCount)
|
|
13003
13988
|
return false;
|
|
13004
13989
|
|
|
13005
|
-
|
|
13990
|
+
// Raw storage, like the list's own buffer: append() hands out slots the
|
|
13991
|
+
// recorders fill, so constructing 96 commands per re-record (a few KB of
|
|
13992
|
+
// zeroing, every changed node, every frame) bought nothing.
|
|
13993
|
+
constexpr int kTmpCommands = 96;
|
|
13994
|
+
alignas(DisplayCommand) unsigned char tmpStorage[sizeof(DisplayCommand) * kTmpCommands];
|
|
13995
|
+
DisplayCommand *tmp = reinterpret_cast<DisplayCommand *>(tmpStorage);
|
|
13006
13996
|
int tmp_len = 0;
|
|
13007
13997
|
DisplayCommand *prev_override = state.appendOverride;
|
|
13008
13998
|
int *prev_override_len = state.appendOverrideCount;
|
|
13009
13999
|
int prev_override_cap = state.appendOverrideCapacity;
|
|
13010
14000
|
state.appendOverride = tmp;
|
|
13011
14001
|
state.appendOverrideCount = &tmp_len;
|
|
13012
|
-
state.appendOverrideCapacity =
|
|
14002
|
+
state.appendOverrideCapacity = kTmpCommands;
|
|
13013
14003
|
|
|
13014
14004
|
Node *n = &nodes[node];
|
|
13015
14005
|
// recordNode gates every paint on `overlaps_clip` — a node outside its
|
|
@@ -13034,6 +14024,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
13034
14024
|
CanvasRenderer::record(*n);
|
|
13035
14025
|
else if (n->type == NodeType::Camera)
|
|
13036
14026
|
CameraRenderer::record(*n);
|
|
14027
|
+
#if GEA_UI_SVG
|
|
14028
|
+
else if (svg::isRoot(*n))
|
|
14029
|
+
svg::record(*n);
|
|
14030
|
+
#endif
|
|
13037
14031
|
}
|
|
13038
14032
|
|
|
13039
14033
|
state.appendOverride = prev_override;
|
|
@@ -13044,6 +14038,15 @@ int gLastScrollUiFrame = -1000;
|
|
|
13044
14038
|
int delta = tmp_len - old_len;
|
|
13045
14039
|
if (old_len == 0 && tmp_len > 0)
|
|
13046
14040
|
return false;
|
|
14041
|
+
// Only a replaced blit can drop the last reference to an image; new ones
|
|
14042
|
+
// retain theirs while recording.
|
|
14043
|
+
bool replacedBlit = false;
|
|
14044
|
+
for (int ci = start; ci < end && !replacedBlit; ++ci)
|
|
14045
|
+
{
|
|
14046
|
+
const DisplayCommandType type = state.commands[ci].type;
|
|
14047
|
+
replacedBlit = type == DisplayCommandType::BlitImage || type == DisplayCommandType::BlitImageScaled ||
|
|
14048
|
+
type == DisplayCommandType::BlitImageProjected;
|
|
14049
|
+
}
|
|
13047
14050
|
if (delta > 0 && state.commandCount + delta > DisplayListState::kMaxCommands)
|
|
13048
14051
|
return false;
|
|
13049
14052
|
if (delta != 0 && end < state.commandCount)
|
|
@@ -13066,10 +14069,27 @@ int gLastScrollUiFrame = -1000;
|
|
|
13066
14069
|
state.nodeDrawEnd[node] = -1;
|
|
13067
14070
|
}
|
|
13068
14071
|
state.shiftNodeDrawRangesAfter(end, delta, node);
|
|
13069
|
-
|
|
14072
|
+
if (replacedBlit)
|
|
14073
|
+
pruneImageReferences();
|
|
13070
14074
|
return true;
|
|
13071
14075
|
}
|
|
13072
14076
|
|
|
14077
|
+
bool DisplayList::rerecordNodeCommandsWithExpandedClip(int node, int clipNode, int clipX0, int clipY0, int clipX1, int clipY1)
|
|
14078
|
+
{
|
|
14079
|
+
state.recordExpandedClipNode = clipNode;
|
|
14080
|
+
state.recordExpandedClipX0 = clipX0;
|
|
14081
|
+
state.recordExpandedClipY0 = clipY0;
|
|
14082
|
+
state.recordExpandedClipX1 = clipX1;
|
|
14083
|
+
state.recordExpandedClipY1 = clipY1;
|
|
14084
|
+
const bool ok = rerecordNodeCommands(node);
|
|
14085
|
+
state.recordExpandedClipNode = -1;
|
|
14086
|
+
state.recordExpandedClipX0 = 0;
|
|
14087
|
+
state.recordExpandedClipY0 = 0;
|
|
14088
|
+
state.recordExpandedClipX1 = -1;
|
|
14089
|
+
state.recordExpandedClipY1 = -1;
|
|
14090
|
+
return ok;
|
|
14091
|
+
}
|
|
14092
|
+
|
|
13073
14093
|
std::uint32_t DisplayList::recordSerial() const
|
|
13074
14094
|
{
|
|
13075
14095
|
return state.displayListSerial;
|
|
@@ -13087,6 +14107,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
13087
14107
|
Node *nodes = tree.nodes();
|
|
13088
14108
|
if (!state.commands || node < 0 || node >= tree.nodeCount())
|
|
13089
14109
|
return false;
|
|
14110
|
+
// Untracked thumbs (more than the box table holds) cannot follow a
|
|
14111
|
+
// translate (translateSubtreeCommands): have the caller re-record.
|
|
14112
|
+
if (state.scrollbarBoxOverflow)
|
|
14113
|
+
return false;
|
|
13090
14114
|
const Node *n = &nodes[node];
|
|
13091
14115
|
|
|
13092
14116
|
// Mirror of ViewRenderer::recordScrollbar's geometry. Cases where no
|
|
@@ -13113,7 +14137,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
13113
14137
|
};
|
|
13114
14138
|
const int oldY = thumbY(n->layout.previous_scroll_y);
|
|
13115
14139
|
const int newY = thumbY(n->layout.scroll_y);
|
|
13116
|
-
const int thumbX = n->layout.x + n->layout.width -
|
|
14140
|
+
const int thumbX = n->layout.x + n->layout.width - 6 - 4;
|
|
13117
14141
|
if (oldY == newY)
|
|
13118
14142
|
return true;
|
|
13119
14143
|
|
|
@@ -13122,10 +14146,17 @@ int gLastScrollUiFrame = -1000;
|
|
|
13122
14146
|
DisplayCommand &c = state.commands[ci];
|
|
13123
14147
|
if (c.type != DisplayCommandType::FillRoundedRect)
|
|
13124
14148
|
continue;
|
|
13125
|
-
if (c.bx != thumbX || c.bw !=
|
|
14149
|
+
if (c.bx != thumbX || c.bw != 4 || c.by != oldY || c.bh != thumb_h)
|
|
13126
14150
|
continue;
|
|
13127
14151
|
c.by = static_cast<std::int16_t>(newY);
|
|
13128
14152
|
c.fillRoundedRect.y = static_cast<std::int16_t>(newY);
|
|
14153
|
+
// The thumb's box steers which repaints replay it; keep it on the thumb.
|
|
14154
|
+
for (int i = 0; i < state.scrollbarBoxCount; ++i)
|
|
14155
|
+
if (state.scrollbarCommands[i] == ci)
|
|
14156
|
+
{
|
|
14157
|
+
state.scrollbarBoxes[i][1] = static_cast<std::int16_t>(newY);
|
|
14158
|
+
state.scrollbarBoxes[i][3] = static_cast<std::int16_t>(newY + thumb_h - 1);
|
|
14159
|
+
}
|
|
13129
14160
|
return true;
|
|
13130
14161
|
}
|
|
13131
14162
|
return false;
|
|
@@ -13141,6 +14172,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
13141
14172
|
// background re-blend over themselves and drift outward every replay.
|
|
13142
14173
|
DisplayCommandReplayer::restoreClearBaseInRegion(x0, y0, x1, y1);
|
|
13143
14174
|
DisplayCommandReplayer::replayDirectDirtyRegion(x0, y0, x1, y1, origin);
|
|
14175
|
+
replayScrollbarThumbsInRegion(x0, y0, x1, y1);
|
|
13144
14176
|
}
|
|
13145
14177
|
|
|
13146
14178
|
void DisplayList::replayDirectDirtyRegions(const DisplayReplayRegion *regions, int count)
|
|
@@ -13148,6 +14180,18 @@ int gLastScrollUiFrame = -1000;
|
|
|
13148
14180
|
for (int i = 0; i < count; ++i)
|
|
13149
14181
|
DisplayCommandReplayer::restoreClearBaseInRegion(regions[i].x0, regions[i].y0, regions[i].x1, regions[i].y1);
|
|
13150
14182
|
DisplayCommandReplayer::replayDirectDirtyRegions(regions, count);
|
|
14183
|
+
for (int i = 0; i < count; ++i)
|
|
14184
|
+
replayScrollbarThumbsInRegion(regions[i].x0, regions[i].y0, regions[i].x1, regions[i].y1);
|
|
14185
|
+
}
|
|
14186
|
+
|
|
14187
|
+
void DisplayList::beginSimpleReplayScope()
|
|
14188
|
+
{
|
|
14189
|
+
DisplayCommandReplayer::beginSimpleReplayScope();
|
|
14190
|
+
}
|
|
14191
|
+
|
|
14192
|
+
void DisplayList::endSimpleReplayScope()
|
|
14193
|
+
{
|
|
14194
|
+
DisplayCommandReplayer::endSimpleReplayScope();
|
|
13151
14195
|
}
|
|
13152
14196
|
|
|
13153
14197
|
bool DisplayList::canReplaySimpleDirtyRegions(int width, int height) const
|
|
@@ -13170,14 +14214,16 @@ int gLastScrollUiFrame = -1000;
|
|
|
13170
14214
|
// chunk. The worker canvas has neither that binding nor the clip, so this
|
|
13171
14215
|
// already-clipped entry must stay on the submitting canvas.
|
|
13172
14216
|
DisplayCommandReplayer::replaySimpleClippedDirtyRegion(x0, y0, x1, y1, origin, /*allowSplit=*/false);
|
|
14217
|
+
replayScrollbarThumbsInRegion(x0, y0, x1, y1);
|
|
13173
14218
|
}
|
|
13174
14219
|
|
|
13175
14220
|
void DisplayList::maybeBakeStaticBackdrop(int width, int height, bool stableThisFrame, bool directReplay,
|
|
13176
14221
|
bool bakeEligibleThisFrame)
|
|
13177
14222
|
{
|
|
13178
14223
|
// The backdrop cache only helps the direct dirty-region replay path; without it
|
|
13179
|
-
// we render the full list anyway, so don't bake.
|
|
13180
|
-
|
|
14224
|
+
// we render the full list anyway, so don't bake. Nor with scrollbar thumbs:
|
|
14225
|
+
// the bake would capture a thumb that direct replay repaints elsewhere.
|
|
14226
|
+
if (!directReplay || state.scrollbarBoxCount > 0)
|
|
13181
14227
|
{
|
|
13182
14228
|
gBackdropCacheValid = false;
|
|
13183
14229
|
gBackdropStableFrames = 0;
|
|
@@ -13240,8 +14286,52 @@ int gLastScrollUiFrame = -1000;
|
|
|
13240
14286
|
*misses = state.filterBlurCacheMisses;
|
|
13241
14287
|
}
|
|
13242
14288
|
|
|
14289
|
+
int DisplayList::replayCullStart()
|
|
14290
|
+
{
|
|
14291
|
+
return DisplayCommandReplayer::cullStartIndex();
|
|
14292
|
+
}
|
|
14293
|
+
|
|
14294
|
+
bool DisplayList::replayCullCovered()
|
|
14295
|
+
{
|
|
14296
|
+
return DisplayCommandReplayer::cullCovered;
|
|
14297
|
+
}
|
|
14298
|
+
|
|
14299
|
+
bool DisplayList::scrollRowSignatures(int vx, int vy, int vw, int vh, std::uint32_t *sig)
|
|
14300
|
+
{
|
|
14301
|
+
return DisplayCommandReplayer::scrollRowSignatures(vx, vy, vw, vh, sig);
|
|
14302
|
+
}
|
|
14303
|
+
|
|
14304
|
+
bool DisplayList::beginRegionReplay()
|
|
14305
|
+
{
|
|
14306
|
+
return DisplayCommandReplayer::buildRegionIndex();
|
|
14307
|
+
}
|
|
14308
|
+
|
|
14309
|
+
bool DisplayList::regionReplayActive()
|
|
14310
|
+
{
|
|
14311
|
+
return gRegionIndexCount >= 0;
|
|
14312
|
+
}
|
|
14313
|
+
|
|
14314
|
+
bool DisplayList::regionReplayHolds(int x, int y, int w, int h, bool *covered)
|
|
14315
|
+
{
|
|
14316
|
+
if (gRegionIndexCount < 0 || x < gRegionX0 || y < gRegionY0 || x + w - 1 > gRegionX1 || y + h - 1 > gRegionY1)
|
|
14317
|
+
return false;
|
|
14318
|
+
if (covered) *covered = gRegionCovered;
|
|
14319
|
+
return true;
|
|
14320
|
+
}
|
|
14321
|
+
|
|
14322
|
+
void DisplayList::endRegionReplay()
|
|
14323
|
+
{
|
|
14324
|
+
gRegionIndexCount = -1;
|
|
14325
|
+
}
|
|
14326
|
+
|
|
14327
|
+
void DisplayList::setReplayCullStart(int start)
|
|
14328
|
+
{
|
|
14329
|
+
DisplayCommandReplayer::cullStartOverride = start;
|
|
14330
|
+
}
|
|
14331
|
+
|
|
13243
14332
|
void DisplayList::replay()
|
|
13244
14333
|
{
|
|
14334
|
+
if (!gea_replay_stage_active()) gea_display_note_direct_draw();
|
|
13245
14335
|
DisplayCommandReplayer::replay();
|
|
13246
14336
|
}
|
|
13247
14337
|
|