Skip to content

Commit

Permalink
Merge pull request #325 from metalefty/v0.10-cherry-picks
Browse files Browse the repository at this point in the history
[v0.10] cherry-picks for v0.10.2
  • Loading branch information
metalefty authored Jul 30, 2024
2 parents 1368143 + 204199c commit c898f12
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 78 deletions.
149 changes: 72 additions & 77 deletions module/rdpCursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,6 @@ rdpSpriteSetCursorCon(rdpClientCon *clientCon,
LLOGLN(10, ("rdpSpriteSetCursorCon: suppress_output set"));
return;
}
if (pCurs == NULL)
{
return;
}
if (pCurs->bits == NULL)
{
return;
}
if (clientCon->client_info.size == 0)
{
return;
Expand All @@ -286,85 +278,98 @@ rdpSpriteSetCursorCon(rdpClientCon *clientCon,
#else
can_do_large = 0;
#endif
if (can_do_new || can_do_large)
if ((pCurs == NULL) || (pCurs->bits == NULL))
{
if (pCurs->bits->argb != NULL)
{
sending_bpp = 32;
}
/* None cursor */
sending_width = 32;
sending_height = 32;
xhot = 0;
yhot = 0;
memset(cur_data, 0, 96 * 96 * 4);
memset(cur_mask, 0xFF, 96 * 96 / 8);
}
server_width = pCurs->bits->width;
server_height = pCurs->bits->height;
if ((server_width > 32) || (server_height > 32))
else
{
if (sending_bpp == 32)
if (can_do_new || can_do_large)
{
if (pCurs->bits->argb != NULL)
{
sending_bpp = 32;
}
}
server_width = pCurs->bits->width;
server_height = pCurs->bits->height;
if ((server_width > 32) || (server_height > 32))
{
if (can_do_large)
{
client_max_width = 96;
client_max_height = 96;
}
}
}
sending_width = server_width > 32 ? client_max_width : 32;
sending_height = server_height > 32 ? client_max_height : 32;
LLOGLN(10, ("rdpSpriteSetCursorCon: sending_width %d sending_height %d "
"server_width %d server_height %d sending_bpp %d",
sending_width, sending_height, server_width, server_height,
sending_bpp));
if (sending_bpp == 32)
{
paddedRowBytes = PixmapBytePad(server_width, 32);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (uint8_t *)(pCurs->bits->argb);
memset(cur_data, 0, 96 * 96 * 4);
memset(cur_mask, 0, 96 * 96 / 8);
for (jndex = 0; jndex < sending_height; jndex++)
sending_width = server_width > 32 ? client_max_width : 32;
sending_height = server_height > 32 ? client_max_height : 32;
LLOGLN(10, ("rdpSpriteSetCursorCon: sending_width %d "
"sending_height %d server_width %d server_height %d "
"sending_bpp %d", sending_width, sending_height,
server_width, server_height, sending_bpp));
if (sending_bpp == 32)
{
for (index = 0; index < sending_width; index++)
paddedRowBytes = PixmapBytePad(server_width, 32);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (uint8_t *)(pCurs->bits->argb);
memset(cur_data, 0, 96 * 96 * 4);
memset(cur_mask, 0, 96 * 96 / 8);
for (jndex = 0; jndex < sending_height; jndex++)
{
pixel = get_pixel_safe(data, index, jndex, paddedRowBytes / 4,
server_height, 32);
set_pixel_safe(cur_data, index, (sending_height - 1) - jndex,
sending_width, sending_height, 32, pixel);
for (index = 0; index < sending_width; index++)
{
pixel = get_pixel_safe(data, index, jndex,
paddedRowBytes / 4,
server_height, 32);
set_pixel_safe(cur_data, index,
(sending_height - 1) - jndex,
sending_width, sending_height, 32, pixel);
}
}
}
}
else
{
paddedRowBytes = PixmapBytePad(server_width, 1);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (uint8_t *)(pCurs->bits->source);
mask = (uint8_t *)(pCurs->bits->mask);
fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) |
(((pCurs->foreGreen >> 8) & 0xff) << 8) |
((pCurs->foreBlue >> 8) & 0xff);
bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) |
(((pCurs->backGreen >> 8) & 0xff) << 8) |
((pCurs->backBlue >> 8) & 0xff);
memset(cur_data, 0, 96 * 96 * 4);
memset(cur_mask, 0, 96 * 96 / 8);
for (jndex = 0; jndex < sending_height; jndex++)
else
{
for (index = 0; index < sending_width; index++)
paddedRowBytes = PixmapBytePad(server_width, 1);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (uint8_t *)(pCurs->bits->source);
mask = (uint8_t *)(pCurs->bits->mask);
fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) |
(((pCurs->foreGreen >> 8) & 0xff) << 8) |
((pCurs->foreBlue >> 8) & 0xff);
bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) |
(((pCurs->backGreen >> 8) & 0xff) << 8) |
((pCurs->backBlue >> 8) & 0xff);
memset(cur_data, 0, 96 * 96 * 4);
memset(cur_mask, 0, 96 * 96 / 8);
for (jndex = 0; jndex < sending_height; jndex++)
{
pixel = get_pixel_safe(mask, index, jndex,
paddedRowBytes * 8,
server_height, 1);
set_pixel_safe(cur_mask, index,
(sending_height - 1) - jndex,
sending_width, sending_height, 1, !pixel);
if (pixel != 0)
for (index = 0; index < sending_width; index++)
{
pixel = get_pixel_safe(data, index, jndex,
pixel = get_pixel_safe(mask, index, jndex,
paddedRowBytes * 8,
server_height, 1);
pixel = pixel ? fgcolor : bgcolor;
set_pixel_safe(cur_data, index,
set_pixel_safe(cur_mask, index,
(sending_height - 1) - jndex,
sending_width, sending_height, 24, pixel);
sending_width, sending_height, 1, !pixel);
if (pixel != 0)
{
pixel = get_pixel_safe(data, index, jndex,
paddedRowBytes * 8,
server_height, 1);
pixel = pixel ? fgcolor : bgcolor;
set_pixel_safe(cur_data, index,
(sending_height - 1) - jndex,
sending_width, sending_height,
24, pixel);
}
}
}
}
Expand Down Expand Up @@ -394,16 +399,6 @@ rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs,
rdpClientCon *clientCon;

