Skip to content

Commit

Permalink
dynamic resize working with accel_assist
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorg71 committed Nov 7, 2024
1 parent 8d1fe99 commit d70ee62
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
22 changes: 14 additions & 8 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ static void
rdpClientConProcessClientInfoMonitors(rdpPtr dev, rdpClientCon *clientCon);
static int
rdpSendMemoryAllocationComplete(rdpPtr dev, rdpClientCon *clientCon);
static int
rdpSendAccelAssistMonitors(rdpPtr dev, rdpClientCon *clientCon);

#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 18, 5, 0, 0)

Expand Down Expand Up @@ -400,6 +402,7 @@ rdpShutdownAccelAssist(rdpPtr dev, rdpClientCon *clientCon) {
}
}
clientCon->accel_assist_pid = -1;
clientCon->use_accel_assist = 0;
return exit_code;
}

Expand Down Expand Up @@ -489,7 +492,7 @@ rdpClientConDisconnect(rdpPtr dev, rdpClientCon *clientCon)
clientCon->shmemfd,
clientCon->shmem_bytes);
}
if (rdpClientConUseAccelAssist(dev, clientCon))
if (clientCon->use_accel_assist)
{
rdpShutdownAccelAssist(dev, clientCon);
}
Expand Down Expand Up @@ -973,7 +976,6 @@ rdpClientConProcessMonitorUpdateMsg(rdpPtr dev, rdpClientCon *clientCon,
LLOGLN(0, ("rdpClientConProcessMonitorUpdateMsg: (%dx%d) #%d",
width, height, num_monitors));


// Update the client_info we have
clientCon->client_info.display_sizes.monitorCount = num_monitors;
for (i = 0; i < num_monitors; ++i)
Expand All @@ -991,6 +993,11 @@ rdpClientConProcessMonitorUpdateMsg(rdpPtr dev, rdpClientCon *clientCon,
rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, width, height);
rdpSendMemoryAllocationComplete(dev, clientCon);

if (clientCon->use_accel_assist)
{
rdpSendAccelAssistMonitors(dev, clientCon);
}

return 0;
}

Expand Down Expand Up @@ -1425,18 +1432,17 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon)
rdpInputKeyboardEvent(dev, 18, (long)(&(clientCon->client_info)),
0, 0, 0);

rdpSendMemoryAllocationComplete(dev, clientCon);
rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, clientCon->rdp_width,
clientCon->rdp_height);

/* currently only nvenc and h264 is supported */
if (rdpClientConUseAccelAssist(dev, clientCon))
{
clientCon->use_accel_assist = 1;
rdpStartAccelAssist(dev, clientCon);
rdpSendAccelAssistMonitors(dev, clientCon);
}
else
{
rdpSendMemoryAllocationComplete(dev, clientCon);
rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, clientCon->rdp_width,
clientCon->rdp_height);
}

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions module/rdpClientCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ struct _rdpClientCon
/* true = skip drawing */
int suppress_output;

int use_accel_assist;
int accel_assist_pid;

struct _rdpClientCon *next;
Expand Down
30 changes: 27 additions & 3 deletions module/rdpPutImage.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,42 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y,
if (clientCon->conNumber == pBits32[1])
{
/* free old */
pixmap = clientCon->accelAssistPixmaps[pBits32[2] & 0xF];
int monitor_index = pBits32[2] & 0xF;
pixmap = clientCon->accelAssistPixmaps[monitor_index];
if (pixmap != NULL)
{
pScreen->DestroyPixmap(pixmap);
}
/* set new */
pixmap = (PixmapPtr) pDst;
LLOGLN(0, ("rdpPutImage: setting conNumber %d, monitor num %d "
"to pixmap %p", pBits32[1], pBits32[2], pixmap));
clientCon->accelAssistPixmaps[pBits32[2] & 0xF] = pixmap;
"to pixmap %p", pBits32[1], monitor_index, pixmap));
clientCon->accelAssistPixmaps[monitor_index] = pixmap;
/* so it can not get freed early */
pixmap->refcnt++;
/* invalidate */
if (dev->monitorCount < 1)
{
LLOGLN(0, ("rdpPutImage: monitor_index %d "
"invalidating 0 0 %d %d",
monitor_index, dev->width, dev->height));
rdpClientConAddDirtyScreen(dev, clientCon, 0, 0,
dev->width, dev->height);
}
else if (monitor_index < dev->monitorCount)
{
int left = dev->minfo[monitor_index].left;
int top = dev->minfo[monitor_index].top;
int width = dev->minfo[monitor_index].right -
dev->minfo[monitor_index].left + 1;
int height = dev->minfo[monitor_index].bottom -
dev->minfo[monitor_index].top + 1;
LLOGLN(0, ("rdpPutImage: monitor_index %d "
"invalidating %d %d %d %d",
monitor_index, left, top, width, height));
rdpClientConAddDirtyScreen(dev, clientCon,
left, top , width, height);
}
break;
}
clientCon = clientCon->next;
Expand Down

0 comments on commit d70ee62

Please sign in to comment.