tabby-rdp 0.3.1 → 0.3.2

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.
@@ -1628,19 +1628,20 @@ class QI {
1628
1628
  }
1629
1629
  async readBox(A, I, g, B) {
1630
1630
  var _a, _b;
1631
- if (this.stats.readback === "copyTo")
1631
+ if (this.stats.readback === "copyTo") {
1632
+ const D = { x: I.x + g.x, y: I.y + g.y, width: g.width, height: g.height };
1632
1633
  try {
1633
- await A.copyTo(B, {
1634
- rect: { x: I.x + g.x, y: I.y + g.y, width: g.width, height: g.height },
1635
- format: "RGBA",
1636
- colorSpace: "srgb"
1637
- });
1638
- return;
1639
- } catch (D) {
1640
- if (!(D instanceof DOMException && D.name === "NotSupportedError") && !(D instanceof TypeError))
1641
- throw D;
1634
+ if (A.allocationSize({ rect: D, format: "RGBA" }) === g.width * g.height * 4) {
1635
+ await A.copyTo(B, { rect: D, format: "RGBA", colorSpace: "srgb" });
1636
+ return;
1637
+ }
1638
+ this.stats.readback = "canvas";
1639
+ } catch (i) {
1640
+ if (!(i instanceof DOMException && i.name === "NotSupportedError") && !(i instanceof TypeError))
1641
+ throw i;
1642
1642
  this.stats.readback = "canvas";
1643
1643
  }
1644
+ }
1644
1645
  (this.canvas === null || this.canvas.width < g.width || this.canvas.height < g.height) && (this.canvas = new OffscreenCanvas(
1645
1646
  Math.max(g.width, ((_a = this.canvas) == null ? void 0 : _a.width) ?? 0),
1646
1647
  Math.max(g.height, ((_b = this.canvas) == null ? void 0 : _b.height) ?? 0)
@@ -1648,7 +1649,7 @@ class QI {
1648
1649
  const E = this.canvas.getContext("2d", { willReadFrequently: true, colorSpace: "srgb" });
1649
1650
  if (E === null)
1650
1651
  throw new Error("no 2D canvas context");
1651
- E.drawImage(A, g.x, g.y, g.width, g.height, 0, 0, g.width, g.height), B.set(E.getImageData(0, 0, g.width, g.height).data);
1652
+ E.drawImage(A, -g.x, -g.y, I.width, I.height), B.set(E.getImageData(0, 0, g.width, g.height).data);
1652
1653
  }
1653
1654
  stopWatchdog() {
1654
1655
  this.watchdog !== null && (clearInterval(this.watchdog), this.watchdog = null);