From e4c6fb396c7baca0b7f256d32b482c143dce5899 Mon Sep 17 00:00:00 2001 From: Nexarian Date: Sun, 29 May 2022 12:55:38 -0400 Subject: [PATCH] Removing scroll rect. Minor improvements to logging and code flow. --- module/rdpCapture.c | 99 ++++++++++++++++--------------------------- module/rdpCapture.h | 2 +- module/rdpClientCon.c | 38 ++++++++++------- 3 files changed, 60 insertions(+), 79 deletions(-) diff --git a/module/rdpCapture.c b/module/rdpCapture.c index 1b3c6439..5fa8be12 100644 --- a/module/rdpCapture.c +++ b/module/rdpCapture.c @@ -832,33 +832,30 @@ rdpCopyBoxList(rdpClientCon *clientCon, PixmapPtr dstPixmap, pScreen = dev->pScreen; hwPixmap = pScreen->GetScreenPixmap(pScreen); copyGC = GetScratchGC(dev->depth, pScreen); - if (copyGC != NULL) + if (copyGC == NULL) { - tmpval[0].val = GXcopy; - ChangeGC(NullClient, copyGC, GCFunction, tmpval); - ValidateGC(&(hwPixmap->drawable), copyGC); - count = num_out_rects; - pbox = out_rects; - for (index = 0; index < count; index++) - { - left = pbox[index].x1; - top = pbox[index].y1; - width = pbox[index].x2 - pbox[index].x1; - height = pbox[index].y2 - pbox[index].y1; - if ((width > 0) && (height > 0)) - { - copyGC->ops->CopyArea(&(hwPixmap->drawable), - &(dstPixmap->drawable), - copyGC, left, top, - width, height, left, top); - } - } - FreeScratchGC(copyGC); + return FALSE; } - else + tmpval[0].val = GXcopy; + ChangeGC(NullClient, copyGC, GCFunction, tmpval); + ValidateGC(&(hwPixmap->drawable), copyGC); + count = num_out_rects; + pbox = out_rects; + for (index = 0; index < count; index++) { - return FALSE; + left = pbox[index].x1; + top = pbox[index].y1; + width = pbox[index].x2 - pbox[index].x1; + height = pbox[index].y2 - pbox[index].y1; + if ((width > 0) && (height > 0)) + { + copyGC->ops->CopyArea(&(hwPixmap->drawable), + &(dstPixmap->drawable), + copyGC, left, top, + width, height, left, top); + } } + FreeScratchGC(copyGC); pScreen->GetImage(&(dstPixmap->drawable), 0, 0, 1, 1, ZPixmap, 0xffffffff, pix1); @@ -1139,14 +1136,13 @@ rdpCapture1(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, /******************************************************************************/ static Bool rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, - int *num_out_rects, BoxPtr scroll_rect, struct image_data *id) + int *num_out_rects, struct image_data *id) { int x; int y; int out_rect_index; int num_rects; int rcode; - int in_scroll_rect; BoxRec rect; BoxRec extents_rect; BoxPtr rects; @@ -1239,18 +1235,6 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, x += 64; } - scroll_rect->x1 = 0; - scroll_rect->x2 = 0; - scroll_rect->y1 = 0; - scroll_rect->y2 = 0; - - *out_rects = g_new(BoxRec, RDP_MAX_TILES); - if (*out_rects == NULL) - { - return FALSE; - } - out_rect_index = 0; - extents_rect = *rdpRegionExtents(in_reg); y = extents_rect.y1 & ~63; num_skips = 0; while (y < extents_rect.y2) @@ -1265,11 +1249,6 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, rcode = rdpRegionContainsRect(in_reg, &rect); LLOGLN(10, ("rdpCapture2: rcode %d", rcode)); - in_scroll_rect = (rect.x1 >= scroll_rect->x1) - && (rect.x2 <= scroll_rect->x2) - && (rect.y1 >= scroll_rect->y1) - && (rect.y2 <= scroll_rect->y2); - if (rcode != rgnOUT) { /* hex digits of pi as a 64 bit int */ @@ -1308,24 +1287,21 @@ rdpCapture2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, else { clientCon->rfx_crcs[crc_offset] = crc; - if(!in_scroll_rect) + /* lazily only do this if hash wasn't identical */ + if (rcode != rgnPART) + { + rdpCopyBox_a8r8g8b8_to_yuvalp(x, y, + src, src_stride, + dst, dst_stride, + &rect, 1); + } + (*out_rects)[out_rect_index] = rect; + out_rect_index++; + if (out_rect_index >= RDP_MAX_TILES) { - /* lazily only do this if hash wasn't identical */ - if (rcode != rgnPART) - { - rdpCopyBox_a8r8g8b8_to_yuvalp(x, y, - src, src_stride, - dst, dst_stride, - &rect, 1); - } - (*out_rects)[out_rect_index] = rect; - out_rect_index++; - if (out_rect_index >= RDP_MAX_TILES) - { - free(*out_rects); - *out_rects = NULL; - return FALSE; - } + free(*out_rects); + *out_rects = NULL; + return FALSE; } } } @@ -1482,7 +1458,7 @@ rdpCapture3(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, *****************************************************************************/ Bool rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, - int *num_out_rects, BoxPtr scroll_rect, struct image_data *id) + int *num_out_rects, struct image_data *id) { int mode; @@ -1496,8 +1472,7 @@ rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, return rdpCapture1(clientCon, in_reg, out_rects, num_out_rects, id); case 2: /* used for remotefx capture */ - return rdpCapture2(clientCon, in_reg, out_rects, num_out_rects, - scroll_rect, id); + return rdpCapture2(clientCon, in_reg, out_rects, num_out_rects, id); case 3: /* used for even align capture */ return rdpCapture3(clientCon, in_reg, out_rects, num_out_rects, id); diff --git a/module/rdpCapture.h b/module/rdpCapture.h index ec2a5417..97ae1d51 100644 --- a/module/rdpCapture.h +++ b/module/rdpCapture.h @@ -35,7 +35,7 @@ capture extern _X_EXPORT Bool rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects, - int *num_out_rects, BoxPtr scroll_rect, struct image_data *id); + int *num_out_rects, struct image_data *id); extern _X_EXPORT int a8r8g8b8_to_a8b8g8r8_box(const uint8_t *s8, int src_stride, diff --git a/module/rdpClientCon.c b/module/rdpClientCon.c index 3cc4dfd6..22adc46f 100644 --- a/module/rdpClientCon.c +++ b/module/rdpClientCon.c @@ -1071,34 +1071,40 @@ rdpSendMemoryAllocationComplete(rdpPtr dev, rdpClientCon *clientCon) { int len; int rv; + int width = dev->width; + int height = dev->height; + int alignment = 0; const int layer_size = 8; - int width; - int height; - switch (clientCon->client_info.capture_code) { - case 2: //RFX - width = RDPALIGN(dev->width, XRDP_RFX_ALIGN); - height = RDPALIGN(dev->height, XRDP_RFX_ALIGN); - case 3: //H264 - width = RDPALIGN(dev->width, XRDP_H264_ALIGN); - height = RDPALIGN(dev->height, XRDP_H264_ALIGN); + switch (clientCon->client_info.capture_code) + { + case 2: + alignment = XRDP_RFX_ALIGN; + break; + case 3: + alignment = XRDP_H264_ALIGN; + break; default: - width = dev->width; - height = dev->height; + break; + } + if (alignment != 0) + { + width = RDPALIGN(dev->width, alignment); + height = RDPALIGN(dev->height, alignment); } rdpClientConSendPending(dev, clientCon); init_stream(clientCon->out_s, 0); s_push_layer(clientCon->out_s, iso_hdr, layer_size); clientCon->count++; - out_uint16_le(clientCon->out_s, 3); + out_uint16_le(clientCon->out_s, 3); /* code: memory allocation complete */ out_uint16_le(clientCon->out_s, 8); /* size */ out_uint16_le(clientCon->out_s, width); out_uint16_le(clientCon->out_s, height); s_mark_end(clientCon->out_s); len = (int) (clientCon->out_s->end - clientCon->out_s->data); s_pop_layer(clientCon->out_s, iso_hdr); - out_uint16_le(clientCon->out_s, 100); + out_uint16_le(clientCon->out_s, 100); /* Metadata message to xrdp (or if using helper, helper signal) */ out_uint16_le(clientCon->out_s, clientCon->count); out_uint32_le(clientCon->out_s, len - layer_size); rv = rdpClientConSend(dev, clientCon, clientCon->out_s->data, len); @@ -2636,6 +2642,8 @@ rdpClientConSendPaintRectShmEx(rdpPtr dev, rdpClientCon *clientCon, struct stream *s; BoxRec box; + LLOGLN(10, ("rdpClientConSendPaintRectShmEx:")); + rdpClientConBeginUpdate(dev, clientCon); num_rects_d = REGION_NUM_RECTS(dirtyReg); @@ -2707,7 +2715,6 @@ rdpCapRect(rdpClientCon *clientCon, BoxPtr cap_rect, struct image_data *id) { RegionPtr cap_dirty; BoxRec rect; - BoxRec scroll_rect; BoxPtr rects; int num_rects; @@ -2730,8 +2737,7 @@ rdpCapRect(rdpClientCon *clientCon, BoxPtr cap_rect, struct image_data *id) num_rects = 0; LLOGLN(10, ("rdpCapRect: capture_code %d", clientCon->client_info.capture_code)); - if (rdpCapture(clientCon, cap_dirty, &rects, &num_rects, - &scroll_rect, id)) + if (rdpCapture(clientCon, cap_dirty, &rects, &num_rects, id)) { LLOGLN(10, ("rdpCapRect: num_rects %d", num_rects)); rdpClientConSendPaintRectShmEx(clientCon->dev, clientCon, id,