@asdf-overlay/electron 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/lib/surface.js +25 -28
  2. package/package.json +2 -2
package/lib/surface.js CHANGED
@@ -17,20 +17,12 @@ export class ElectronOverlaySurface {
17
17
  this.contents = contents;
18
18
  this.surface = OverlaySurface.create(luid);
19
19
  this.handler = (e, rect, image) => {
20
- const offscreenTexture = e.texture;
21
- if (offscreenTexture) {
22
- void this.paintAccelerated(offscreenTexture.textureInfo).finally(() => {
23
- offscreenTexture.release();
20
+ const update = e.texture ? this.paintAccelerated(e.texture) : this.paintSoftware(rect, image);
21
+ if (update) {
22
+ this.window.overlay.updateHandle(this.window.id, update).catch((e) => {
23
+ this.emitError(e);
24
24
  });
25
25
  }
26
- else {
27
- const size = image.getSize();
28
- // offscreenTexture undefined if image is empty, handle the case
29
- if (size.width === 0 || size.height === 0) {
30
- return;
31
- }
32
- void this.paintSoftware(rect, image);
33
- }
34
26
  };
35
27
  contents.on('paint', this.handler);
36
28
  contents.invalidate();
@@ -51,41 +43,46 @@ export class ElectronOverlaySurface {
51
43
  /**
52
44
  * Copy overlay texture in gpu accelerated shared texture mode.
53
45
  */
54
- async paintAccelerated(texture) {
55
- // TODO:: cross platform handle
56
- if (texture.widgetType !== 'frame' || !texture.handle.ntHandle) {
57
- return;
58
- }
59
- const rect = texture.metadata.captureUpdateRect ?? texture.contentRect;
60
- // update only changed part
46
+ paintAccelerated(texture) {
47
+ const info = texture.textureInfo;
61
48
  try {
62
- const update = this.surface.updateShtex(texture.codedSize.width, texture.codedSize.height, texture.handle.ntHandle, {
49
+ // TODO:: cross platform handle
50
+ if (info.widgetType !== 'frame' || !info.handle.ntHandle) {
51
+ return null;
52
+ }
53
+ const rect = info.metadata.captureUpdateRect ?? info.contentRect;
54
+ // update only changed part
55
+ return this.surface.updateShtex(info.codedSize.width, info.codedSize.height, info.handle.ntHandle, {
63
56
  dstX: rect.x,
64
57
  dstY: rect.y,
65
58
  src: rect,
66
59
  });
67
- if (update) {
68
- await this.window.overlay.updateHandle(this.window.id, update);
69
- }
70
60
  }
71
61
  catch (e) {
72
62
  this.emitError(e);
73
63
  }
64
+ finally {
65
+ texture.release();
66
+ }
67
+ return null;
74
68
  }
75
69
  /**
76
70
  * Copy overlay texture from bitmap surface.
77
71
  */
78
- async paintSoftware(_dirtyRect, image) {
72
+ paintSoftware(_dirtyRect, image) {
73
+ const size = image.getSize();
74
+ // offscreenTexture undefined if image is empty, handle the case
75
+ if (size.width === 0 || size.height === 0) {
76
+ return null;
77
+ }
79
78
  // TODO:: update only changed part
80
79
  try {
81
- const update = this.surface.updateBitmap(image.getSize().width, image.toBitmap());
82
- if (update) {
83
- await this.window.overlay.updateHandle(this.window.id, update);
84
- }
80
+ return this.surface.updateBitmap(image.getSize().width, image.toBitmap());
85
81
  }
86
82
  catch (e) {
87
83
  this.emitError(e);
88
84
  }
85
+ return null;
89
86
  }
90
87
  emitError(e) {
91
88
  if (this.events.listenerCount('error') !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asdf-overlay/electron",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Asdf overlay Electron integration",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "peerDependencies": {
36
36
  "electron": "^40.1.0",
37
- "@asdf-overlay/core": "1.2.3"
37
+ "@asdf-overlay/core": "1.2.4"
38
38
  },
39
39
  "scripts": {
40
40
  "build:dist": "tsc",