From 8528969efdb03421fa97368c5d687cb275ad321c Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 25 Jul 2021 00:28:37 -0400 Subject: [PATCH] [host] nvfbc: clamp damage rectangles to screen size --- host/platform/Windows/capture/NVFBC/src/nvfbc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/host/platform/Windows/capture/NVFBC/src/nvfbc.c b/host/platform/Windows/capture/NVFBC/src/nvfbc.c index fe587852..02458524 100644 --- a/host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -392,11 +392,15 @@ static void updateDamageRects(CaptureFrame * frame) goto done; } + int x1 = ds[y * w + x].x1 * 128; + int y1 = ds[y * w + x].y1 * 128; + int x2 = min((ds[y * w + x].x2 + 1) * 128, this->width); + int y2 = min((ds[y * w + x].y2 + 1) * 128, this->height); frame->damageRects[rectId++] = (FrameDamageRect) { - .x = ds[y * w + x].x1 * 128, - .y = ds[y * w + x].y1 * 128, - .width = (ds[y * w + x].x2 - ds[y * w + x].x1 + 1) * 128, - .height = (ds[y * w + x].y2 - ds[y * w + x].y1 + 1) * 128, + .x = x1, + .y = y1, + .width = x2 - x1, + .height = y2 - y1, }; }