[x11,client] assert use of xfc->depth

Do not use color depth settings before they are initialized
This commit is contained in:
Armin Novak 2022-11-28 07:31:19 +01:00 committed by akallabeth
parent eda1359f52
commit 4008033065
4 changed files with 14 additions and 0 deletions

View File

@ -231,6 +231,7 @@ static Pixmap xf_brush_new(xfContext* xfc, UINT32 width, UINT32 height, UINT32 b
gdi = xfc->common.context.gdi;
WINPR_ASSERT(gdi);
WINPR_ASSERT(xfc->depth != 0);
bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, xfc->depth);
if (data)
@ -1004,6 +1005,7 @@ static BOOL xf_gdi_update_screen(xfContext* xfc, BYTE* pSrcData, UINT32 scanline
if (!(rects = region16_rects(pRegion, &nbRects)))
return TRUE;
WINPR_ASSERT(xfc->depth != 0);
if (xfc->depth > 16)
bpp = 4;
else if (xfc->depth > 8)

View File

@ -323,6 +323,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
if (FreeRDPAreColorFormatsEqualNoAlpha(gdi->dstFormat, surface->gdi.format))
{
WINPR_ASSERT(xfc->depth != 0);
surface->image =
XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0,
(char*)surface->gdi.data, surface->gdi.mappedWidth,
@ -344,6 +345,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context,
}
ZeroMemory(surface->stage, size);
WINPR_ASSERT(xfc->depth != 0);
surface->image =
XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)surface->stage,
surface->gdi.mappedWidth, surface->gdi.mappedHeight, xfc->scanline_pad,

View File

@ -117,6 +117,8 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
gdi = context->gdi;
xf_lock_x11(xfc);
depth = FreeRDPGetBitsPerPixel(bitmap->format);
WINPR_ASSERT(xfc->depth != 0);
xbitmap->pixmap =
XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, bitmap->height, xfc->depth);
@ -145,6 +147,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap)
bitmap->format = gdi->dstFormat;
}
WINPR_ASSERT(xfc->depth != 0);
xbitmap->image =
XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, (char*)bitmap->data,
bitmap->width, bitmap->height, xfc->scanline_pad, 0);
@ -782,6 +785,7 @@ UINT32 xf_get_local_color_format(xfContext* xfc, BOOL aligned)
invert = xfc->invert;
WINPR_ASSERT(xfc->depth != 0);
if (xfc->depth == 32)
DstFormat = (!invert) ? PIXEL_FORMAT_RGBA32 : PIXEL_FORMAT_BGRA32;
else if (xfc->depth == 30)

View File

@ -499,6 +499,7 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
window->is_mapped = FALSE;
window->is_transient = FALSE;
WINPR_ASSERT(xfc->depth != 0);
window->handle =
XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), xfc->workArea.x,
xfc->workArea.y, xfc->workArea.width, xfc->workArea.height, 0, xfc->depth,
@ -812,6 +813,8 @@ BOOL xf_AppWindowCreate(xfContext* xfc, xfAppWindow* appWindow)
appWindow->maxHorz = FALSE;
appWindow->minimized = FALSE;
appWindow->rail_ignore_configure = FALSE;
WINPR_ASSERT(xfc->depth != 0);
appWindow->handle =
XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen), appWindow->x, appWindow->y,
appWindow->width, appWindow->height, 0, xfc->depth, InputOutput, xfc->visual,
@ -1244,6 +1247,7 @@ UINT xf_AppUpdateWindowFromSurface(xfContext* xfc, gdiGfxSurface* surface)
if (!appWindow->image)
{
WINPR_ASSERT(xfc->depth != 0);
appWindow->image =
XCreateImage(xfc->display, xfc->visual, xfc->depth, ZPixmap, 0, surface->data,
surface->width, surface->height, xfc->scanline_pad, surface->scanline);
@ -1295,6 +1299,8 @@ BOOL xf_AppWindowResize(xfContext* xfc, xfAppWindow* appWindow)
if (appWindow->pixmap != 0)
XFreePixmap(xfc->display, appWindow->pixmap);
WINPR_ASSERT(xfc->depth != 0);
appWindow->pixmap =
XCreatePixmap(xfc->display, xfc->drawable, appWindow->width, appWindow->height, xfc->depth);
xf_AppWindowDestroyImage(appWindow);