Skip to content

Commit

Permalink
Removing scroll rect. Minor improvements to logging and code flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexarian committed May 29, 2022
1 parent 68505c8 commit e4c6fb3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 79 deletions.
99 changes: 37 additions & 62 deletions module/rdpCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion module/rdpCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 22 additions & 16 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit e4c6fb3

Please sign in to comment.