@geastack/geatsc-plugin-gea 0.1.27 → 0.1.28
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/dist/cpp-ir.js +65 -0
- package/dist/host-declarations.js +4 -0
- package/dist/host-shims.js +21 -0
- package/package.json +1 -1
package/dist/cpp-ir.js
CHANGED
|
@@ -1280,9 +1280,16 @@ const imageData565InteropSource = [
|
|
|
1280
1280
|
"#include <memory>",
|
|
1281
1281
|
"namespace gea {",
|
|
1282
1282
|
"template <typename T> class TypedArray;",
|
|
1283
|
+
"class ArrayBuffer;",
|
|
1283
1284
|
"template <typename T> struct Ref;",
|
|
1284
1285
|
"template <typename T, typename... Arguments> inline Ref<T> makeRef(Arguments&&... arguments);",
|
|
1285
1286
|
"} // namespace gea",
|
|
1287
|
+
"// A display whose swap buffers an app may render into in place defines these",
|
|
1288
|
+
"// (see rgb_panel.cpp); elsewhere they are absent and the panel helpers below",
|
|
1289
|
+
"// report no buffers.",
|
|
1290
|
+
'extern "C" int gea_display_panel_buffer_count(int *width, int *height) __attribute__((weak));',
|
|
1291
|
+
'extern "C" std::uint16_t *gea_display_panel_buffer(int index) __attribute__((weak));',
|
|
1292
|
+
'extern "C" int gea_display_acquire_panel_buffer() __attribute__((weak));',
|
|
1286
1293
|
"namespace gea_ir {",
|
|
1287
1294
|
"",
|
|
1288
1295
|
"template <typename D = void>",
|
|
@@ -1329,6 +1336,64 @@ const imageData565InteropSource = [
|
|
|
1329
1336
|
" return out;",
|
|
1330
1337
|
"}",
|
|
1331
1338
|
"",
|
|
1339
|
+
"// `ctx.panelBufferCount()`: how many display buffers an app can render a whole",
|
|
1340
|
+
"// frame into in place (0 where it cannot -- no swap buffers, a byte-swapped or",
|
|
1341
|
+
"// non-RGB565 panel, a scroll region laid out as a ring).",
|
|
1342
|
+
"inline double canvasPanelBufferCount(gea::embedded::ui::CanvasRenderingContext2D &) {",
|
|
1343
|
+
" if constexpr (!imageData565ZeroCopy) {",
|
|
1344
|
+
" return 0;",
|
|
1345
|
+
" } else {",
|
|
1346
|
+
" if (!gea_display_panel_buffer_count) return 0;",
|
|
1347
|
+
" int width = 0;",
|
|
1348
|
+
" int height = 0;",
|
|
1349
|
+
" return gea_display_panel_buffer_count(&width, &height);",
|
|
1350
|
+
" }",
|
|
1351
|
+
"}",
|
|
1352
|
+
"",
|
|
1353
|
+
"// `ctx.createPanelImageData565(index)`: an `ImageData565` whose `data16` IS",
|
|
1354
|
+
"// display buffer `index`, so writing it draws the frame and `putImageData` of",
|
|
1355
|
+
"// it copies nothing. Empty (width 0) when there is no such buffer.",
|
|
1356
|
+
"template <typename I>",
|
|
1357
|
+
"inline ImageData565T<std::conditional_t<true, void, I>> canvasCreatePanelImageData565(gea::embedded::ui::CanvasRenderingContext2D &, const I &index) {",
|
|
1358
|
+
" ImageData565T<std::conditional_t<true, void, I>> out;",
|
|
1359
|
+
" using __gea_image_t = decltype(out);",
|
|
1360
|
+
" using __gea_array_t = typename __gea_image_t::array_type;",
|
|
1361
|
+
" // Dependent on `I` so it is looked up where the runtime is complete.",
|
|
1362
|
+
" using __gea_buffer_t = std::conditional_t<sizeof(I) != 0, gea::ArrayBuffer, void>;",
|
|
1363
|
+
" if constexpr (imageData565ZeroCopy) {",
|
|
1364
|
+
" int width = 0;",
|
|
1365
|
+
" int height = 0;",
|
|
1366
|
+
" const int count = gea_display_panel_buffer_count ? gea_display_panel_buffer_count(&width, &height) : 0;",
|
|
1367
|
+
" const int slot = canvasInt(index);",
|
|
1368
|
+
" std::uint16_t *pixels = slot >= 0 && slot < count && gea_display_panel_buffer ? gea_display_panel_buffer(slot) : nullptr;",
|
|
1369
|
+
" if (pixels && width > 0 && height > 0) {",
|
|
1370
|
+
" const std::size_t length = static_cast<std::size_t>(width) * static_cast<std::size_t>(height);",
|
|
1371
|
+
" auto bytes = gea::makeRef<__gea_buffer_t>(typename __gea_buffer_t::Borrowed{}, reinterpret_cast<std::uint8_t *>(pixels), length * sizeof(std::uint16_t));",
|
|
1372
|
+
" out.data16 = gea::makeRef<__gea_array_t>(__gea_array_t::fromBuffer(std::move(bytes), 0, length));",
|
|
1373
|
+
" out.width = width;",
|
|
1374
|
+
" out.height = height;",
|
|
1375
|
+
" // Spelled as the native pixel type: this branch is discarded where that is",
|
|
1376
|
+
" // not 16-bit (iOS, tvOS, macOS), but its non-dependent code is still checked.",
|
|
1377
|
+
" out.id = gea::framework::graphics::ImageStore::instance().registerBuffer(",
|
|
1378
|
+
" reinterpret_cast<gea::framework::graphics::pixel::native_t *>(pixels), width, height);",
|
|
1379
|
+
" return out;",
|
|
1380
|
+
" }",
|
|
1381
|
+
" }",
|
|
1382
|
+
" out.data16 = gea::makeRef<__gea_array_t>(std::size_t{0});",
|
|
1383
|
+
" return out;",
|
|
1384
|
+
"}",
|
|
1385
|
+
"",
|
|
1386
|
+
"// `ctx.acquirePanelBuffer()`: waits for the display to release the buffer the",
|
|
1387
|
+
"// next frame draws into and returns its index, or -1 (then draw into an",
|
|
1388
|
+
"// ordinary `ImageData565`). The frame must repaint every pixel of it.",
|
|
1389
|
+
"inline double canvasAcquirePanelBuffer(gea::embedded::ui::CanvasRenderingContext2D &) {",
|
|
1390
|
+
" if constexpr (!imageData565ZeroCopy) {",
|
|
1391
|
+
" return -1;",
|
|
1392
|
+
" } else {",
|
|
1393
|
+
" return gea_display_acquire_panel_buffer ? gea_display_acquire_panel_buffer() : -1;",
|
|
1394
|
+
" }",
|
|
1395
|
+
"}",
|
|
1396
|
+
"",
|
|
1332
1397
|
"template <typename D, typename X, typename Y>",
|
|
1333
1398
|
"inline void canvasPutImageData(gea::embedded::ui::CanvasRenderingContext2D &ctx, const ImageData565T<D> &image, const X &x, const Y &y) {",
|
|
1334
1399
|
" if (image.id < 0) return;",
|
|
@@ -72,6 +72,7 @@ const geaProfilerHostMethods = ['nowUs', 'nowCycles'];
|
|
|
72
72
|
const geaStorageHostMethods = ['getItem', 'setItem', 'removeItem', 'clear', 'key'];
|
|
73
73
|
const geaBatteryHostMethods = ['level', 'charging'];
|
|
74
74
|
const geaNotifyHostMethods = ['text', 'seq'];
|
|
75
|
+
const geaSimdHostMethods = ['sumWindowsU8'];
|
|
75
76
|
const geaDeviceControlHostMethods = ['exec'];
|
|
76
77
|
const geaNativeBenchHostMethods = [
|
|
77
78
|
'loopOverhead', 'arrayRead', 'arrayWrite', 'closure', 'methodCalls', 'mathIntensive',
|
|
@@ -123,6 +124,8 @@ const geaMemoryHostMethods = [
|
|
|
123
124
|
'allocationPsramBytes',
|
|
124
125
|
'allocationSramPeakBytes',
|
|
125
126
|
'allocationPsramPeakBytes',
|
|
127
|
+
'beginInternal',
|
|
128
|
+
'endInternal',
|
|
126
129
|
];
|
|
127
130
|
const rawGeaHostExternDeclarations = Object.fromEntries([
|
|
128
131
|
['gea::runtime::hostbase64::encode', geaBase64Declarations],
|
|
@@ -158,6 +161,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
|
|
|
158
161
|
...geaStorageHostMethods.map((method) => [`gea::host::Storage.${method}`, geaHostDeclarations]),
|
|
159
162
|
...geaBatteryHostMethods.map((method) => [`gea::host::Battery.${method}`, geaHostDeclarations]),
|
|
160
163
|
...geaNotifyHostMethods.map((method) => [`gea::host::Notify.${method}`, geaHostDeclarations]),
|
|
164
|
+
...geaSimdHostMethods.map((method) => [`gea::host::Simd.${method}`, geaHostDeclarations]),
|
|
161
165
|
...geaDeviceControlHostMethods.map((method) => [`gea::host::DeviceControl.${method}`, geaHostDeclarations]),
|
|
162
166
|
...geaNativeBenchHostMethods.map((method) => [`gea::host::native_bench::${method}`, geaNativeBenchDeclarations]),
|
|
163
167
|
...geaEpubArchiveHostMethods.map((method) => [`gea::host::epub_archive::${method}`, geaEpubArchiveDeclarations]),
|
package/dist/host-shims.js
CHANGED
|
@@ -125,6 +125,8 @@ const MEMORY_NO_THROW_METHODS = [
|
|
|
125
125
|
"displayFlushRows",
|
|
126
126
|
"displayFlushDepth",
|
|
127
127
|
"displayFlushBufferBytes",
|
|
128
|
+
"beginInternal",
|
|
129
|
+
"endInternal",
|
|
128
130
|
];
|
|
129
131
|
const HOST_NATIVE_CALLABLE_SIDECARS = [
|
|
130
132
|
...[
|
|
@@ -581,6 +583,8 @@ export function createGeaHostShims() {
|
|
|
581
583
|
__gea_Profiler: "gea::host::Profiler",
|
|
582
584
|
__gea_Battery: "gea::host::Battery",
|
|
583
585
|
__gea_Notify: "gea::host::Notify",
|
|
586
|
+
Simd: "gea::host::Simd",
|
|
587
|
+
__gea_Simd: "gea::host::Simd",
|
|
584
588
|
__gea_DeviceControl: "gea::host::DeviceControl",
|
|
585
589
|
// `console` is a PATH, not a value. An app that declares its own
|
|
586
590
|
// `declare const console: { log(message: string): void }` (several in
|
|
@@ -1256,6 +1260,8 @@ export function createGeaHostShims() {
|
|
|
1256
1260
|
allocationPsramBytes: "gea::host::Memory.allocationPsramBytes",
|
|
1257
1261
|
allocationSramPeakBytes: "gea::host::Memory.allocationSramPeakBytes",
|
|
1258
1262
|
allocationPsramPeakBytes: "gea::host::Memory.allocationPsramPeakBytes",
|
|
1263
|
+
beginInternal: "gea::host::Memory.beginInternal",
|
|
1264
|
+
endInternal: "gea::host::Memory.endInternal",
|
|
1259
1265
|
},
|
|
1260
1266
|
memory: {
|
|
1261
1267
|
internalFree: "gea::host::Memory.internalFree",
|
|
@@ -1279,6 +1285,8 @@ export function createGeaHostShims() {
|
|
|
1279
1285
|
allocationPsramBytes: "gea::host::Memory.allocationPsramBytes",
|
|
1280
1286
|
allocationSramPeakBytes: "gea::host::Memory.allocationSramPeakBytes",
|
|
1281
1287
|
allocationPsramPeakBytes: "gea::host::Memory.allocationPsramPeakBytes",
|
|
1288
|
+
beginInternal: "gea::host::Memory.beginInternal",
|
|
1289
|
+
endInternal: "gea::host::Memory.endInternal",
|
|
1282
1290
|
},
|
|
1283
1291
|
__gea_Memory: {
|
|
1284
1292
|
internalFree: "gea::host::Memory.internalFree",
|
|
@@ -1302,6 +1310,8 @@ export function createGeaHostShims() {
|
|
|
1302
1310
|
allocationPsramBytes: "gea::host::Memory.allocationPsramBytes",
|
|
1303
1311
|
allocationSramPeakBytes: "gea::host::Memory.allocationSramPeakBytes",
|
|
1304
1312
|
allocationPsramPeakBytes: "gea::host::Memory.allocationPsramPeakBytes",
|
|
1313
|
+
beginInternal: "gea::host::Memory.beginInternal",
|
|
1314
|
+
endInternal: "gea::host::Memory.endInternal",
|
|
1305
1315
|
},
|
|
1306
1316
|
Input: {
|
|
1307
1317
|
consumeBackButton: "gea::host::Input.consumeBackButton",
|
|
@@ -1421,6 +1431,12 @@ export function createGeaHostShims() {
|
|
|
1421
1431
|
text: "gea::host::Notify.text",
|
|
1422
1432
|
seq: "gea::host::Notify.seq",
|
|
1423
1433
|
},
|
|
1434
|
+
Simd: {
|
|
1435
|
+
sumWindowsU8: "gea::host::Simd.sumWindowsU8",
|
|
1436
|
+
},
|
|
1437
|
+
__gea_Simd: {
|
|
1438
|
+
sumWindowsU8: "gea::host::Simd.sumWindowsU8",
|
|
1439
|
+
},
|
|
1424
1440
|
DeviceControl: {
|
|
1425
1441
|
exec: "gea::host::DeviceControl.exec",
|
|
1426
1442
|
},
|
|
@@ -1455,6 +1471,8 @@ export function createGeaHostShims() {
|
|
|
1455
1471
|
__gea_Battery: ["level"],
|
|
1456
1472
|
Notify: ["seq"],
|
|
1457
1473
|
__gea_Notify: ["seq"],
|
|
1474
|
+
Simd: ["sumWindowsU8"],
|
|
1475
|
+
__gea_Simd: ["sumWindowsU8"],
|
|
1458
1476
|
},
|
|
1459
1477
|
hostNamespaceProperties: {
|
|
1460
1478
|
window: {
|
|
@@ -2562,6 +2580,9 @@ export function createGeaHostShims() {
|
|
|
2562
2580
|
drawImageRotated90CW: "gea_ir::canvasDrawImageRotated90CW($receiver, $args)",
|
|
2563
2581
|
drawImageTiledX: "gea_ir::canvasDrawImageTiledX($receiver, $args)",
|
|
2564
2582
|
createImageData565: "gea_ir::canvasCreateImageData565($receiver, $args)",
|
|
2583
|
+
panelBufferCount: "gea_ir::canvasPanelBufferCount($receiver /*$args*/)",
|
|
2584
|
+
createPanelImageData565: "gea_ir::canvasCreatePanelImageData565($receiver, $args)",
|
|
2585
|
+
acquirePanelBuffer: "gea_ir::canvasAcquirePanelBuffer($receiver /*$args*/)",
|
|
2565
2586
|
putImageData: "gea_ir::canvasPutImageData($receiver, $args)",
|
|
2566
2587
|
flush: "gea_ir::canvasFlush($receiver /*$args*/)",
|
|
2567
2588
|
beginBatch: "gea_ir::canvasBeginBatch($receiver /*$args*/)",
|