Skip to content

Commit

Permalink
Fix GFX resize issues
Browse files Browse the repository at this point in the history
On a GFX resize, clear the CRC areas to ensure that a full frame
is transmitted when output restarts.

Also, rename rdpClientSetSharedMemoryParameters() as
rdpClientConResizeAllMemoryAreas() as this is more descriptive
of what the routime is actually doing.
  • Loading branch information
matt335672 committed Feb 20, 2024
1 parent bbb6ecf commit b493abd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
27 changes: 27 additions & 0 deletions module/rdpCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,3 +1162,30 @@ rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
}
return FALSE;
}

/**
* Reset any capture state fields following a memory resize
*****************************************************************************/
void
rdpCaptureResetState(rdpClientCon *clientCon)
{
int mode;
int i;

LLOGLN(10, ("rdpCapReset:"));
mode = clientCon->client_info.capture_code;
switch (mode)
{
case 2:
case 4:
for (i = 0 ; i < 16; ++i)
{
free(clientCon->rfx_crcs[i]);
clientCon->rfx_crcs[i] = NULL;
clientCon->num_rfx_crcs_alloc[i] = 0;
}
break;
default:
break;
}
}
3 changes: 3 additions & 0 deletions module/rdpCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ extern _X_EXPORT Bool
rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
int *num_out_rects, struct image_data *id);

extern _X_EXPORT void
rdpCaptureResetState(rdpClientCon *clientCon);

extern _X_EXPORT int
a8r8g8b8_to_a8b8g8r8_box(const uint8_t *s8, int src_stride,
uint8_t *d8, int dst_stride,
Expand Down
12 changes: 7 additions & 5 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ convertSharedMemoryStatusToActive(enum shared_memory_status status) {

/******************************************************************************/
/**
* Sets all the parameters relating to the shared memory, and
* resizes it.
* Resizes all memory areas following a change in client geometry or
* capture format.
*
* Call this when any of the following are changed:-
* - clientCon->client_info.display_sizes.session_width
Expand All @@ -763,7 +763,7 @@ convertSharedMemoryStatusToActive(enum shared_memory_status status) {
* All the remaining memory and capture parameters are adjusted
*/
static void
rdpClientSetSharedMemoryParameters(rdpPtr dev, rdpClientCon *clientCon)
rdpClientConResizeAllMemoryAreas(rdpPtr dev, rdpClientCon *clientCon)
{
int bytes;
int width = clientCon->client_info.display_sizes.session_width;
Expand Down Expand Up @@ -878,6 +878,8 @@ rdpClientSetSharedMemoryParameters(rdpPtr dev, rdpClientCon *clientCon)
LLOGLN(0, ("rdpClientConProcessScreenSizeMsg: RRScreenSizeSet ok=[%d]", ok));
}

rdpCaptureResetState(clientCon);

if (clientCon->shmemstatus == SHM_UNINITIALIZED
|| clientCon->shmemstatus == SHM_RESIZING)
{
Expand Down Expand Up @@ -907,7 +909,7 @@ rdpClientConProcessMonitorUpdateMsg(rdpPtr dev, rdpClientCon *clientCon,
clientCon->client_info.display_sizes.session_width = width;
clientCon->client_info.display_sizes.session_height = height;

rdpClientSetSharedMemoryParameters(dev, clientCon);
rdpClientConResizeAllMemoryAreas(dev, clientCon);
rdpClientConProcessClientInfoMonitors(dev, clientCon);

/* Tell xrdp we're done */
Expand Down Expand Up @@ -1159,7 +1161,7 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon)
clientCon->rdp_Bpp_mask = 0xffffff;
}

rdpClientSetSharedMemoryParameters(dev, clientCon);
rdpClientConResizeAllMemoryAreas(dev, clientCon);
rdpClientConProcessClientInfoMonitors(dev, clientCon);

if (clientCon->client_info.offscreen_support_level > 0)
Expand Down

0 comments on commit b493abd

Please sign in to comment.