From 0535c49cac55d931c9d5b4178db050e6f6e543cf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 11 Jun 2019 23:46:20 +0200 Subject: Pixmap.c: call miModifyPixmapHeader twice instead of duplicating code --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 94 ++++------------------------- 1 file changed, 11 insertions(+), 83 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index f8241d4d7..371678d0e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -555,89 +555,18 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep bitsPerPixel, devKind, (void *) pPixData); #endif - if ((width > 0) && (height > 0) && (depth > 0) && - (bitsPerPixel > 0) && (devKind > 0) && pPixData) - { - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - pPixmap->drawable.id = 0; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pPixmap->drawable.x = 0; - pPixmap->drawable.y = 0; - pPixmap->drawable.width = width; - pPixmap->drawable.height = height; - pPixmap->devKind = devKind; - pPixmap->refcnt = 1; - pPixmap->devPrivate.ptr = pPixData; - - pVirtualPixmap->drawable.depth = depth; - pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel; - pVirtualPixmap->drawable.id = 0; - pVirtualPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pVirtualPixmap->drawable.x = 0; - pVirtualPixmap->drawable.y = 0; - pVirtualPixmap->drawable.width = width; - pVirtualPixmap->drawable.height = height; - pVirtualPixmap->devKind = devKind; - pVirtualPixmap->refcnt = 1; - pVirtualPixmap->devPrivate.ptr = pPixData; - } - else - { - if (width > 0) - pPixmap->drawable.width = width; - - if (height > 0) - pPixmap->drawable.height = height; - - if (depth > 0) - pPixmap->drawable.depth = depth; - - if (bitsPerPixel > 0) - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - else if ((bitsPerPixel < 0) && (depth > 0)) - pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth); - - if (devKind > 0) - pPixmap->devKind = devKind; - else if ((devKind < 0) && ((width > 0) || (depth > 0))) - pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width, - pPixmap->drawable.depth); - - if (pPixData) - pPixmap->devPrivate.ptr = pPixData; - - /* - * XXX This was the previous assignment: - * - * pVirtualPixmap->devPrivate.ptr = pPixData; - */ - - if (width > 0) - pVirtualPixmap->drawable.width = width; - - if (height > 0) - pVirtualPixmap->drawable.height = height; - - if (depth > 0) - pVirtualPixmap->drawable.depth = depth; - - if (bitsPerPixel > 0) - pVirtualPixmap->drawable.bitsPerPixel = bitsPerPixel; - else if ((bitsPerPixel < 0) && (depth > 0)) - pVirtualPixmap->drawable.bitsPerPixel = BitsPerPixel(depth); - - if (devKind > 0) - pVirtualPixmap->devKind = devKind; - else if ((devKind < 0) && ((width > 0) || (depth > 0))) - pVirtualPixmap->devKind = PixmapBytePad(pVirtualPixmap->drawable.width, - pVirtualPixmap->drawable.depth); + /* + * ignore return code, because the only case where this will return + * FALSE is pPixmap == NULL, which we have already caught above. + */ + miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); + miModifyPixmapHeader(pVirtualPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); - if (pPixData) - pVirtualPixmap->devPrivate.ptr = pPixData; - - #ifdef PANIC + #ifdef PANIC + if (!((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) && + (devKind > 0) && pPixData)) + { if (pPixmap->drawable.x != 0 || pPixmap->drawable.y != 0) { fprintf(stderr, "nxagentModifyPixmapHeader: PANIC! Pixmap at [%p] has x [%d] and y [%d].\n", @@ -645,9 +574,8 @@ Bool nxagentModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int dep FatalError("nxagentModifyPixmapHeader: PANIC! Pixmap has x or y greater than zero."); } - - #endif } + #endif return True; } -- cgit v1.2.3