@geastack/engine 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/canvas.cpp +52 -30
- package/css/declarative.h +6 -0
- package/css/engine.h +19 -0
- package/image_store.cpp +136 -33
- package/package.json +2 -2
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +15 -13
- package/ui/core.cpp +23 -0
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +282 -0
- package/ui/image_node.cpp +9 -8
- package/ui/input.cpp +22 -2
- package/ui/input_render.cpp +4 -0
- package/ui/layout.cpp +171 -83
- package/ui/layout_snapshot.cpp +28 -1
- package/ui/node_features.h +18 -0
- package/ui/node_lifecycle.cpp +192 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +631 -71
- package/ui/node_text.h +82 -0
- package/ui/render.cpp +155 -87
- package/ui/renderer_features.h +19 -0
- package/ui/root_scroll_refresh.cpp +31 -14
- package/ui/style.cpp +991 -228
- package/ui/text.cpp +24 -4
- package/ui/tree_events.cpp +135 -95
- package/ui/tree_events.h +28 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +32 -4
- package/ui/tree_render.cpp +48 -19
- package/ui/tree_scroll_mirror.cpp +26 -0
- package/ui/tree_state.cpp +261 -114
- package/ui/tree_state.h +69 -18
- package/ui/tree_style.cpp +339 -72
- package/ui/view.cpp +122 -62
- package/ui/virtual_keyboard.cpp +10 -3
package/ui/node_text.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace gea::embedded::ui
|
|
7
|
+
{
|
|
8
|
+
// Empty nodes own no string storage. Nonempty text lives in stable pooled
|
|
9
|
+
// records, preserving c_str() addresses while other nodes are created/removed.
|
|
10
|
+
// Copies own independent records: retained display commands can scrub one
|
|
11
|
+
// node's old buffer without invalidating a clone's unchanged text.
|
|
12
|
+
class NodeText
|
|
13
|
+
{
|
|
14
|
+
public:
|
|
15
|
+
NodeText() = default;
|
|
16
|
+
NodeText(const NodeText &other);
|
|
17
|
+
NodeText(NodeText &&other) noexcept;
|
|
18
|
+
~NodeText();
|
|
19
|
+
NodeText &operator=(const NodeText &other);
|
|
20
|
+
NodeText &operator=(NodeText &&other) noexcept;
|
|
21
|
+
NodeText &operator=(const std::string &text)
|
|
22
|
+
{
|
|
23
|
+
assign(text.c_str());
|
|
24
|
+
return *this;
|
|
25
|
+
}
|
|
26
|
+
NodeText &operator=(const char *text)
|
|
27
|
+
{
|
|
28
|
+
assign(text);
|
|
29
|
+
return *this;
|
|
30
|
+
}
|
|
31
|
+
// Pool allocation payload (including spare slots/map), excluding string
|
|
32
|
+
// character buffers and allocator metadata. Useful alongside heap census.
|
|
33
|
+
static std::size_t storageBytes();
|
|
34
|
+
void clear();
|
|
35
|
+
void assign(const char *text);
|
|
36
|
+
bool empty() const { return handle_ == kEmpty; }
|
|
37
|
+
const std::string &str() const;
|
|
38
|
+
operator const std::string &() const { return str(); }
|
|
39
|
+
const char *c_str() const { return str().c_str(); }
|
|
40
|
+
const char *data() const { return c_str(); }
|
|
41
|
+
std::size_t size() const { return str().size(); }
|
|
42
|
+
char operator[](std::size_t i) const { return str()[i]; }
|
|
43
|
+
std::size_t find(char c) const { return str().find(c); }
|
|
44
|
+
std::size_t find_first_not_of(const char *chars) const
|
|
45
|
+
{
|
|
46
|
+
return str().find_first_not_of(chars);
|
|
47
|
+
}
|
|
48
|
+
std::string substr(std::size_t pos,
|
|
49
|
+
std::size_t count = std::string::npos) const
|
|
50
|
+
{
|
|
51
|
+
return str().substr(pos, count);
|
|
52
|
+
}
|
|
53
|
+
friend bool operator==(const NodeText &a, const NodeText &b)
|
|
54
|
+
{
|
|
55
|
+
return a.str() == b.str();
|
|
56
|
+
}
|
|
57
|
+
friend bool operator==(const NodeText &a, const std::string &b)
|
|
58
|
+
{
|
|
59
|
+
return a.str() == b;
|
|
60
|
+
}
|
|
61
|
+
friend bool operator==(const NodeText &a, const char *b)
|
|
62
|
+
{
|
|
63
|
+
return a.str() == b;
|
|
64
|
+
}
|
|
65
|
+
friend bool operator!=(const NodeText &a, const NodeText &b)
|
|
66
|
+
{
|
|
67
|
+
return !(a == b);
|
|
68
|
+
}
|
|
69
|
+
friend bool operator!=(const NodeText &a, const std::string &b)
|
|
70
|
+
{
|
|
71
|
+
return !(a == b);
|
|
72
|
+
}
|
|
73
|
+
friend bool operator!=(const NodeText &a, const char *b)
|
|
74
|
+
{
|
|
75
|
+
return !(a == b);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private:
|
|
79
|
+
static constexpr std::uint32_t kEmpty = UINT32_MAX;
|
|
80
|
+
std::uint32_t handle_ = kEmpty;
|
|
81
|
+
};
|
|
82
|
+
} // namespace gea::embedded::ui
|
package/ui/render.cpp
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#include "renderer_features.h"
|
|
2
3
|
#include "internal.h"
|
|
3
4
|
#include "state_init.h"
|
|
4
5
|
#include "canvas.h"
|
|
@@ -268,14 +269,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
268
269
|
#define GEA_EMBEDDED_RECOLOR_PIXEL_CACHE_SIZE 512
|
|
269
270
|
#endif
|
|
270
271
|
|
|
271
|
-
constexpr int kTransformedGradientLutSlots = GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_SLOTS;
|
|
272
|
+
constexpr int kTransformedGradientLutSlots = (GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS) ? GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_SLOTS : 1;
|
|
272
273
|
static_assert(kTransformedGradientLutSlots > 0);
|
|
273
|
-
constexpr int kTransformedGradientLutBanks = GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_BANKS;
|
|
274
|
+
constexpr int kTransformedGradientLutBanks = (GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS) ? GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_BANKS : 1;
|
|
274
275
|
static_assert(kTransformedGradientLutBanks > 0);
|
|
275
276
|
constexpr bool kTransformedGradientA5Mirror = GEA_EMBEDDED_TRANSFORMED_GRADIENT_A5_MIRROR != 0;
|
|
276
277
|
static_assert(kTransformedGradientA5Mirror || GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER == 0,
|
|
277
278
|
"GEA_EMBEDDED_PIE_BLEND_SPAN8_GATHER requires the transformed-gradient a5 mirror");
|
|
278
|
-
constexpr int kProjectedTextCacheBanks = GEA_EMBEDDED_PROJECTED_TEXT_CACHE_BANKS;
|
|
279
|
+
constexpr int kProjectedTextCacheBanks = GEA_EMBEDDED_RENDERER_TRANSFORMS ? GEA_EMBEDDED_PROJECTED_TEXT_CACHE_BANKS : 1;
|
|
279
280
|
static_assert(kProjectedTextCacheBanks > 0);
|
|
280
281
|
constexpr int kScratchDepth = 16;
|
|
281
282
|
constexpr int kFilterBlurPasses = 5;
|
|
@@ -1356,10 +1357,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
1356
1357
|
const int halfMin = std::min(node.layout.width, node.layout.height) / 2;
|
|
1357
1358
|
const int minRadius = std::max(1, halfMin - 1);
|
|
1358
1359
|
return halfMin > 0 &&
|
|
1359
|
-
node.style.border_radius[0] >= minRadius &&
|
|
1360
|
-
node.style.border_radius[1] >= minRadius &&
|
|
1361
|
-
node.style.border_radius[2] >= minRadius &&
|
|
1362
|
-
node.style.border_radius[3] >= minRadius;
|
|
1360
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)] >= minRadius &&
|
|
1361
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)] >= minRadius &&
|
|
1362
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)] >= minRadius &&
|
|
1363
|
+
node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)] >= minRadius;
|
|
1363
1364
|
}
|
|
1364
1365
|
|
|
1365
1366
|
bool screenToNodeRectHomography(const Node &node, double out[8])
|
|
@@ -2010,8 +2011,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
2010
2011
|
return nx * nx + ny * ny <= 1.0;
|
|
2011
2012
|
}
|
|
2012
2013
|
|
|
2013
|
-
const double radius = static_cast<double>(std::min(std::min(node.style.border_radius[0], node.style.border_radius[1]),
|
|
2014
|
-
std::min(node.style.border_radius[2], node.style.border_radius[3])));
|
|
2014
|
+
const double radius = static_cast<double>(std::min(std::min(node.style.border_radius[GEA_CSS_RADIUS_INDEX(0)], node.style.border_radius[GEA_CSS_RADIUS_INDEX(1)]),
|
|
2015
|
+
std::min(node.style.border_radius[GEA_CSS_RADIUS_INDEX(2)], node.style.border_radius[GEA_CSS_RADIUS_INDEX(3)])));
|
|
2015
2016
|
const double r = std::max(0.0, std::min(radius, std::min(w, h) * 0.5));
|
|
2016
2017
|
if (r <= 0.0)
|
|
2017
2018
|
return true;
|
|
@@ -2125,7 +2126,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
2125
2126
|
const double ry = h * 0.5;
|
|
2126
2127
|
if (rx <= 0.0 || ry <= 0.0)
|
|
2127
2128
|
return 0;
|
|
2128
|
-
const double blur = std::max(1.0, static_cast<double>(rstyle(node.style).filter_blur_radius));
|
|
2129
|
+
const double blur = std::max(1.0, static_cast<double>((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0)));
|
|
2129
2130
|
const double dx = std::fabs(sx - (x + rx));
|
|
2130
2131
|
const double dy = std::fabs(sy - (y + ry));
|
|
2131
2132
|
const double alphaX = 1.0 - smoothStep(rx, rx + blur * 2.0, dx);
|
|
@@ -2743,9 +2744,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
2743
2744
|
// thread). Falls back to the per-pixel scan if the label is implausibly large.
|
|
2744
2745
|
const int srcW = command.projectedText.srcW;
|
|
2745
2746
|
const int srcH = command.projectedText.srcH;
|
|
2746
|
-
const bool useBuffer = static_cast<long long>(srcW) * static_cast<long long>(srcH) <= (1LL << 19);
|
|
2747
2747
|
const std::uint8_t *cb = nullptr;
|
|
2748
2748
|
int inkX0 = 0, inkY0 = 0, inkX1 = srcW - 1, inkY1 = srcH - 1;
|
|
2749
|
+
const bool useBuffer = static_cast<long long>(srcW) * static_cast<long long>(srcH) <= (1LL << 19);
|
|
2750
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
2749
2751
|
if (useBuffer)
|
|
2750
2752
|
{
|
|
2751
2753
|
// Coverage buffer is text-space (independent of the 3D projection), so it's
|
|
@@ -2901,6 +2903,21 @@ int gLastScrollUiFrame = -1000;
|
|
|
2901
2903
|
inkY1 = hit->ink[3];
|
|
2902
2904
|
}
|
|
2903
2905
|
else
|
|
2906
|
+
#else
|
|
2907
|
+
// A native/dynamic instruction missed by source analysis still uses the
|
|
2908
|
+
// identical coverage rasterization and Q8 sampling. Only this call owns
|
|
2909
|
+
// the scratch; no transform-free app reserves a bank or retains a bitmap.
|
|
2910
|
+
std::vector<std::uint8_t> uncachedCoverage;
|
|
2911
|
+
if (useBuffer) {
|
|
2912
|
+
uncachedCoverage.resize(static_cast<std::size_t>(srcW) * srcH);
|
|
2913
|
+
int ink[4];
|
|
2914
|
+
buildProjectedTextAlpha(command, font, uncachedCoverage.data(), srcW, srcH, ink);
|
|
2915
|
+
if (ink[2] < ink[0]) return;
|
|
2916
|
+
cb = uncachedCoverage.data();
|
|
2917
|
+
inkX0 = ink[0]; inkY0 = ink[1]; inkX1 = ink[2]; inkY1 = ink[3];
|
|
2918
|
+
}
|
|
2919
|
+
else
|
|
2920
|
+
#endif
|
|
2904
2921
|
{
|
|
2905
2922
|
refreshPerfStatsMutable().projectedTextCacheFallbacks++;
|
|
2906
2923
|
}
|
|
@@ -3384,6 +3401,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
3384
3401
|
// so an app that never fills a transformed gradient reserves ZERO RAM for
|
|
3385
3402
|
// this ~26 KB LUT bank scratch — it used to sit in .bss unconditionally for
|
|
3386
3403
|
// every app. Allocated on the first transformed-gradient fill; never freed.
|
|
3404
|
+
#if GEA_EMBEDDED_RENDERER_TRANSFORMS && GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
3387
3405
|
using FaceLutBank = FaceLutSlot[kTransformedGradientLutSlots];
|
|
3388
3406
|
static FaceLutBank *const slotsByBank = []() -> FaceLutBank *
|
|
3389
3407
|
{
|
|
@@ -3413,6 +3431,16 @@ int gLastScrollUiFrame = -1000;
|
|
|
3413
3431
|
auto &slots = slotsByBank[lutBank];
|
|
3414
3432
|
int &slotRR = slotRRByBank[lutBank];
|
|
3415
3433
|
std::uint8_t *const slotConstAlpha = slotConstAlphaByBank[lutBank];
|
|
3434
|
+
|
|
3435
|
+
#else
|
|
3436
|
+
FaceLutSlot slots[1]{};
|
|
3437
|
+
int slotRR = 0;
|
|
3438
|
+
std::uint8_t slotConstAlpha[1]{};
|
|
3439
|
+
#if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
|
|
3440
|
+
volatile unsigned char slotLockByBank[1]{};
|
|
3441
|
+
constexpr int lutBank = 0;
|
|
3442
|
+
#endif
|
|
3443
|
+
#endif
|
|
3416
3444
|
#if GEA_EMBEDDED_TRANSFORMED_GRADIENT_LUT_LOCK
|
|
3417
3445
|
volatile unsigned char &slotLock = slotLockByBank[lutBank];
|
|
3418
3446
|
auto lockSlots = [&slotLock]()
|
|
@@ -5285,6 +5313,29 @@ int gLastScrollUiFrame = -1000;
|
|
|
5285
5313
|
gea::framework::graphics::pixel::native_t color;
|
|
5286
5314
|
};
|
|
5287
5315
|
|
|
5316
|
+
static DitherStop ditherStop(int r, int g, int b, uint8_t alpha)
|
|
5317
|
+
{
|
|
5318
|
+
DitherStop stop{};
|
|
5319
|
+
auto split = [](int value, int levels, uint8_t &q, uint8_t &rem) {
|
|
5320
|
+
const int scaled = std::clamp(value, 0, 255) * levels;
|
|
5321
|
+
q = static_cast<uint8_t>(scaled / 255);
|
|
5322
|
+
rem = static_cast<uint8_t>(scaled % 255);
|
|
5323
|
+
};
|
|
5324
|
+
split(r, 31, stop.qR, stop.remR);
|
|
5325
|
+
split(g, 63, stop.qG, stop.remG);
|
|
5326
|
+
split(b, 31, stop.qB, stop.remB);
|
|
5327
|
+
stop.color = gea::framework::graphics::pixel::packNative8(r, g, b);
|
|
5328
|
+
stop.alpha = alpha;
|
|
5329
|
+
return stop;
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
static DitherStop ditherAt(const DisplayCommand &c, int p)
|
|
5333
|
+
{
|
|
5334
|
+
int r, g, b;
|
|
5335
|
+
rgb888At(c, p, &r, &g, &b);
|
|
5336
|
+
return ditherStop(r, g, b, alphaAt(c, p));
|
|
5337
|
+
}
|
|
5338
|
+
|
|
5288
5339
|
// Un-dithered RGB888 color at a gradient position. Carries every integer
|
|
5289
5340
|
// divide in the gradient (mid-stop remap, RGB565->888 unpack, channel
|
|
5290
5341
|
// interpolation). The S3 has no fast integer divide, so calling this per
|
|
@@ -5457,6 +5508,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
5457
5508
|
// flush's expected per-row dirty pattern and hung the panel TX. Going through
|
|
5458
5509
|
// blitImage() keeps the cache provably equivalent to the stable path.) Gated on
|
|
5459
5510
|
// opaque + large + stable so animated/small/alpha gradients render normally.
|
|
5511
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
5460
5512
|
auto *bgCanvas = gea::platform::display::Display::canvas();
|
|
5461
5513
|
int bgCap = 0;
|
|
5462
5514
|
gea::framework::graphics::pixel::native_t *bgBuf = gea_bg_cache(&bgCap);
|
|
@@ -5520,6 +5572,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
5520
5572
|
if (transCacheable && transCache.blit(transKey, 14, x0, y0, x1, y1, scrW, scrH, transSpan))
|
|
5521
5573
|
return;
|
|
5522
5574
|
|
|
5575
|
+
#endif
|
|
5576
|
+
|
|
5523
5577
|
const double angleRadians = (static_cast<double>(c.gradient.angle) * kPi) / 1800.0;
|
|
5524
5578
|
double dx = std::sin(angleRadians);
|
|
5525
5579
|
double dy = -std::cos(angleRadians);
|
|
@@ -5586,6 +5640,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
5586
5640
|
#ifndef GEA_EMBEDDED_LAZY_GRADIENT_LUTS
|
|
5587
5641
|
#define GEA_EMBEDDED_LAZY_GRADIENT_LUTS 0
|
|
5588
5642
|
#endif
|
|
5643
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
5589
5644
|
struct LutSlot
|
|
5590
5645
|
{
|
|
5591
5646
|
DitherStop lut[1001];
|
|
@@ -5641,32 +5696,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
5641
5696
|
{
|
|
5642
5697
|
for (int p = 0; p <= 1000; p++)
|
|
5643
5698
|
{
|
|
5644
|
-
|
|
5645
|
-
rgb888At(c, p, &r, &g, &b);
|
|
5646
|
-
auto split = [](int value, int levels, uint8_t *q, uint8_t *rem)
|
|
5647
|
-
{
|
|
5648
|
-
if (value <= 0)
|
|
5649
|
-
{
|
|
5650
|
-
*q = 0;
|
|
5651
|
-
*rem = 0;
|
|
5652
|
-
return;
|
|
5653
|
-
}
|
|
5654
|
-
if (value >= 255)
|
|
5655
|
-
{
|
|
5656
|
-
*q = static_cast<uint8_t>(levels);
|
|
5657
|
-
*rem = 0;
|
|
5658
|
-
return;
|
|
5659
|
-
}
|
|
5660
|
-
const int scaled = value * levels;
|
|
5661
|
-
const int qq = scaled / 255;
|
|
5662
|
-
*q = static_cast<uint8_t>(qq);
|
|
5663
|
-
*rem = static_cast<uint8_t>(scaled - qq * 255);
|
|
5664
|
-
};
|
|
5665
|
-
split(r, 31, &lut[p].qR, &lut[p].remR);
|
|
5666
|
-
split(g, 63, &lut[p].qG, &lut[p].remG);
|
|
5667
|
-
split(b, 31, &lut[p].qB, &lut[p].remB);
|
|
5668
|
-
lut[p].color = gea::framework::graphics::pixel::packNative8(r, g, b);
|
|
5669
|
-
lut[p].alpha = alphaAt(c, p);
|
|
5699
|
+
lut[p] = ditherAt(c, p);
|
|
5670
5700
|
}
|
|
5671
5701
|
lutKey[0] = c.gradient.fromColor;
|
|
5672
5702
|
lutKey[1] = c.gradient.midColor;
|
|
@@ -5678,6 +5708,13 @@ int gLastScrollUiFrame = -1000;
|
|
|
5678
5708
|
lutKeyA[2] = c.gradient.toAlpha;
|
|
5679
5709
|
lutKeyA[3] = c.gradient.hasMid;
|
|
5680
5710
|
}
|
|
5711
|
+
#else
|
|
5712
|
+
struct UncachedLut {
|
|
5713
|
+
const DisplayCommand &command;
|
|
5714
|
+
DitherStop operator[](int p) const { return ditherAt(command, p); }
|
|
5715
|
+
} lut{c};
|
|
5716
|
+
#endif
|
|
5717
|
+
|
|
5681
5718
|
static constexpr uint8_t bayer4[4][4] = {
|
|
5682
5719
|
{0, 8, 2, 10},
|
|
5683
5720
|
{12, 4, 14, 6},
|
|
@@ -5702,8 +5739,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
5702
5739
|
const float stepY = static_cast<float>(dy);
|
|
5703
5740
|
const float fMinProjection = static_cast<float>(minProjection);
|
|
5704
5741
|
const float invSpanPermille = 1000.0f / static_cast<float>(projectionSpan);
|
|
5705
|
-
|
|
5706
|
-
static
|
|
5742
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
5743
|
+
static
|
|
5744
|
+
#endif
|
|
5745
|
+
gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
|
|
5746
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
5747
|
+
static
|
|
5748
|
+
#endif
|
|
5749
|
+
uint8_t rowAlpha[gea::platform::display::kWidth];
|
|
5707
5750
|
for (int y = y0; y <= y1; y++)
|
|
5708
5751
|
{
|
|
5709
5752
|
int rowX0 = x0;
|
|
@@ -5772,6 +5815,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
5772
5815
|
}
|
|
5773
5816
|
}
|
|
5774
5817
|
|
|
5818
|
+
#if GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
5775
5819
|
// Once the gradient has been identical for 2 frames, render it in full into
|
|
5776
5820
|
// the cache buffer (reusing the LUT/projection just computed); subsequent
|
|
5777
5821
|
// frames hit the blit fast-path above. One-time ~full-screen render; writes
|
|
@@ -5895,6 +5939,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
5895
5939
|
}
|
|
5896
5940
|
});
|
|
5897
5941
|
}
|
|
5942
|
+
#endif
|
|
5898
5943
|
}
|
|
5899
5944
|
};
|
|
5900
5945
|
|
|
@@ -5989,6 +6034,16 @@ int gLastScrollUiFrame = -1000;
|
|
|
5989
6034
|
localPermille(c, permille));
|
|
5990
6035
|
}
|
|
5991
6036
|
|
|
6037
|
+
static LinearGradientDrawer::DitherStop ditherAt(const DisplayCommand &c, int p)
|
|
6038
|
+
{
|
|
6039
|
+
const int lp = localPermille(c, p);
|
|
6040
|
+
int r, g, b;
|
|
6041
|
+
LinearGradientDrawer::interpolatePremultipliedRgb888(c.radialGradient.fromColor, c.radialGradient.fromAlpha,
|
|
6042
|
+
c.radialGradient.toColor, c.radialGradient.toAlpha, lp, &r, &g, &b);
|
|
6043
|
+
return LinearGradientDrawer::ditherStop(r, g, b,
|
|
6044
|
+
LinearGradientDrawer::interpolateAlpha(c.radialGradient.fromAlpha, c.radialGradient.toAlpha, lp));
|
|
6045
|
+
}
|
|
6046
|
+
|
|
5992
6047
|
static void replay(const DisplayCommand &c)
|
|
5993
6048
|
{
|
|
5994
6049
|
int cx0, cy0, cx1, cy1;
|
|
@@ -6015,6 +6070,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6015
6070
|
// warm-glow radial is static — fixed colors + box, identical across themes
|
|
6016
6071
|
// (only the base linear layer changes) — so cache it once and blit instead of
|
|
6017
6072
|
// recomputing sqrt + dither per pixel. Gated to reasonably large boxes.
|
|
6073
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6018
6074
|
auto *rcanvas = gea::platform::display::Display::canvas();
|
|
6019
6075
|
const int scrW = rcanvas ? rcanvas->width() : 0;
|
|
6020
6076
|
const int scrH = rcanvas ? rcanvas->height() : 0;
|
|
@@ -6036,9 +6092,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
6036
6092
|
if (cacheable && cache.blit(keyNow, 17, x0, y0, x1, y1, scrW, scrH, span))
|
|
6037
6093
|
return;
|
|
6038
6094
|
|
|
6095
|
+
#endif
|
|
6096
|
+
|
|
6039
6097
|
// Divide-free dither LUT indexed by local permille (0..1000), cached across
|
|
6040
6098
|
// calls keyed by the color stops (mirrors LinearGradientDrawer). The per-pixel
|
|
6041
6099
|
// dither becomes a table read + 3 threshold compares — no divides.
|
|
6100
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6042
6101
|
#if GEA_EMBEDDED_LAZY_GRADIENT_LUTS
|
|
6043
6102
|
static auto lutStorage = std::make_unique<std::array<LinearGradientDrawer::DitherStop, 1001>>();
|
|
6044
6103
|
auto &lut = *lutStorage;
|
|
@@ -6058,34 +6117,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6058
6117
|
// clamps to 1000, which localPermille also maps to 1000).
|
|
6059
6118
|
for (int p = 0; p <= 1000; ++p)
|
|
6060
6119
|
{
|
|
6061
|
-
|
|
6062
|
-
int r = 0, g = 0, b = 0;
|
|
6063
|
-
LinearGradientDrawer::interpolatePremultipliedRgb888(c.radialGradient.fromColor, c.radialGradient.fromAlpha,
|
|
6064
|
-
c.radialGradient.toColor, c.radialGradient.toAlpha, lp, &r, &g, &b);
|
|
6065
|
-
auto split = [](int value, int levels, uint8_t *q, uint8_t *rem)
|
|
6066
|
-
{
|
|
6067
|
-
if (value <= 0)
|
|
6068
|
-
{
|
|
6069
|
-
*q = 0;
|
|
6070
|
-
*rem = 0;
|
|
6071
|
-
return;
|
|
6072
|
-
}
|
|
6073
|
-
if (value >= 255)
|
|
6074
|
-
{
|
|
6075
|
-
*q = static_cast<uint8_t>(levels);
|
|
6076
|
-
*rem = 0;
|
|
6077
|
-
return;
|
|
6078
|
-
}
|
|
6079
|
-
const int scaled = value * levels;
|
|
6080
|
-
const int qq = scaled / 255;
|
|
6081
|
-
*q = static_cast<uint8_t>(qq);
|
|
6082
|
-
*rem = static_cast<uint8_t>(scaled - qq * 255);
|
|
6083
|
-
};
|
|
6084
|
-
split(r, 31, &lut[p].qR, &lut[p].remR);
|
|
6085
|
-
split(g, 63, &lut[p].qG, &lut[p].remG);
|
|
6086
|
-
split(b, 31, &lut[p].qB, &lut[p].remB);
|
|
6087
|
-
lut[p].color = gea::framework::graphics::pixel::packNative8(r, g, b);
|
|
6088
|
-
lut[p].alpha = LinearGradientDrawer::interpolateAlpha(c.radialGradient.fromAlpha, c.radialGradient.toAlpha, lp);
|
|
6120
|
+
lut[p] = ditherAt(c, p);
|
|
6089
6121
|
}
|
|
6090
6122
|
lutKeyFrom = c.radialGradient.fromColor;
|
|
6091
6123
|
lutKeyTo = c.radialGradient.toColor;
|
|
@@ -6093,6 +6125,13 @@ int gLastScrollUiFrame = -1000;
|
|
|
6093
6125
|
lutKeyToA = c.radialGradient.toAlpha;
|
|
6094
6126
|
lutKeyStop = c.radialGradient.stopPermille;
|
|
6095
6127
|
}
|
|
6128
|
+
#else
|
|
6129
|
+
struct UncachedLut {
|
|
6130
|
+
const DisplayCommand &command;
|
|
6131
|
+
LinearGradientDrawer::DitherStop operator[](int p) const { return ditherAt(command, p); }
|
|
6132
|
+
} lut{c};
|
|
6133
|
+
#endif
|
|
6134
|
+
|
|
6096
6135
|
static constexpr uint8_t bayer4[4][4] = {
|
|
6097
6136
|
{0, 8, 2, 10},
|
|
6098
6137
|
{12, 4, 14, 6},
|
|
@@ -6104,8 +6143,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
6104
6143
|
// row into ~1px writes (each paying a clip + framebuffer read-back + dirty-list
|
|
6105
6144
|
// scan) — the radial's real cost, just like the linear drawer. blitImage clips
|
|
6106
6145
|
// and marks dirty once per row. (baseAlpha is read from Display::alpha() inside.)
|
|
6107
|
-
|
|
6108
|
-
static
|
|
6146
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6147
|
+
static
|
|
6148
|
+
#endif
|
|
6149
|
+
gea::framework::graphics::pixel::native_t rowColor[gea::platform::display::kWidth];
|
|
6150
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6151
|
+
static
|
|
6152
|
+
#endif
|
|
6153
|
+
uint8_t rowAlpha[gea::platform::display::kWidth];
|
|
6109
6154
|
// Mirror gate: a pixel xx and its mirror (mirrorSum - xx) have dx values
|
|
6110
6155
|
// that are exact float negations of each other when 2*centerX lands on an
|
|
6111
6156
|
// integer grid (e.g. the shell glow's `at 50%`), so dx*dx — and therefore
|
|
@@ -6115,7 +6160,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
6115
6160
|
const float mirrorSumF = 2.0f * centerX - 1.0f;
|
|
6116
6161
|
const int mirrorSum = static_cast<int>(mirrorSumF);
|
|
6117
6162
|
const bool mirrorable = mirrorSumF == static_cast<float>(mirrorSum);
|
|
6118
|
-
|
|
6163
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6164
|
+
static
|
|
6165
|
+
#endif
|
|
6166
|
+
std::uint16_t rowPermille[gea::platform::display::kWidth];
|
|
6119
6167
|
for (int y = y0; y <= y1; ++y)
|
|
6120
6168
|
{
|
|
6121
6169
|
int rowX0 = x0;
|
|
@@ -6163,6 +6211,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6163
6211
|
}
|
|
6164
6212
|
}
|
|
6165
6213
|
|
|
6214
|
+
#if GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
6166
6215
|
// Bake the full box into the cache once params are stable for 2 frames.
|
|
6167
6216
|
if (cacheable)
|
|
6168
6217
|
{
|
|
@@ -6184,6 +6233,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6184
6233
|
*alp = e.alpha;
|
|
6185
6234
|
});
|
|
6186
6235
|
}
|
|
6236
|
+
#endif
|
|
6187
6237
|
}
|
|
6188
6238
|
};
|
|
6189
6239
|
|
|
@@ -6547,12 +6597,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
6547
6597
|
|
|
6548
6598
|
static void recordFilterBlur(int id, const Node &node, DisplayCommandType type, uint8_t parentAlpha)
|
|
6549
6599
|
{
|
|
6550
|
-
if (rstyle(node.style).filter_blur_radius <= 0)
|
|
6600
|
+
if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) <= 0)
|
|
6551
6601
|
return;
|
|
6552
6602
|
if (node.layout.width <= 0 || node.layout.height <= 0)
|
|
6553
6603
|
return;
|
|
6554
6604
|
const bool sourceLayerBlur = filterBlurSourceAlphaCap(node, parentAlpha) >= 0;
|
|
6555
|
-
const int localSpread = sourceLayerBlur ? std::max(0, static_cast<int>(rstyle(node.style).filter_blur_radius)) * kFilterBlurPasses : 0;
|
|
6605
|
+
const int localSpread = sourceLayerBlur ? std::max(0, static_cast<int>((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0))) * kFilterBlurPasses : 0;
|
|
6556
6606
|
int16_t xs[4] = {};
|
|
6557
6607
|
int16_t ys[4] = {};
|
|
6558
6608
|
ViewRenderer::transformedRectCorners(node, false,
|
|
@@ -6578,9 +6628,9 @@ int gLastScrollUiFrame = -1000;
|
|
|
6578
6628
|
}
|
|
6579
6629
|
if (x0 > x1 || y0 > y1)
|
|
6580
6630
|
return;
|
|
6581
|
-
int radiusX = rstyle(node.style).filter_blur_radius;
|
|
6582
|
-
int radiusY = rstyle(node.style).filter_blur_radius;
|
|
6583
|
-
filterBlurScreenRadii(node, rstyle(node.style).filter_blur_radius, &radiusX, &radiusY);
|
|
6631
|
+
int radiusX = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
|
|
6632
|
+
int radiusY = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
|
|
6633
|
+
filterBlurScreenRadii(node, (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0), &radiusX, &radiusY);
|
|
6584
6634
|
const int spreadX = sourceLayerBlur ? 0 : std::max(0, radiusX) * kFilterBlurPasses;
|
|
6585
6635
|
const int spreadY = sourceLayerBlur ? 0 : std::max(0, radiusY) * kFilterBlurPasses;
|
|
6586
6636
|
x0 -= spreadX;
|
|
@@ -6596,7 +6646,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6596
6646
|
cmd->bw = static_cast<int16_t>(clampInt(x1 - x0 + 1, 0, 32767));
|
|
6597
6647
|
cmd->bh = static_cast<int16_t>(clampInt(y1 - y0 + 1, 0, 32767));
|
|
6598
6648
|
cmd->filterBlur.nodeId = static_cast<int16_t>(id);
|
|
6599
|
-
cmd->filterBlur.radius = rstyle(node.style).filter_blur_radius;
|
|
6649
|
+
cmd->filterBlur.radius = (GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0);
|
|
6600
6650
|
cmd->filterBlur.radiusX = static_cast<int16_t>(clampInt(radiusX, 0, 32767));
|
|
6601
6651
|
cmd->filterBlur.radiusY = static_cast<int16_t>(clampInt(radiusY, 0, 32767));
|
|
6602
6652
|
cmd->filterBlur.sourceAlphaCap = static_cast<int16_t>(filterBlurSourceAlphaCap(node, parentAlpha));
|
|
@@ -6731,7 +6781,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
6731
6781
|
int draw_start = state.commandCount;
|
|
6732
6782
|
const bool paintsOwnBox = overlaps_clip && n->style.visibility == 0;
|
|
6733
6783
|
const bool nativeTextInput = isNativeTextInputView(*n);
|
|
6734
|
-
const bool filtered = overlaps_clip && rstyle(n->style).filter_blur_radius > 0;
|
|
6784
|
+
const bool filtered = overlaps_clip && (GEA_CSS_FILTERS ? rstyle(n->style).filter_blur_radius : 0) > 0;
|
|
6735
6785
|
uint8_t draw_alpha = cur_alpha;
|
|
6736
6786
|
bool pushed_mask_alpha = false;
|
|
6737
6787
|
if (active_mask && active_mask->style.mask_right_fade_width > 0)
|
|
@@ -7592,7 +7642,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
7592
7642
|
for (int i = 0; i < nodeCount; i++)
|
|
7593
7643
|
{
|
|
7594
7644
|
const Node &node = nodes[i];
|
|
7595
|
-
if (rstyle(node.style).filter_blur_radius > 0)
|
|
7645
|
+
if ((GEA_CSS_FILTERS ? rstyle(node.style).filter_blur_radius : 0) > 0)
|
|
7596
7646
|
{ SRDBG("blur node", i); return false; }
|
|
7597
7647
|
if (node.style.opacity != 255 && node.style.opacity != 0)
|
|
7598
7648
|
{ SRDBG("opacity node", i); return false; }
|
|
@@ -7892,6 +7942,14 @@ int gLastScrollUiFrame = -1000;
|
|
|
7892
7942
|
for (int id = origin; id >= 0 && chainLen < 32; id = nodes[id].parent)
|
|
7893
7943
|
chain[chainLen++] = id;
|
|
7894
7944
|
const int originOrder = drawOrderIndexForSimpleReplay(origin);
|
|
7945
|
+
// An opaque image can cover the origin's ancestors completely.
|
|
7946
|
+
// Use the ordered cull walk instead of repainting those ancestors
|
|
7947
|
+
// immediately before the image overwrites them.
|
|
7948
|
+
if (occlusionCullStartIndex(x0, y0, x1, y1, nodes, nodeCount) > 0)
|
|
7949
|
+
{
|
|
7950
|
+
replaySimpleClippedDirtyRegionFast(x0, y0, x1, y1);
|
|
7951
|
+
return;
|
|
7952
|
+
}
|
|
7895
7953
|
if (!simpleOriginReplayCanSkipEarlierNodes(chain, chainLen, originOrder, x0, y0, x1, y1))
|
|
7896
7954
|
{
|
|
7897
7955
|
replaySimpleClippedDirtyRegionFast(x0, y0, x1, y1);
|
|
@@ -8363,12 +8421,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
8363
8421
|
}
|
|
8364
8422
|
|
|
8365
8423
|
// Painter's-algorithm occlusion cull: the LAST node (in draw order) whose
|
|
8366
|
-
// first command is an opaque
|
|
8424
|
+
// first command is an opaque fill or image covering the region occludes
|
|
8367
8425
|
// everything drawn before it — the replay walk can start there. A page-sized
|
|
8368
8426
|
// UI (e-reader page turn) stacks several full-bleed paper fills under the
|
|
8369
8427
|
// content; each is a full PSRAM write of the region, so skipping the covered
|
|
8370
8428
|
// ones removes ~100 ms/turn on a 540×960 GRAY4 panel. Conservative: the
|
|
8371
|
-
// cover must be untransformed
|
|
8429
|
+
// cover must be untransformed, at full effective alpha,
|
|
8372
8430
|
// its node's first command, never blinking, and not shrunk by any ancestor
|
|
8373
8431
|
// overflow clip smaller than the region.
|
|
8374
8432
|
static int GEA_RENDER_HOT_SRAM occlusionCullStartIndex(int x0, int y0, int x1, int y1, Node *nodes, int nodeCount)
|
|
@@ -8390,10 +8448,16 @@ int gLastScrollUiFrame = -1000;
|
|
|
8390
8448
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
8391
8449
|
continue;
|
|
8392
8450
|
const DisplayCommand &c = state.commands[start];
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8451
|
+
bool covers = false;
|
|
8452
|
+
if (c.type == DisplayCommandType::FillRect)
|
|
8453
|
+
covers = c.fill.x <= x0 && c.fill.y <= y0 &&
|
|
8454
|
+
c.fill.x + c.fill.w - 1 >= x1 && c.fill.y + c.fill.h - 1 >= y1;
|
|
8455
|
+
else if (c.type == DisplayCommandType::BlitImage)
|
|
8456
|
+
covers = c.blit.pixels && !c.blit.alpha &&
|
|
8457
|
+
c.blit.dx <= x0 && c.blit.dy <= y0 &&
|
|
8458
|
+
c.blit.dx + c.blit.sourceWidth - 1 >= x1 &&
|
|
8459
|
+
c.blit.dy + c.blit.sourceHeight - 1 >= y1;
|
|
8460
|
+
if (!covers || c.textClipOwner >= 0)
|
|
8397
8461
|
continue;
|
|
8398
8462
|
// The recorded paint bbox must also cover the region (guards against
|
|
8399
8463
|
// any recording that paints less than the command rect suggests).
|
|
@@ -9804,7 +9868,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9804
9868
|
|
|
9805
9869
|
for (int i = 0; i < tree.nodeCount(); i++)
|
|
9806
9870
|
{
|
|
9807
|
-
if (rstyle(nodes[i].style).filter_blur_radius > 0)
|
|
9871
|
+
if ((GEA_CSS_FILTERS ? rstyle(nodes[i].style).filter_blur_radius : 0) > 0)
|
|
9808
9872
|
return false;
|
|
9809
9873
|
if (nodes[i].style.overflow == 2)
|
|
9810
9874
|
return false;
|
|
@@ -10123,7 +10187,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
10123
10187
|
const Node &probe = nodes[id];
|
|
10124
10188
|
const bool paintsBox =
|
|
10125
10189
|
(probe.style.has_bg && (probe.style.bg_alpha > 0 || styleHasBackgroundImage(probe.style))) ||
|
|
10126
|
-
rstyle(probe.style).box_shadow_alpha > 0;
|
|
10190
|
+
(GEA_CSS_BOX_SHADOW ? rstyle(probe.style).box_shadow_alpha : 0) > 0;
|
|
10127
10191
|
if (!paintsBox)
|
|
10128
10192
|
continue;
|
|
10129
10193
|
}
|
|
@@ -12316,6 +12380,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
12316
12380
|
|
|
12317
12381
|
bool DisplayList::patchScrollbarThumb(int node)
|
|
12318
12382
|
{
|
|
12383
|
+
#if GEA_CSS_SCROLLING
|
|
12319
12384
|
Tree &tree = Tree::instance();
|
|
12320
12385
|
Node *nodes = tree.nodes();
|
|
12321
12386
|
if (!state.commands || node < 0 || node >= tree.nodeCount())
|
|
@@ -12362,7 +12427,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
12362
12427
|
return true;
|
|
12363
12428
|
}
|
|
12364
12429
|
return false;
|
|
12365
|
-
|
|
12430
|
+
#else
|
|
12431
|
+
(void)node; return true;
|
|
12432
|
+
#endif
|
|
12433
|
+
}
|
|
12366
12434
|
|
|
12367
12435
|
void DisplayList::replayDirectDirtyRegion(int x0, int y0, int x1, int y1, int origin)
|
|
12368
12436
|
{
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
// Generated from the app's source/style analysis by the build driver. These
|
|
5
|
+
// describe reachable instructions, not app configuration switches. Builds made
|
|
6
|
+
// without an analyzer retain the complete renderer. Cache sizing only matters
|
|
7
|
+
// inside a feature's enabled branch; the disabled branches use no cache storage.
|
|
8
|
+
#ifndef GEA_EMBEDDED_RENDERER_CIRCLES
|
|
9
|
+
#define GEA_EMBEDDED_RENDERER_CIRCLES 1
|
|
10
|
+
#endif
|
|
11
|
+
#ifndef GEA_EMBEDDED_RENDERER_TRANSFORMS
|
|
12
|
+
#define GEA_EMBEDDED_RENDERER_TRANSFORMS 1
|
|
13
|
+
#endif
|
|
14
|
+
#ifndef GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS
|
|
15
|
+
#define GEA_EMBEDDED_RENDERER_LINEAR_GRADIENTS 1
|
|
16
|
+
#endif
|
|
17
|
+
#ifndef GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS
|
|
18
|
+
#define GEA_EMBEDDED_RENDERER_RADIAL_GRADIENTS 1
|
|
19
|
+
#endif
|