@geastack/engine 0.1.6 → 0.1.8
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 +105 -48
- package/css/declarative.h +6 -0
- package/css/engine.h +20 -0
- package/image_store.cpp +136 -33
- package/package.json +4 -3
- package/ui/CSS_FEATURES.md +261 -0
- package/ui/absolute_leaf_refresh.cpp +77 -62
- package/ui/core.cpp +26 -3
- package/ui/css_atom.cpp +6 -0
- package/ui/css_atom.h +2 -0
- package/ui/css_features.h +369 -0
- package/ui/document.cpp +11 -0
- package/ui/image_node.cpp +25 -24
- package/ui/input.cpp +46 -26
- package/ui/input_render.cpp +31 -27
- package/ui/internal.h +22 -0
- package/ui/layout.cpp +899 -613
- package/ui/layout_snapshot.cpp +29 -2
- package/ui/node_features.h +36 -0
- package/ui/node_lifecycle.cpp +358 -84
- package/ui/node_lifecycle.h +1 -0
- package/ui/node_model.h +816 -96
- package/ui/node_text.h +84 -0
- package/ui/refresh_perf.h +19 -17
- package/ui/render.cpp +341 -259
- package/ui/renderer_features.h +24 -0
- package/ui/root_scroll_refresh.cpp +86 -69
- package/ui/storage_usage.h +45 -0
- package/ui/style.cpp +1398 -349
- package/ui/style_values.h +2 -2
- package/ui/text.cpp +172 -154
- package/ui/tree_events.cpp +218 -92
- package/ui/tree_events.h +44 -20
- package/ui/tree_inspection.h +15 -0
- package/ui/tree_nodes.cpp +51 -19
- package/ui/tree_render.cpp +159 -126
- package/ui/tree_scroll_mirror.cpp +30 -4
- package/ui/tree_state.cpp +334 -115
- package/ui/tree_state.h +118 -22
- package/ui/tree_style.cpp +679 -303
- package/ui/view.cpp +268 -208
- package/ui/virtual_keyboard.cpp +18 -11
package/README.md
CHANGED
|
@@ -24,6 +24,76 @@ The component prop types live in `@geastack/core`. The C++ sources are
|
|
|
24
24
|
compiled into a target through `@geastack/core`'s source manifest. Vendored
|
|
25
25
|
third-party code is listed in the repository's `THIRD_PARTY.md`.
|
|
26
26
|
|
|
27
|
+
## Renderer cache reachability
|
|
28
|
+
|
|
29
|
+
ESP32 app builds derive renderer cache storage from the Gea compiler plugin's
|
|
30
|
+
source analysis. Circle operations, CSS transforms, linear gradients and radial
|
|
31
|
+
gradients each retain their own caches only when used. A video canvas that calls
|
|
32
|
+
`clearRect` and `drawImage`, for example, does not reserve circle tables. Ordinary
|
|
33
|
+
rounded corners continue to render without them.
|
|
34
|
+
|
|
35
|
+
The analysis follows source imports, imported CSS and CSS `@import`, JSX style
|
|
36
|
+
objects, style assignments and DOM style setters. Unknown styles or opaque
|
|
37
|
+
imports conservatively retain the corresponding features. The CLI passes the
|
|
38
|
+
result to both the app and the shared engine; no per-app switches are needed.
|
|
39
|
+
Position storage is selected independently for each physical edge and for
|
|
40
|
+
pixel versus percentage offsets. Unknown/logical insets retain every possible
|
|
41
|
+
edge. Native inputs and lists retain the edges they can mutate. The selected
|
|
42
|
+
fields remain embedded, aligned members; selection happens at compile time,
|
|
43
|
+
with no runtime accessor or extra pointer load. Cached style operations also
|
|
44
|
+
omit transform payloads when transforms are absent.
|
|
45
|
+
|
|
46
|
+
Text and border alpha bytes are omitted only when the complete source graph
|
|
47
|
+
proves every reachable color opaque. Literal CSS, custom-color definitions,
|
|
48
|
+
immutable local bindings and bounded palette/getter values participate in that
|
|
49
|
+
build-time proof. Unknown receivers, writes, escaping objects, palette mutation,
|
|
50
|
+
reflection, and native controls retain storage. Background alpha is independent.
|
|
51
|
+
The retained values stay inline; omitted fields read as the constant 255.
|
|
52
|
+
Node records reuse tail padding while preserving member assignment and reset
|
|
53
|
+
semantics, without a pointer lookup or packed-field decoding.
|
|
54
|
+
|
|
55
|
+
CSS animation support is likewise derived from whole-source reachability.
|
|
56
|
+
Animation/transition declarations, keyframes, `data-anim`, imperative animation
|
|
57
|
+
APIs and opaque styles/native UI calls retain it. Animation-free apps omit the
|
|
58
|
+
compiled animation handle in each CSS rule, active-list storage, priming and
|
|
59
|
+
per-frame animation polling. `requestAnimationFrame` is independent and remains
|
|
60
|
+
available. Older analysis versions retain the full animation engine; application
|
|
61
|
+
defines cannot override the proof. Enabled animation and frame-scheduling tests
|
|
62
|
+
run alongside the pruned geometry/pixel checks.
|
|
63
|
+
|
|
64
|
+
Generated `::before`/`::after` node support is also automatic. Literal selectors,
|
|
65
|
+
`content` writes and opaque CSS/native mutation retain it; older analyzers keep
|
|
66
|
+
support by default. First-line and animation buckets remain independent. Absent
|
|
67
|
+
families reserve no rule-plan buckets or cached bucket counters. CSS resets copy
|
|
68
|
+
an immutable default style directly, without constructing a temporary Node or
|
|
69
|
+
initializing unrelated text, links, layout and render state.
|
|
70
|
+
|
|
71
|
+
Cache-size definitions affect only retained features. Older analyzers and native
|
|
72
|
+
builds without feature analysis keep the full engine defaults.
|
|
73
|
+
|
|
74
|
+
Pruned caches have no persistent storage. The engine retains uncached rendering
|
|
75
|
+
paths for native or dynamically supplied instructions, preserving pixels and hit
|
|
76
|
+
testing even when such instructions are absent from the source analysis.
|
|
77
|
+
`packages/core/test/run-renderer-features.sh` compares enabled/pruned rendering
|
|
78
|
+
and verifies that pruned cache storage symbols are absent from the binary.
|
|
79
|
+
|
|
80
|
+
## Native JPEG decoding
|
|
81
|
+
|
|
82
|
+
ESP targets that link Espressif's `esp_new_jpeg` component automatically use it
|
|
83
|
+
when its `esp_jpeg_dec.h` header is visible and the target stores RGB565 pixels.
|
|
84
|
+
The decoder writes directly to the aligned image buffer in the target's byte
|
|
85
|
+
order, preserving source dimensions. It does not allocate an intermediate RGBA
|
|
86
|
+
frame. Unsupported images fall back to the ESP32-S3 ROM decoder, then stb.
|
|
87
|
+
Targets without the component retain their existing decoder fallback.
|
|
88
|
+
|
|
89
|
+
The S3 ROM path also preserves full colour and source dimensions, converting
|
|
90
|
+
individual RGB888 MCU blocks into the final native image with an 8 KiB workspace.
|
|
91
|
+
`packages/core/test/run-native-jpeg.sh` checks the backend API contracts, native
|
|
92
|
+
pixels, byte order, cleanup and fallback using host mocks. Actual codec speed
|
|
93
|
+
and output must be checked on hardware. With `GEA_EMBEDDED_PERF=1`, the optional
|
|
94
|
+
Espressif backend reports its result and duration on the first and every tenth
|
|
95
|
+
decode.
|
|
96
|
+
|
|
27
97
|
## License
|
|
28
98
|
|
|
29
99
|
Apache-2.0. See `LICENSE`.
|
package/canvas.cpp
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#include "ui/renderer_features.h"
|
|
2
3
|
#include "canvas.h"
|
|
3
4
|
#include "display.h"
|
|
4
5
|
#include "graphics/font.h"
|
|
5
6
|
#include "pixel.h"
|
|
6
7
|
|
|
7
8
|
#include <algorithm>
|
|
9
|
+
#include <atomic>
|
|
8
10
|
#include <cmath>
|
|
9
11
|
#include <cstdio>
|
|
10
12
|
#include <cstdlib>
|
|
11
13
|
#include <cstring>
|
|
14
|
+
#include <type_traits>
|
|
12
15
|
#include <vector>
|
|
13
16
|
|
|
14
17
|
// For the compile-gated GEA_EMBEDDED_TEXT_SPRITE_DIAG counters (see the diag
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
namespace gea::framework::graphics {
|
|
49
52
|
|
|
50
53
|
namespace {
|
|
54
|
+
#if GEA_EMBEDDED_RENDERER_TRIANGLE_OCCLUSION
|
|
51
55
|
// Per-scanline coverage bitmask for fillTrianglesOpaqueOccluded. Bit x set = a
|
|
52
56
|
// nearer triangle already owns pixel x on that chunk-local row. Two banks so two
|
|
53
57
|
// Canvases on different cores can occlude concurrently (cross-core band raster).
|
|
@@ -68,6 +72,7 @@ inline int occlCoreBank()
|
|
|
68
72
|
return 0;
|
|
69
73
|
#endif
|
|
70
74
|
}
|
|
75
|
+
#endif
|
|
71
76
|
} // namespace
|
|
72
77
|
|
|
73
78
|
constexpr int kBitmapFontWidth = BitmapFont8x16::kWidth;
|
|
@@ -239,14 +244,18 @@ void adoptHotTextSprite(const TextSprite &s)
|
|
|
239
244
|
}
|
|
240
245
|
#endif // GEA_EMBEDDED_TEXT_SPRITE_HOT_STAGE_BYTES > 0
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
TextSprite &textSpriteFor(const char *text, const RasterizedFont &font)
|
|
243
248
|
{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
// Search all four slots: a direct-mapped hash makes alternating labels
|
|
250
|
+
// such as "FPS: 59" and "FPS: 60" evict each other. Hits stay read-only;
|
|
251
|
+
// a four-byte replacement cursor advances only for a new cache key.
|
|
252
|
+
for (TextSprite &candidate : gTextSprites) {
|
|
253
|
+
if (candidate.fontData == font.data() && candidate.sizePx == font.sizePx() &&
|
|
254
|
+
std::strcmp(candidate.text, text) == 0)
|
|
255
|
+
return candidate;
|
|
248
256
|
}
|
|
249
|
-
|
|
257
|
+
static std::atomic<unsigned> nextSlot{0};
|
|
258
|
+
return gTextSprites[nextSlot.fetch_add(1, std::memory_order_relaxed) % kTextSpriteSlots];
|
|
250
259
|
}
|
|
251
260
|
|
|
252
261
|
// Rasterize `text` into `sprite`'s coverage buffer in text-relative coordinates
|
|
@@ -833,6 +842,7 @@ SolidGlyphCacheEntry *solidGlyphCacheEntry(const RasterizedFont &font,
|
|
|
833
842
|
|
|
834
843
|
class CanvasMath {
|
|
835
844
|
public:
|
|
845
|
+
#if GEA_EMBEDDED_RENDERER_CIRCLES
|
|
836
846
|
#ifndef GEA_EMBEDDED_CANVAS_CIRCLE_RADIUS_MAX
|
|
837
847
|
#define GEA_EMBEDDED_CANVAS_CIRCLE_RADIUS_MAX 63
|
|
838
848
|
#endif
|
|
@@ -843,16 +853,32 @@ public:
|
|
|
843
853
|
#define GEA_EMBEDDED_CANVAS_CIRCLE_BOX_SPAN_SLOTS 16
|
|
844
854
|
#endif
|
|
845
855
|
|
|
846
|
-
|
|
856
|
+
#ifndef GEA_EMBEDDED_CANVAS_CIRCLE_SPAN_MAX
|
|
857
|
+
#define GEA_EMBEDDED_CANVAS_CIRCLE_SPAN_MAX 32
|
|
858
|
+
#endif
|
|
859
|
+
static constexpr int kCircleSpanMax = GEA_EMBEDDED_CANVAS_CIRCLE_SPAN_MAX;
|
|
847
860
|
static constexpr int kCircleSpanSlotCount = (kCircleSpanMax / 2) + 1;
|
|
848
861
|
static constexpr int kCircleRadiusMax = GEA_EMBEDDED_CANVAS_CIRCLE_RADIUS_MAX;
|
|
849
|
-
|
|
862
|
+
// Tables are concatenated at their actual heights, not at the maximum
|
|
863
|
+
// height for every radius. Even-size slot s uses 2*s rows; radius r uses
|
|
864
|
+
// 2*r+1 rows. Their starts are s*(s-1) and r*r respectively.
|
|
865
|
+
static constexpr int kCircleSpanRows = kCircleSpanSlotCount * (kCircleSpanSlotCount - 1);
|
|
866
|
+
static constexpr int kCircleRadiusRows = (kCircleRadiusMax + 1) * (kCircleRadiusMax + 1);
|
|
850
867
|
static constexpr int kCircleBoxSpanMax = GEA_EMBEDDED_CANVAS_CIRCLE_BOX_SPAN_MAX;
|
|
851
868
|
static constexpr int kCircleBoxSpanSlots = GEA_EMBEDDED_CANVAS_CIRCLE_BOX_SPAN_SLOTS;
|
|
869
|
+
static_assert(kCircleSpanMax > 0 && kCircleSpanMax <= 32 && (kCircleSpanMax % 2) == 0);
|
|
852
870
|
static_assert(kCircleRadiusMax > 0 && kCircleRadiusMax < 64);
|
|
853
871
|
static_assert(kCircleBoxSpanMax > 0 && kCircleBoxSpanMax <= 255);
|
|
854
872
|
static_assert(kCircleBoxSpanSlots > 0);
|
|
855
873
|
|
|
874
|
+
using CircleSpanReady = std::conditional_t<(kCircleSpanSlotCount <= 8), std::uint8_t,
|
|
875
|
+
std::conditional_t<(kCircleSpanSlotCount <= 16), std::uint16_t, std::uint32_t>>;
|
|
876
|
+
using CircleRadiusReady = std::conditional_t<(kCircleRadiusMax < 8), std::uint8_t,
|
|
877
|
+
std::conditional_t<(kCircleRadiusMax < 16), std::uint16_t,
|
|
878
|
+
std::conditional_t<(kCircleRadiusMax < 32), std::uint32_t, std::uint64_t>>>;
|
|
879
|
+
using CircleBoxSlot = std::conditional_t<(kCircleBoxSpanSlots <= 256), std::uint8_t, std::uint32_t>;
|
|
880
|
+
|
|
881
|
+
#endif
|
|
856
882
|
static int min(int a, int b) { return a < b ? a : b; }
|
|
857
883
|
|
|
858
884
|
static int integerSqrt(int n)
|
|
@@ -867,33 +893,40 @@ public:
|
|
|
867
893
|
return x;
|
|
868
894
|
}
|
|
869
895
|
|
|
870
|
-
const std::uint8_t (*circleSpans(int size))[2]
|
|
896
|
+
static const std::uint8_t (*circleSpans(int size))[2]
|
|
871
897
|
{
|
|
898
|
+
#if GEA_EMBEDDED_RENDERER_CIRCLES
|
|
872
899
|
if (size <= 0 || size > kCircleSpanMax || (size & 1)) return nullptr;
|
|
873
|
-
int slot = size / 2;
|
|
874
|
-
|
|
875
|
-
|
|
900
|
+
const int slot = size / 2;
|
|
901
|
+
auto *spans = instance().circleSpanCache_ + slot * (slot - 1);
|
|
902
|
+
const CircleSpanReady bit = static_cast<CircleSpanReady>(CircleSpanReady{1} << slot);
|
|
903
|
+
if (!(instance().circleSpanCacheReady_ & bit)) {
|
|
876
904
|
int radius2 = size * size;
|
|
877
905
|
for (int row = 0; row < size; row++) {
|
|
878
906
|
int dy2 = row * 2 + 1 - size;
|
|
879
907
|
int dx2 = integerSqrt(radius2 - dy2 * dy2);
|
|
880
|
-
|
|
881
|
-
|
|
908
|
+
spans[row][0] = (std::uint8_t)((size - dx2) / 2);
|
|
909
|
+
spans[row][1] = (std::uint8_t)((size + dx2 - 1) / 2);
|
|
882
910
|
}
|
|
883
|
-
circleSpanCacheReady_ |= bit;
|
|
911
|
+
instance().circleSpanCacheReady_ |= bit;
|
|
884
912
|
}
|
|
885
|
-
return
|
|
913
|
+
return spans;
|
|
914
|
+
#else
|
|
915
|
+
(void)size;
|
|
916
|
+
return nullptr;
|
|
917
|
+
#endif
|
|
886
918
|
}
|
|
887
919
|
|
|
888
|
-
const std::uint8_t (*circleBoxSpans(int size))[2]
|
|
920
|
+
static const std::uint8_t (*circleBoxSpans(int size))[2]
|
|
889
921
|
{
|
|
922
|
+
#if GEA_EMBEDDED_RENDERER_CIRCLES
|
|
890
923
|
if (size <= 0 || size > kCircleBoxSpanMax) return nullptr;
|
|
891
924
|
for (int slot = 0; slot < kCircleBoxSpanSlots; ++slot) {
|
|
892
|
-
if (circleBoxSpanSize_[slot] == size)
|
|
893
|
-
return circleBoxSpanCache_[slot];
|
|
925
|
+
if (instance().circleBoxSpanSize_[slot] == size)
|
|
926
|
+
return instance().circleBoxSpanCache_[slot];
|
|
894
927
|
}
|
|
895
|
-
const int slot = circleBoxSpanNext_;
|
|
896
|
-
circleBoxSpanNext_ = (circleBoxSpanNext_ + 1) % kCircleBoxSpanSlots;
|
|
928
|
+
const int slot = instance().circleBoxSpanNext_;
|
|
929
|
+
instance().circleBoxSpanNext_ = (instance().circleBoxSpanNext_ + 1) % kCircleBoxSpanSlots;
|
|
897
930
|
const long long ss = static_cast<long long>(size) * static_cast<long long>(size);
|
|
898
931
|
for (int row = 0; row < size; row++) {
|
|
899
932
|
const long long dy2 = static_cast<long long>(row * 2 + 1 - size);
|
|
@@ -904,31 +937,42 @@ public:
|
|
|
904
937
|
int sx1 = (size + dx2 - 1) / 2;
|
|
905
938
|
if (sx0 < 0) sx0 = 0;
|
|
906
939
|
if (sx1 >= size) sx1 = size - 1;
|
|
907
|
-
circleBoxSpanCache_[slot][row][0] = static_cast<std::uint8_t>(sx0);
|
|
908
|
-
circleBoxSpanCache_[slot][row][1] = static_cast<std::uint8_t>(sx1);
|
|
940
|
+
instance().circleBoxSpanCache_[slot][row][0] = static_cast<std::uint8_t>(sx0);
|
|
941
|
+
instance().circleBoxSpanCache_[slot][row][1] = static_cast<std::uint8_t>(sx1);
|
|
909
942
|
}
|
|
910
|
-
circleBoxSpanSize_[slot] = size;
|
|
911
|
-
return circleBoxSpanCache_[slot];
|
|
943
|
+
instance().circleBoxSpanSize_[slot] = size;
|
|
944
|
+
return instance().circleBoxSpanCache_[slot];
|
|
945
|
+
#else
|
|
946
|
+
(void)size;
|
|
947
|
+
return nullptr;
|
|
948
|
+
#endif
|
|
912
949
|
}
|
|
913
950
|
|
|
914
|
-
const std::uint8_t (*circleRadiusSpans(int radius))[2]
|
|
951
|
+
static const std::uint8_t (*circleRadiusSpans(int radius))[2]
|
|
915
952
|
{
|
|
953
|
+
#if GEA_EMBEDDED_RENDERER_CIRCLES
|
|
916
954
|
if (radius <= 0 || radius > kCircleRadiusMax) return nullptr;
|
|
917
|
-
|
|
918
|
-
|
|
955
|
+
const int rr = radius * radius;
|
|
956
|
+
auto *spans = instance().circleRadiusSpanCache_ + rr;
|
|
957
|
+
const CircleRadiusReady bit = static_cast<CircleRadiusReady>(CircleRadiusReady{1} << radius);
|
|
958
|
+
if (!(instance().circleRadiusSpanCacheReady_ & bit)) {
|
|
919
959
|
const int diameter = radius * 2 + 1;
|
|
920
|
-
const int rr = radius * radius;
|
|
921
960
|
for (int row = 0; row < diameter; row++) {
|
|
922
961
|
const int dy = row - radius;
|
|
923
962
|
const int dx = integerSqrt(rr - dy * dy);
|
|
924
|
-
|
|
925
|
-
|
|
963
|
+
spans[row][0] = (std::uint8_t)(radius - dx);
|
|
964
|
+
spans[row][1] = (std::uint8_t)(radius + dx);
|
|
926
965
|
}
|
|
927
|
-
circleRadiusSpanCacheReady_ |= bit;
|
|
966
|
+
instance().circleRadiusSpanCacheReady_ |= bit;
|
|
928
967
|
}
|
|
929
|
-
return
|
|
968
|
+
return spans;
|
|
969
|
+
#else
|
|
970
|
+
(void)radius;
|
|
971
|
+
return nullptr;
|
|
972
|
+
#endif
|
|
930
973
|
}
|
|
931
974
|
|
|
975
|
+
#if GEA_EMBEDDED_RENDERER_CIRCLES
|
|
932
976
|
static CanvasMath &instance()
|
|
933
977
|
{
|
|
934
978
|
static CanvasMath math;
|
|
@@ -936,13 +980,14 @@ public:
|
|
|
936
980
|
}
|
|
937
981
|
|
|
938
982
|
private:
|
|
939
|
-
std::uint8_t circleSpanCache_[
|
|
940
|
-
|
|
941
|
-
std::uint8_t circleRadiusSpanCache_[
|
|
942
|
-
|
|
983
|
+
std::uint8_t circleSpanCache_[kCircleSpanRows][2]{};
|
|
984
|
+
CircleSpanReady circleSpanCacheReady_ = 0;
|
|
985
|
+
std::uint8_t circleRadiusSpanCache_[kCircleRadiusRows][2]{};
|
|
986
|
+
CircleRadiusReady circleRadiusSpanCacheReady_ = 0;
|
|
943
987
|
std::uint8_t circleBoxSpanCache_[kCircleBoxSpanSlots][kCircleBoxSpanMax][2]{};
|
|
944
988
|
std::uint8_t circleBoxSpanSize_[kCircleBoxSpanSlots]{};
|
|
945
|
-
|
|
989
|
+
CircleBoxSlot circleBoxSpanNext_ = 0;
|
|
990
|
+
#endif
|
|
946
991
|
};
|
|
947
992
|
|
|
948
993
|
pixel::native_t Canvas::readPixelNative(int x, int y) const
|
|
@@ -1658,7 +1703,7 @@ bool Canvas::fillCircleNoDirty(int cx, int cy, int r, pixel::native_t color)
|
|
|
1658
1703
|
const ClipRect *clip = &clipStack_[clipDepth_];
|
|
1659
1704
|
if (cx + r < clip->x0 || cx - r > clip->x1 || cy + r < clip->y0 || cy - r > clip->y1) return false;
|
|
1660
1705
|
|
|
1661
|
-
const std::uint8_t (*spans)[2] = CanvasMath::
|
|
1706
|
+
const std::uint8_t (*spans)[2] = CanvasMath::circleRadiusSpans(r);
|
|
1662
1707
|
if (!spans) {
|
|
1663
1708
|
const int rr = r * r;
|
|
1664
1709
|
int dy0 = -r;
|
|
@@ -1807,7 +1852,7 @@ void Canvas::fillCirclesRgb565WorldYSorted(const CircleEntry *circles,
|
|
|
1807
1852
|
int yOffset)
|
|
1808
1853
|
{
|
|
1809
1854
|
if (!pixels_ || !circles || count <= 0 || r <= 0) return;
|
|
1810
|
-
const std::uint8_t (*spans)[2] = CanvasMath::
|
|
1855
|
+
const std::uint8_t (*spans)[2] = CanvasMath::circleRadiusSpans(r);
|
|
1811
1856
|
const int diameter = r * 2 + 1;
|
|
1812
1857
|
const int w = width_;
|
|
1813
1858
|
const int h = height_;
|
|
@@ -2100,6 +2145,15 @@ void Canvas::fillTriangleOpaque(int x0, int y0, int x1, int y1, int x2, int y2,
|
|
|
2100
2145
|
void Canvas::fillTrianglesOpaqueOccluded(const TriangleEntry *tris, int count, int ox, int oy)
|
|
2101
2146
|
{
|
|
2102
2147
|
if (!pixels_ || count <= 0) return;
|
|
2148
|
+
#if !GEA_EMBEDDED_RENDERER_TRIANGLE_OCCLUSION
|
|
2149
|
+
// Same painter's-order fallback used for chunks larger than the scratch.
|
|
2150
|
+
// Unused optimizations reserve no storage, but native commands still draw.
|
|
2151
|
+
for (int i = 0; i < count; ++i) {
|
|
2152
|
+
const TriangleEntry &t = tris[i];
|
|
2153
|
+
fillTriangleOpaque(t.x0 - ox, t.y0 - oy, t.x1 - ox, t.y1 - oy,
|
|
2154
|
+
t.x2 - ox, t.y2 - oy, t.color);
|
|
2155
|
+
}
|
|
2156
|
+
#else
|
|
2103
2157
|
const int rows = height_;
|
|
2104
2158
|
// Fall back to painter's back-to-front when the chunk exceeds the coverage
|
|
2105
2159
|
// scratch (only gea3d's small half-res chunks take the occluded path).
|
|
@@ -2212,6 +2266,7 @@ void Canvas::fillTrianglesOpaqueOccluded(const TriangleEntry *tris, int count, i
|
|
|
2212
2266
|
}
|
|
2213
2267
|
}
|
|
2214
2268
|
if (dirty_x1 >= dirty_x0 && dirty_y1 >= dirty_y0) markDirty(dirty_x0, dirty_y0, dirty_x1, dirty_y1);
|
|
2269
|
+
#endif
|
|
2215
2270
|
}
|
|
2216
2271
|
|
|
2217
2272
|
void Canvas::drawText(const char *text, int x, int y, pixel::native_t color, float scale)
|
|
@@ -2616,7 +2671,7 @@ void Canvas::drawRasterizedText(const char *text, int x, int y, pixel::native_t
|
|
|
2616
2671
|
if (len == 0 || len > static_cast<std::size_t>(kTextSpriteMaxLen)) gTsDiag.tooLong++;
|
|
2617
2672
|
#endif
|
|
2618
2673
|
if (len > 0 && len <= static_cast<std::size_t>(kTextSpriteMaxLen)) {
|
|
2619
|
-
TextSprite &slot =
|
|
2674
|
+
TextSprite &slot = textSpriteFor(text, font);
|
|
2620
2675
|
const bool idMatch = slot.fontData == font.data() &&
|
|
2621
2676
|
slot.sizePx == font.sizePx() &&
|
|
2622
2677
|
std::strcmp(slot.text, text) == 0;
|
|
@@ -3226,8 +3281,8 @@ void Canvas::fillQuarterCircle(int cx, int cy, int r, int quadrant, pixel::nativ
|
|
|
3226
3281
|
void Canvas::fillCircleBox(int x, int y, int size, pixel::native_t color)
|
|
3227
3282
|
{
|
|
3228
3283
|
if (!pixels_) return;
|
|
3229
|
-
const std::uint8_t (*spans)[2] = CanvasMath::
|
|
3230
|
-
if (
|
|
3284
|
+
const std::uint8_t (*spans)[2] = CanvasMath::circleSpans(size);
|
|
3285
|
+
if (size <= 0 || size > 32 || (size & 1)) return;
|
|
3231
3286
|
const ClipRect *clip = &clipStack_[clipDepth_];
|
|
3232
3287
|
|
|
3233
3288
|
if (x > clip->x1 || y > clip->y1 || x + size - 1 < clip->x0 || y + size - 1 < clip->y0) return;
|
|
@@ -3242,8 +3297,10 @@ void Canvas::fillCircleBox(int x, int y, int size, pixel::native_t color)
|
|
|
3242
3297
|
for (int row = row0; row <= row1; row++) {
|
|
3243
3298
|
int sy = y + row;
|
|
3244
3299
|
|
|
3245
|
-
int
|
|
3246
|
-
int
|
|
3300
|
+
const int dy2 = row * 2 + 1 - size;
|
|
3301
|
+
const int dx2 = spans ? 0 : CanvasMath::integerSqrt(size * size - dy2 * dy2);
|
|
3302
|
+
int sx0 = x + (spans ? spans[row][0] : (size - dx2) / 2);
|
|
3303
|
+
int sx1 = x + (spans ? spans[row][1] : (size + dx2 - 1) / 2);
|
|
3247
3304
|
if (sx0 < clip->x0) sx0 = clip->x0;
|
|
3248
3305
|
if (sx1 > clip->x1) sx1 = clip->x1;
|
|
3249
3306
|
if (sx0 < 0) sx0 = 0;
|
|
@@ -3275,7 +3332,7 @@ void Canvas::fillRoundedRectBoxesRgb565(const std::int16_t *xs,
|
|
|
3275
3332
|
// four-corner rounded-rect raster.
|
|
3276
3333
|
if (Canvas::antialiasSamples() < 2 && roundedRectIsCircleLike(w, h, tl, tr, br, bl) && h <= 256) {
|
|
3277
3334
|
const std::uint8_t (*cachedSpans)[2] =
|
|
3278
|
-
(w == h) ? CanvasMath::
|
|
3335
|
+
(w == h) ? CanvasMath::circleBoxSpans(w) : nullptr;
|
|
3279
3336
|
std::uint16_t spanX0[256];
|
|
3280
3337
|
std::uint16_t spanX1[256];
|
|
3281
3338
|
if (!cachedSpans) {
|
|
@@ -3368,7 +3425,7 @@ void Canvas::fillRoundedRect(int x, int y, int w, int h, int tl, int tr, int br,
|
|
|
3368
3425
|
// 62fps circle path (its poles are marginally rounder than the integer scanline).
|
|
3369
3426
|
if (Canvas::antialiasSamples() < 2 && w == h &&
|
|
3370
3427
|
tl == w / 2 && tr == w / 2 && br == w / 2 && bl == w / 2 &&
|
|
3371
|
-
|
|
3428
|
+
w > 0 && w <= 32 && !(w & 1)) {
|
|
3372
3429
|
fillCircleBox(x, y, w, color);
|
|
3373
3430
|
return;
|
|
3374
3431
|
}
|
|
@@ -4378,7 +4435,7 @@ void Canvas::drawImageRounded(
|
|
|
4378
4435
|
// lookup per row instead of an integer sqrt, and repeat draws of the
|
|
4379
4436
|
// same radius (every full-size icon, every chunk that touches it) pay
|
|
4380
4437
|
// nothing at all.
|
|
4381
|
-
const std::uint8_t (*spans)[2] = CanvasMath::
|
|
4438
|
+
const std::uint8_t (*spans)[2] = CanvasMath::circleRadiusSpans(rr);
|
|
4382
4439
|
for (int py = y0; py <= y1; py++) {
|
|
4383
4440
|
const int ly = py - dy;
|
|
4384
4441
|
int lo, hi;
|
package/css/declarative.h
CHANGED
|
@@ -34,6 +34,7 @@ public:
|
|
|
34
34
|
// Call once after an app mounts; nowMs is the current frame clock.
|
|
35
35
|
static void scanAndStart(uint32_t nowMs)
|
|
36
36
|
{
|
|
37
|
+
#if GEA_CSS_ANIMATIONS
|
|
37
38
|
gea::embedded::ui::Tree &tree = gea::embedded::ui::Tree::instance();
|
|
38
39
|
const int count = tree.nodeCount();
|
|
39
40
|
for (int id = 0; id < count; ++id) {
|
|
@@ -41,9 +42,13 @@ public:
|
|
|
41
42
|
if (!kind || kind[0] == '\0') continue;
|
|
42
43
|
startForNode(tree, id, kind, nowMs);
|
|
43
44
|
}
|
|
45
|
+
#else
|
|
46
|
+
(void)nowMs;
|
|
47
|
+
#endif
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
private:
|
|
51
|
+
#if GEA_CSS_ANIMATIONS
|
|
47
52
|
static int attrInt(gea::embedded::ui::Tree &tree, int id, const char *name, int def)
|
|
48
53
|
{
|
|
49
54
|
const char *v = tree.getAttribute(id, name);
|
|
@@ -126,6 +131,7 @@ private:
|
|
|
126
131
|
startOne(Property::Height, from, to);
|
|
127
132
|
}
|
|
128
133
|
}
|
|
134
|
+
#endif
|
|
129
135
|
};
|
|
130
136
|
|
|
131
137
|
} // namespace gea::css
|
package/css/engine.h
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#include <utility>
|
|
17
17
|
#include <vector>
|
|
18
18
|
|
|
19
|
+
#include "../ui/css_features.h"
|
|
19
20
|
#include "../ui/style.h"
|
|
20
21
|
#include "animation.h"
|
|
21
22
|
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
|
|
26
27
|
namespace gea::css {
|
|
27
28
|
|
|
29
|
+
#if GEA_CSS_ANIMATIONS
|
|
28
30
|
class AnimationEngine {
|
|
29
31
|
public:
|
|
30
32
|
static AnimationEngine &instance()
|
|
@@ -225,4 +227,22 @@ private:
|
|
|
225
227
|
int nextHandle_ = 1;
|
|
226
228
|
};
|
|
227
229
|
|
|
230
|
+
#else
|
|
231
|
+
// The shared runtime still calls tick/clear in an animation-free app. These
|
|
232
|
+
// compile away without allocating an active-list singleton. A native producer
|
|
233
|
+
// must retain support; accidental use fails at compile time rather than dropping
|
|
234
|
+
// an animation silently.
|
|
235
|
+
class AnimationEngine {
|
|
236
|
+
public:
|
|
237
|
+
static AnimationEngine &instance() { static AnimationEngine engine; return engine; }
|
|
238
|
+
int start(Animation, uint32_t) = delete;
|
|
239
|
+
void cancel(int) {}
|
|
240
|
+
void cancelNode(int) {}
|
|
241
|
+
void clear() {}
|
|
242
|
+
bool active() const { return false; }
|
|
243
|
+
std::size_t count() const { return 0; }
|
|
244
|
+
void tick(uint32_t) {}
|
|
245
|
+
};
|
|
246
|
+
#endif
|
|
247
|
+
|
|
228
248
|
} // namespace gea::css
|