Skip to content

Commit 9cd6d48

Browse files
committed
VNC-151 Enhance video frame rendering by adding positional parameters and strict property checks.
1 parent 343fd29 commit 9cd6d48

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

core/display.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -799,16 +799,22 @@ export default class Display {
799799
}
800800
}
801801

802-
videoFrameRect(frame) {
803-
if (frame.displayWidth === 0 || frame.displayHeight === 0) {
802+
videoFrameRect(frame, frame_id, x, y, width, height) {
803+
if (frame.displayWidth === 0 || frame.displayHeight === 0 || frame.codedWidth === 0 || frame.codedHeight === 0) {
804804
return false;
805805
}
806+
806807
const rect = {
807808
type: 'video_frame',
808809
frame,
810+
x,
811+
y,
812+
width,
813+
height,
814+
frame_id
809815
};
810816
// TODO: REMoVE
811-
this.drawVideoFrame(frame);
817+
// this.drawVideoFrame(frame, x, y, width, height);
812818

813819
this._processRectScreens(rect);
814820
this._asyncRenderQPush(rect);
@@ -937,16 +943,16 @@ export default class Display {
937943
targetCtx.drawImage(img, x, y);
938944
}
939945
} catch (error) {
940-
Log.Error('Invalid image recieved.'); //KASM-2090
946+
Log.Error('Invalid image received.'); //KASM-2090
941947
}
942948
}
943949

944-
drawVideoFrame(videoFrame) {
950+
drawVideoFrame(videoFrame, x, y, w, h) {
945951
try {
946952
let targetCtx = ((this._enableCanvasBuffer) ? this._drawCtx : this._targetCtx);
947-
targetCtx.drawImage(videoFrame, 0, 0, videoFrame.displayWidth, videoFrame.displayHeight, 0, 0, videoFrame.displayWidth, videoFrame.displayHeight);
953+
targetCtx.drawImage(videoFrame, x, y, w, h);
948954
} catch (error) {
949-
Log.Error('Invalid video frame recieved.', error);
955+
Log.Error('Invalid video frame received.', error);
950956
}
951957
}
952958

@@ -1101,7 +1107,7 @@ export default class Display {
11011107
a.img.close();
11021108
break;
11031109
case 'video_frame':
1104-
this.drawVideoFrame(a.frame);
1110+
this.drawVideoFrame(a.frame, pos.x, pos.y, a.frame.codedWidth, a.frame.codedHeight);
11051111
a.frame.close();
11061112
break;
11071113
default:
@@ -1294,7 +1300,7 @@ export default class Display {
12941300

12951301
for (let sI = 0; sI < a.screenLocations.length; sI++) {
12961302
let screenLocation = a.screenLocations[sI];
1297-
if (screenLocation.screenIndex == 0) {
1303+
if (screenLocation.screenIndex === 0) {
12981304
switch (a.type) {
12991305
case 'copy':
13001306
this.copyImage(screenLocation.oldX, screenLocation.oldY, screenLocation.x, screenLocation.y, a.width, a.height, a.frame_id, true);
@@ -1321,7 +1327,7 @@ export default class Display {
13211327
this.drawImage(a.img, screenLocation.x, screenLocation.y, a.width, a.height);
13221328
break;
13231329
case 'video_frame':
1324-
this.drawVideoFrame(a.frame);
1330+
this.drawVideoFrame(a.frame, screenLocation.x, screenLocation.y, a.frame.codedWidth, a.frame.codedHeight);
13251331
a.frame.close();
13261332
break;
13271333
default:

0 commit comments

Comments
 (0)