LLOGLN(10, ("rdpSpriteSetCursor:"));
if (pCurs == 0)
{
return;
}

if (pCurs->bits == 0)
{
return;
}

dev = rdpGetDevFromScreen(pScr);
clientCon = dev->clientConHead;
while (clientCon != NULL)
Expand Down
1 change: 1 addition & 0 deletions xrdpdev/xorg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Section "Device"
Driver "xrdpdev"
Option "DRMDevice" "/dev/dri/renderD128"
Option "DRI3" "1"
Option "DRMAllowList" "i915 radeon"
EndSection

Section "Screen"
Expand Down
54 changes: 53 additions & 1 deletion xrdpdev/xrdpdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ This is the main driver file

#include <xf86Modes.h>

#include <sys/ioctl.h>
#include <drm.h>

#include "rdp.h"
#include "rdpPri.h"
#include "rdpDraw.h"
Expand Down Expand Up @@ -72,6 +75,7 @@ This is the main driver file
char g_drm_device[128] = "/dev/dri/renderD128";
Bool g_use_dri2 = TRUE;
Bool g_use_dri3 = TRUE;
char g_drm_allow_list[128] = "";
#endif

#define LLOG_LEVEL 1
Expand Down Expand Up @@ -185,8 +189,47 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags)
}
else
{
struct drm_version dver;
char delim[] = " ";
char *token;
LLOGLN(0, ("rdpPreInit: %s open ok, fd %d", g_drm_device, dev->fd));
dev->glamor = TRUE;
memset(&dver, 0, sizeof(dver));
dver.name_len = 256;
dver.name = g_new0(char, dver.name_len);
dver.date_len = 256;
dver.date = g_new0(char, dver.date_len);
dver.desc_len = 256;
dver.desc = g_new0(char, dver.desc_len);
if (ioctl(dev->fd, DRM_IOCTL_VERSION, &dver) != -1)
{
LLOGLN(0, ("rdpPreInit: name [%s]", dver.name));
LLOGLN(0, ("rdpPreInit: date [%s]", dver.date));
LLOGLN(0, ("rdpPreInit: desc [%s]", dver.desc));
token = strtok(g_drm_allow_list, delim);
while (token != NULL)
{
LLOGLN(10, ("rdpPreInit: token [%s]", token));
if (strstr(dver.name, token) != NULL)
{
dev->glamor = TRUE;
LLOGLN(0, ("rdpPreInit: drm device looks ok, "
"use glamor set"));
break;
}
token = strtok(NULL, delim);
}
if (dev->glamor == FALSE)
{
LLOGLN(0, ("rdpPreInit: unsupported render node"));
}
}
else
{
LLOGLN(0, ("rdpPreInit: DRM_IOCTL_VERSION failed"));
}
free(dver.name);
free(dver.date);
free(dver.desc);
}
#endif

Expand Down Expand Up @@ -934,6 +977,15 @@ rdpProbe(DriverPtr drv, int flags)
g_use_dri3 = 0;
}
LLOGLN(0, ("rdpProbe: found DRI3 xorg.conf value [%s]", val));
#endif
}
val = xf86FindOptionValue(dev_sections[i]->options, "DRMAllowList");
if (val != NULL)
{
#if defined(XORGXRDP_GLAMOR)
strncpy(g_drm_allow_list, val, 127);
g_drm_device[127] = 0;
LLOGLN(0, ("rdpProbe: found DRMAllowList xorg.conf value [%s]", val));
#endif
}
entity = xf86ClaimFbSlot(drv, 0, dev_sections[i], 1);
Expand Down

0 comments on commit c898f12

Please sign in to comment.