@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/ui/node_text.h
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
#include "storage_usage.h"
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
namespace gea::embedded::ui
|
|
8
|
+
{
|
|
9
|
+
// Empty nodes own no string storage. Nonempty text lives in stable pooled
|
|
10
|
+
// records, preserving c_str() addresses while other nodes are created/removed.
|
|
11
|
+
// Copies own independent records: retained display commands can scrub one
|
|
12
|
+
// node's old buffer without invalidating a clone's unchanged text.
|
|
13
|
+
class NodeText
|
|
14
|
+
{
|
|
15
|
+
public:
|
|
16
|
+
NodeText() = default;
|
|
17
|
+
NodeText(const NodeText &other);
|
|
18
|
+
NodeText(NodeText &&other) noexcept;
|
|
19
|
+
~NodeText();
|
|
20
|
+
NodeText &operator=(const NodeText &other);
|
|
21
|
+
NodeText &operator=(NodeText &&other) noexcept;
|
|
22
|
+
NodeText &operator=(const std::string &text)
|
|
23
|
+
{
|
|
24
|
+
assign(text.c_str());
|
|
25
|
+
return *this;
|
|
26
|
+
}
|
|
27
|
+
NodeText &operator=(const char *text)
|
|
28
|
+
{
|
|
29
|
+
assign(text);
|
|
30
|
+
return *this;
|
|
31
|
+
}
|
|
32
|
+
// Pool allocation payload (including spare slots/map), excluding string
|
|
33
|
+
// character buffers and allocator metadata. Useful alongside heap census.
|
|
34
|
+
static std::size_t storageBytes();
|
|
35
|
+
static StorageUsage storageUsage();
|
|
36
|
+
void clear();
|
|
37
|
+
void assign(const char *text);
|
|
38
|
+
bool empty() const { return handle_ == kEmpty; }
|
|
39
|
+
const std::string &str() const;
|
|
40
|
+
operator const std::string &() const { return str(); }
|
|
41
|
+
const char *c_str() const { return str().c_str(); }
|
|
42
|
+
const char *data() const { return c_str(); }
|
|
43
|
+
std::size_t size() const { return str().size(); }
|
|
44
|
+
char operator[](std::size_t i) const { return str()[i]; }
|
|
45
|
+
std::size_t find(char c) const { return str().find(c); }
|
|
46
|
+
std::size_t find_first_not_of(const char *chars) const
|
|
47
|
+
{
|
|
48
|
+
return str().find_first_not_of(chars);
|
|
49
|
+
}
|
|
50
|
+
std::string substr(std::size_t pos,
|
|
51
|
+
std::size_t count = std::string::npos) const
|
|
52
|
+
{
|
|
53
|
+
return str().substr(pos, count);
|
|
54
|
+
}
|
|
55
|
+
friend bool operator==(const NodeText &a, const NodeText &b)
|
|
56
|
+
{
|
|
57
|
+
return a.str() == b.str();
|
|
58
|
+
}
|
|
59
|
+
friend bool operator==(const NodeText &a, const std::string &b)
|
|
60
|
+
{
|
|
61
|
+
return a.str() == b;
|
|
62
|
+
}
|
|
63
|
+
friend bool operator==(const NodeText &a, const char *b)
|
|
64
|
+
{
|
|
65
|
+
return a.str() == b;
|
|
66
|
+
}
|
|
67
|
+
friend bool operator!=(const NodeText &a, const NodeText &b)
|
|
68
|
+
{
|
|
69
|
+
return !(a == b);
|
|
70
|
+
}
|
|
71
|
+
friend bool operator!=(const NodeText &a, const std::string &b)
|
|
72
|
+
{
|
|
73
|
+
return !(a == b);
|
|
74
|
+
}
|
|
75
|
+
friend bool operator!=(const NodeText &a, const char *b)
|
|
76
|
+
{
|
|
77
|
+
return !(a == b);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
static constexpr std::uint32_t kEmpty = UINT32_MAX;
|
|
82
|
+
std::uint32_t handle_ = kEmpty;
|
|
83
|
+
};
|
|
84
|
+
} // namespace gea::embedded::ui
|
package/ui/refresh_perf.h
CHANGED
|
@@ -112,6 +112,11 @@ struct RefreshPerfStats {
|
|
|
112
112
|
int treeScopedRejectNode = -1;
|
|
113
113
|
int treeLayoutRepositionCalls = 0;
|
|
114
114
|
std::int64_t treeLayoutTextUs = 0;
|
|
115
|
+
#if GEA_EMBEDDED_UI_REFRESH_PERF
|
|
116
|
+
// Deterministic work budgets for animation regressions; absent with perf off.
|
|
117
|
+
int treeIntegerPositionFastCalls = 0;
|
|
118
|
+
int treeTranslateClipChecks = 0;
|
|
119
|
+
#endif
|
|
115
120
|
int treeSetStyleCalls = 0;
|
|
116
121
|
int treeSetStyleChanged = 0;
|
|
117
122
|
int treeSetStyleNoop = 0;
|
|
@@ -125,6 +130,8 @@ struct RefreshPerfStats {
|
|
|
125
130
|
int treeMarkDisplayListDirtyCalls = 0;
|
|
126
131
|
int treeMarkDisplayListContentDirtyCalls = 0;
|
|
127
132
|
int treeMarkNodeCommandDirtyCalls = 0;
|
|
133
|
+
int treeAbsContainingAreaCalls = 0;
|
|
134
|
+
int treeAbsContainingAreaHits = 0;
|
|
128
135
|
int treeAbsModeCalls = 0;
|
|
129
136
|
int treeAbsModeFast = 0;
|
|
130
137
|
int treeAbsModeFull = 0;
|
|
@@ -201,35 +208,30 @@ inline std::int64_t refreshPerfNowUs()
|
|
|
201
208
|
#endif
|
|
202
209
|
}
|
|
203
210
|
|
|
211
|
+
// Diagnostic writes must be compiled out, not redirected to a throwaway object:
|
|
212
|
+
// the latter still performs loads/stores in every style update and replay scan.
|
|
213
|
+
// A statement macro preserves surrounding if/else binding and does not evaluate
|
|
214
|
+
// its arguments when profiling is off.
|
|
215
|
+
#define GEA_REFRESH_PERF(...) \
|
|
216
|
+
do { if constexpr (GEA_EMBEDDED_UI_REFRESH_PERF) { __VA_ARGS__; } } while (false)
|
|
217
|
+
|
|
204
218
|
inline RefreshPerfStats &refreshPerfStatsMutable()
|
|
205
219
|
{
|
|
206
|
-
#if GEA_EMBEDDED_UI_REFRESH_PERF
|
|
207
220
|
return gRefreshPerfStats;
|
|
208
|
-
#else
|
|
209
|
-
// Perf off: the timer-derived `… += refreshPerfNowUs() - start` writes already
|
|
210
|
-
// fold to `+= 0` (refreshPerfNowUs() returns 0), and the ScopedRefreshStat
|
|
211
|
-
// guards optimize away. The few remaining bare counters in tree_render/render
|
|
212
|
-
// (`treePanReplayCalls++`, `treePanRepaintArea += …`) are routed to a throwaway
|
|
213
|
-
// that nothing reads, so they never touch live state.
|
|
214
|
-
#if GEA_EMBEDDED_UI_STATE_DYNAMIC_INIT
|
|
215
|
-
// On the heap, not static: the -1 sentinels make the throwaway a .data
|
|
216
|
-
// object (see state_init.h).
|
|
217
|
-
static RefreshPerfStats &discard = *new RefreshPerfStats();
|
|
218
|
-
#else
|
|
219
|
-
static RefreshPerfStats discard;
|
|
220
|
-
#endif
|
|
221
|
-
return discard;
|
|
222
|
-
#endif
|
|
223
221
|
}
|
|
224
222
|
|
|
225
223
|
inline void refreshPerfStatsReset()
|
|
226
224
|
{
|
|
227
|
-
gRefreshPerfStats = {};
|
|
225
|
+
GEA_REFRESH_PERF(gRefreshPerfStats = {});
|
|
228
226
|
}
|
|
229
227
|
|
|
230
228
|
inline RefreshPerfStats refreshPerfStatsRead()
|
|
231
229
|
{
|
|
230
|
+
#if GEA_EMBEDDED_UI_REFRESH_PERF
|
|
232
231
|
return gRefreshPerfStats;
|
|
232
|
+
#else
|
|
233
|
+
return {};
|
|
234
|
+
#endif
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
} // namespace gea::embedded::ui
|