@asdf-overlay/electron 1.2.3 → 1.2.5
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/lib/surface.d.ts +0 -1
- package/lib/surface.js +26 -42
- package/package.json +2 -2
package/lib/surface.d.ts
CHANGED
package/lib/surface.js
CHANGED
|
@@ -17,19 +17,15 @@ export class ElectronOverlaySurface {
|
|
|
17
17
|
this.contents = contents;
|
|
18
18
|
this.surface = OverlaySurface.create(luid);
|
|
19
19
|
this.handler = (e, rect, image) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
20
|
+
try {
|
|
21
|
+
const update = e.texture ? this.paintAccelerated(e.texture) : this.paintSoftware(rect, image);
|
|
22
|
+
if (update) {
|
|
23
|
+
this.window.overlay.updateHandle(this.window.id, update)
|
|
24
|
+
.catch((e) => this.events.emit('error', e));
|
|
31
25
|
}
|
|
32
|
-
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
this.events.emit('error', err);
|
|
33
29
|
}
|
|
34
30
|
};
|
|
35
31
|
contents.on('paint', this.handler);
|
|
@@ -51,47 +47,35 @@ export class ElectronOverlaySurface {
|
|
|
51
47
|
/**
|
|
52
48
|
* Copy overlay texture in gpu accelerated shared texture mode.
|
|
53
49
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (texture.widgetType !== 'frame' || !texture.handle.ntHandle) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const rect = texture.metadata.captureUpdateRect ?? texture.contentRect;
|
|
60
|
-
// update only changed part
|
|
50
|
+
paintAccelerated(texture) {
|
|
51
|
+
const info = texture.textureInfo;
|
|
61
52
|
try {
|
|
62
|
-
|
|
53
|
+
// TODO:: cross platform handle
|
|
54
|
+
if (info.widgetType !== 'frame' || !info.handle.ntHandle) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const rect = info.metadata.captureUpdateRect ?? info.contentRect;
|
|
58
|
+
// update only changed part
|
|
59
|
+
return this.surface.updateShtex(info.codedSize.width, info.codedSize.height, info.handle.ntHandle, {
|
|
63
60
|
dstX: rect.x,
|
|
64
61
|
dstY: rect.y,
|
|
65
62
|
src: rect,
|
|
66
63
|
});
|
|
67
|
-
if (update) {
|
|
68
|
-
await this.window.overlay.updateHandle(this.window.id, update);
|
|
69
|
-
}
|
|
70
64
|
}
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
finally {
|
|
66
|
+
texture.release();
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
76
70
|
* Copy overlay texture from bitmap surface.
|
|
77
71
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await this.window.overlay.updateHandle(this.window.id, update);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
this.emitError(e);
|
|
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;
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (this.events.listenerCount('error') !== 0) {
|
|
92
|
-
this.events.emit('error', e);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
throw e;
|
|
78
|
+
// TODO:: update only changed part
|
|
79
|
+
return this.surface.updateBitmap(image.getSize().width, image.toBitmap());
|
|
96
80
|
}
|
|
97
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asdf-overlay/electron",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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.
|
|
37
|
+
"@asdf-overlay/core": "1.2.5"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build:dist": "tsc",
|