react-x11 2.26.3 → 2.27.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-x11",
3
- "version": "2.26.3",
3
+ "version": "2.27.0",
4
4
  "description": "react renderer with X11 as a target",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -103,12 +103,12 @@
103
103
  "dependencies": {
104
104
  "ical.js": "^2.2.1",
105
105
  "linebreak": "^1.1.0",
106
- "ntk": "^8.16.1",
106
+ "ntk": "^8.17.8",
107
107
  "react-reconciler": "^0.34.0",
108
108
  "yoga-layout": "^3.2.1"
109
109
  },
110
110
  "optionalDependencies": {
111
- "@windowkit/appkit": "^0.17.0",
111
+ "@windowkit/appkit": "^0.18.0",
112
112
  "@windowkit/wayland": "^3.1.1",
113
113
  "@windowkit/win32": "^0.0.6",
114
114
  "dbus-native": "^0.16.0",
@@ -1562,7 +1562,23 @@ export class BackendContext2D {
1562
1562
  dw = sw;
1563
1563
  dh = sh;
1564
1564
  }
1565
- if (!this._blit(src, sx, sy, sw, sh, dx, dy, dw, dh)) {
1565
+ if (this._blit(src, sx, sy, sw, sh, dx, dy, dw, dh)) {
1566
+ // a row memcpy
1567
+ } else if (this._faded()) {
1568
+ this._native.ctxDrawSurfaceFaded(
1569
+ this._s(),
1570
+ src,
1571
+ sx,
1572
+ sy,
1573
+ sw,
1574
+ sh,
1575
+ dx,
1576
+ dy,
1577
+ dw,
1578
+ dh,
1579
+ this._state.globalAlpha,
1580
+ );
1581
+ } else {
1566
1582
  this._native.ctxDrawSurface(
1567
1583
  this._s(),
1568
1584
  src,
@@ -1579,6 +1595,41 @@ export class BackendContext2D {
1579
1595
  this._dirty();
1580
1596
  }
1581
1597
 
1598
+ /**
1599
+ * Whether a surface is drawn under this `globalAlpha` from its pixels
1600
+ * scaled by it (@windowkit/appkit's `ctxDrawSurfaceFaded`): where the
1601
+ * alpha is below 1, no shadow would ink, and the bridge has the verb.
1602
+ * CoreGraphics draws an image under an alpha below 1 at some fifteen times
1603
+ * what the same draw costs at 1 — a 556x300 surface 1.24ms against 0.09 —
1604
+ * so a group faded on a surface (`NodePaint._paintGroup`) cost more than
1605
+ * fading each thing in it; scaled first, the same colours within a unit
1606
+ * take 0.25ms (#810). A shadow is drawn from the image and the alpha
1607
+ * together, so a draw that casts one is left to the draw that always did.
1608
+ */
1609
+ _faded() {
1610
+ const st = this._state;
1611
+ if (!(st.globalAlpha < 1)) return false;
1612
+ if (typeof this._native.ctxDrawSurfaceFaded !== 'function') return false;
1613
+ return !(
1614
+ parseColor(st.shadowColor)[3] > 0 &&
1615
+ (st.shadowBlur > 0 || st.shadowOffsetX !== 0 || st.shadowOffsetY !== 0)
1616
+ );
1617
+ }
1618
+
1619
+ /**
1620
+ * `true` where a surface drawn under a `globalAlpha` below 1 costs about
1621
+ * what it costs drawn at 1 — the macOS context, over a bridge with
1622
+ * `ctxDrawSurfaceFaded` — so that a group faded on a surface of its own,
1623
+ * as CSS `opacity` has it, is the cheaper way to fade what overlaps, and
1624
+ * not only the right one. Absent where that is not known: on Windows,
1625
+ * where Direct2D draws the bitmap with the opacity and nobody has
1626
+ * measured it, and on X11, whose server composites a surface under an
1627
+ * alpha in the request that composites it at all.
1628
+ */
1629
+ get fadesSurfacesCheaply() {
1630
+ return typeof this._native.ctxDrawSurfaceFaded === 'function' || undefined;
1631
+ }
1632
+
1582
1633
  /**
1583
1634
  * The bitmap a `drawImage` source composites from: a surface's own, an
1584
1635
  * ntk Image's upload (made on its first draw, see `uploadImage`), or
package/src/node.d.ts CHANGED
@@ -159,6 +159,18 @@ export interface Context2D {
159
159
  * asks this first.
160
160
  */
161
161
  readonly scalesText?: boolean;
162
+ /**
163
+ * `true` where a `Surface` drawn under a `globalAlpha` below 1 costs about
164
+ * what it costs drawn at 1 — the macOS context, over a bridge that scales
165
+ * the surface's pixels by the alpha rather than drawing it through
166
+ * CoreGraphics' own alpha, which costs some fifteen times as much. Where
167
+ * it is true, fading a group drawn on a surface of its own — CSS
168
+ * `opacity` — is cheaper than fading each thing drawn in it, as well as
169
+ * right where they overlap. Absent where that is not known: Windows, and
170
+ * X11, whose server composites a surface under an alpha in the request
171
+ * that composites it.
172
+ */
173
+ readonly fadesSurfacesCheaply?: boolean;
162
174
  measureText(text: string): { width: number; [key: string]: unknown };
163
175
  /**
164
176
  * Composite an offscreen `Surface` (`react-x11/ntk`) — whole at a point,