@geastack/geatsc-plugin-gea 0.1.20 → 0.1.21-uart.1

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 CHANGED
@@ -1277,6 +1277,7 @@ const imageData565InteropSource = [
1277
1277
  "} // namespace gea_ir",
1278
1278
  '#include "image.h"',
1279
1279
  '#include "memory.h"',
1280
+ "#include <memory>",
1280
1281
  "namespace gea {",
1281
1282
  "template <typename T> class TypedArray;",
1282
1283
  "template <typename T> struct Ref;",
@@ -1344,7 +1345,55 @@ const imageData565InteropSource = [
1344
1345
  " for (std::size_t i = 0; i < count; ++i) dst[i] = gea::framework::graphics::pixel::toNative(src[i]);",
1345
1346
  " }",
1346
1347
  " }",
1347
- " ctx.drawImage(image.id, canvasInt(x), canvasInt(y));",
1348
+ " ctx.putImage(image.id, canvasInt(x), canvasInt(y));",
1349
+ "}",
1350
+ "",
1351
+ "// `putImageData(image, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight)`: only",
1352
+ "// the dirty rectangle of the image is drawn, at (dx + dirtyX, dy + dirtyY),",
1353
+ "// after the HTML spec's normalisation (negative sizes flip, then clamp).",
1354
+ "template <typename D, typename X, typename Y, typename RX, typename RY, typename RW, typename RH>",
1355
+ "inline void canvasPutImageData(gea::embedded::ui::CanvasRenderingContext2D &ctx, const ImageData565T<D> &image, const X &x, const Y &y,",
1356
+ " const RX &dirtyX, const RY &dirtyY, const RW &dirtyWidth, const RH &dirtyHeight) {",
1357
+ " const int width = static_cast<int>(image.width);",
1358
+ " const int height = static_cast<int>(image.height);",
1359
+ " if (width <= 0 || height <= 0 || image.id < 0) return;",
1360
+ " int rx = canvasInt(dirtyX);",
1361
+ " int ry = canvasInt(dirtyY);",
1362
+ " int rw = canvasInt(dirtyWidth);",
1363
+ " int rh = canvasInt(dirtyHeight);",
1364
+ " if (rw < 0) { rx += rw; rw = -rw; }",
1365
+ " if (rh < 0) { ry += rh; rh = -rh; }",
1366
+ " if (rx < 0) { rw += rx; rx = 0; }",
1367
+ " if (ry < 0) { rh += ry; ry = 0; }",
1368
+ " if (rx + rw > width) rw = width - rx;",
1369
+ " if (ry + rh > height) rh = height - ry;",
1370
+ " if (rw <= 0 || rh <= 0) return;",
1371
+ " if (rx == 0 && ry == 0 && rw == width && rh == height) {",
1372
+ " canvasPutImageData(ctx, image, x, y);",
1373
+ " return;",
1374
+ " }",
1375
+ " // Only the rectangle is converted, in place in the staging copy, and its",
1376
+ " // rows are drawn straight out of it: each row is contiguous, so no scratch",
1377
+ " // buffer is needed and several puts in one frame stay independent.",
1378
+ " const gea::framework::graphics::pixel::native_t *rows = nullptr;",
1379
+ " if constexpr (imageData565ZeroCopy) {",
1380
+ " rows = reinterpret_cast<const gea::framework::graphics::pixel::native_t *>((*image.data16).data());",
1381
+ " } else {",
1382
+ " if (!image.staging) return;",
1383
+ " const std::uint16_t *src = (*image.data16).data();",
1384
+ " for (int row = ry; row < ry + rh; ++row) {",
1385
+ " const std::size_t start = static_cast<std::size_t>(row) * static_cast<std::size_t>(width) + static_cast<std::size_t>(rx);",
1386
+ " gea::framework::graphics::pixel::native_t *dst = image.staging + start;",
1387
+ " if constexpr (std::is_same_v<gea::framework::graphics::pixel::native_t, std::uint16_t>) {",
1388
+ " for (int i = 0; i < rw; ++i) dst[i] = gea::framework::graphics::pixel::fromRgb565(src[start + i]);",
1389
+ " } else {",
1390
+ " for (int i = 0; i < rw; ++i) dst[i] = gea::framework::graphics::pixel::toNative(src[start + i]);",
1391
+ " }",
1392
+ " }",
1393
+ " rows = image.staging;",
1394
+ " }",
1395
+ " rows += static_cast<std::size_t>(ry) * static_cast<std::size_t>(width) + static_cast<std::size_t>(rx);",
1396
+ " ctx.drawPixelRows(rows, width, rw, rh, canvasInt(x) + rx, canvasInt(y) + ry);",
1348
1397
  "}",
1349
1398
  "",
1350
1399
  ];
@@ -1599,12 +1648,12 @@ export function directCanvasInteropSource(usesCanvas, options = {}) {
1599
1648
  "}",
1600
1649
  "",
1601
1650
  "template <typename Image, typename X, typename Y>",
1602
- "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y) {",
1651
+ "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D &ctx, const Image &image, const X &x, const Y &y) {",
1603
1652
  " ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y));",
1604
1653
  "}",
1605
1654
  "",
1606
1655
  "template <typename Image, typename X, typename Y, typename W, typename H>",
1607
- "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
1656
+ "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D &ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
1608
1657
  " ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y), canvasInt(w), canvasInt(h));",
1609
1658
  "}",
1610
1659
  "",
@@ -2345,12 +2394,12 @@ function canvasInteropSource(usesCanvas, directCanvas) {
2345
2394
  "}",
2346
2395
  "",
2347
2396
  "template <typename Image, typename X, typename Y>",
2348
- "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y) {",
2397
+ "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D &ctx, const Image &image, const X &x, const Y &y) {",
2349
2398
  " ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y));",
2350
2399
  "}",
2351
2400
  "",
2352
2401
  "template <typename Image, typename X, typename Y, typename W, typename H>",
2353
- "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
2402
+ "inline void canvasDrawImage(gea::embedded::ui::CanvasRenderingContext2D &ctx, const Image &image, const X &x, const Y &y, const W &w, const H &h) {",
2354
2403
  " ctx.drawImage(canvasImageId(image), canvasInt(x), canvasInt(y), canvasInt(w), canvasInt(h));",
2355
2404
  "}",
2356
2405
  "",
@@ -60,6 +60,7 @@ const geaGeolocationHostMethods = [
60
60
  'clearWatch',
61
61
  ];
62
62
  const geaInputHostMethods = ['consumeBackButton'];
63
+ const geaUartHostMethods = ['open', 'isOpen', 'close', 'read', 'write', 'available', 'writable'];
63
64
  const geaGpioHostMethods = ['configureOutput', 'configureInput', 'write', 'read'];
64
65
  const geaLedHostMethods = ['set', 'off', 'attach', 'setPixel', 'show', 'detach'];
65
66
  const geaClockHostMethods = ['epochMs'];
@@ -138,6 +139,7 @@ const rawGeaHostExternDeclarations = Object.fromEntries([
138
139
  ...geaTouchHostMethods.map((method) => [`gea::host::touch.${method}`, geaHostDeclarations]),
139
140
  ...geaMemoryHostMethods.map((method) => [`gea::host::Memory.${method}`, geaHostDeclarations]),
140
141
  ...geaInputHostMethods.map((method) => [`gea::host::Input.${method}`, geaHostDeclarations]),
142
+ ...geaUartHostMethods.map((method) => [`gea::host::Uart.${method}`, geaHostDeclarations]),
141
143
  ...geaGpioHostMethods.map((method) => [`gea::host::Gpio.${method}`, geaHostDeclarations]),
142
144
  ...geaLedHostMethods.map((method) => [`gea::host::Led.${method}`, geaHostDeclarations]),
143
145
  ...geaClockHostMethods.map((method) => [`gea::host::Clock.${method}`, geaHostDeclarations]),
@@ -552,6 +552,7 @@ export function createGeaHostShims() {
552
552
  __gea_Display: "gea::host::Display",
553
553
  __gea_Memory: "gea::host::Memory",
554
554
  __gea_Input: "gea::host::Input",
555
+ __gea_Uart: "gea::host::Uart",
555
556
  __gea_Gpio: "gea::host::Gpio",
556
557
  __gea_Led: "gea::host::Led",
557
558
  __gea_Clock: "gea::host::Clock",
@@ -1268,6 +1269,15 @@ export function createGeaHostShims() {
1268
1269
  write: "gea::host::Gpio.write",
1269
1270
  read: "gea::host::Gpio.read",
1270
1271
  },
1272
+ __gea_Uart: {
1273
+ open: "gea::host::Uart.open",
1274
+ isOpen: "gea::host::Uart.isOpen",
1275
+ close: "gea::host::Uart.close",
1276
+ read: "gea::host::Uart.read",
1277
+ write: "gea::host::Uart.write",
1278
+ available: "gea::host::Uart.available",
1279
+ writable: "gea::host::Uart.writable",
1280
+ },
1271
1281
  __gea_Gpio: {
1272
1282
  configureOutput: "gea::host::Gpio.configureOutput",
1273
1283
  configureInput: "gea::host::Gpio.configureInput",
@@ -1343,6 +1353,7 @@ export function createGeaHostShims() {
1343
1353
  Input: ["consumeBackButton"],
1344
1354
  __gea_Input: ["consumeBackButton"],
1345
1355
  Gpio: ["configureOutput", "configureInput", "write", "read"],
1356
+ __gea_Uart: ["open", "isOpen", "close", "available", "writable"],
1346
1357
  __gea_Gpio: ["configureOutput", "configureInput", "write", "read"],
1347
1358
  Led: ["set", "off", "attach", "setPixel", "show", "detach"],
1348
1359
  __gea_Led: ["set", "off", "attach", "setPixel", "show", "detach"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/geatsc-plugin-gea",
3
- "version": "0.1.20",
3
+ "version": "0.1.21-uart.1",
4
4
  "description": "Gea IR backend plugin for geatsc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {