[PATCH v2 5/6] modesetting: Add support for using shadow buffers

Keith Packard keithp at keithp.com
Thu Jan 8 14:24:34 PST 2015


Jason Ekstrand <jason at jlekstrand.net> writes:


>  static PixmapPtr
> +drmmode_create_pixmap_header(ScreenPtr pScreen, int width, int height,
> +                             int depth, int bitsPerPixel, int devKind,
> +                             void *pPixData)
> +{
> +    PixmapPtr pixmap;
> +
> +    /* width and height of 0 means don't allocate any pixmap data */
> +    pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
> +
> +    if (pixmap) {
> +        if ((*pScreen->ModifyPixmapHeader)(pixmap, width, height, depth,
> +                                           bitsPerPixel, devKind, pPixData))
> +            return pixmap;
> +        (*pScreen->DestroyPixmap)(pixmap);
> +    }
> +    return NullPixmap;
> +}

This one looks correct, but seems like it's structured backwards from
the usual code when checking for errors. I think this is easier to
follow:

    /* width and height of 0 means don't allocate any pixmap data */
    pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
    if (!pixmap)
        return NullPixmap;

    if (!(*pScreen->ModifyPixmapHeader)(pixmap, width, height, depth,
                                        bitsPerPixel, devKind,
                                        pPixData)) {
        (*pScreen->DestroyPixmap)(pixmap);
        return NullPixmap;
    }
    return pixmap;

> +    if (shadow_pixmap == NULL) {
> +        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
> +                   "Couldn't allocate shadow pixmap for rotated CRTC\n");
> +        return NULL;

This error path will need to free the shadow data, if that was allocated
as a part of this function.

The rest of this patch has been

Reviewed-by: Keith Packard <keithp at keithp.com>

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150108/dc609988/attachment-0001.sig>


More information about the xorg-devel mailing list