@geastack/geatsc-plugin-gea 0.1.20 → 0.1.21
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 +54 -5
- package/package.json +1 -1
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.
|
|
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
|
"",
|