[PATCH 04/12] dix: Remove a dead parameter from DoGetImage

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 16 19:26:52 PDT 2012


On Tue, Oct 16, 2012 at 02:56:17PM -0400, Adam Jackson wrote:
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  dix/dispatch.c | 88 +++++++++++++++++++++-------------------------------------
>  1 file changed, 31 insertions(+), 57 deletions(-)
> 
> diff --git a/dix/dispatch.c b/dix/dispatch.c
> index 2df1a6e..0f4e80a 100644
> --- a/dix/dispatch.c
> +++ b/dix/dispatch.c
> @@ -1969,7 +1969,7 @@ ProcPutImage(ClientPtr client)
>  static int
>  DoGetImage(ClientPtr client, int format, Drawable drawable,
>             int x, int y, int width, int height,
> -           Mask planemask, xGetImageReply ** im_return)
> +           Mask planemask)
>  {
>      DrawablePtr pDraw, pBoundingDraw;
>      int nlines, linesPerBuf, rc;
> @@ -2069,46 +2069,32 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
>  
>      xgi.length = length;
>  
> -    if (im_return) {
> -        pBuf = calloc(1, sz_xGetImageReply + length);
> -        if (!pBuf)
> -            return BadAlloc;
> -        if (widthBytesLine == 0)
> -            linesPerBuf = 0;
> -        else
> +    xgi.length = bytes_to_int32(xgi.length);

this seems to leave us with two xgi.length assignments, you could squash
those two together.

Cheers,
   Peter

> +    if (widthBytesLine == 0 || height == 0)
> +        linesPerBuf = 0;
> +    else if (widthBytesLine >= IMAGE_BUFSIZE)
> +        linesPerBuf = 1;
> +    else {
> +        linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
> +        if (linesPerBuf > height)
>              linesPerBuf = height;
> -        *im_return = (xGetImageReply *) pBuf;
> -        *(xGetImageReply *) pBuf = xgi;
> -        pBuf += sz_xGetImageReply;
>      }
> -    else {
> -        xgi.length = bytes_to_int32(xgi.length);
> -        if (widthBytesLine == 0 || height == 0)
> -            linesPerBuf = 0;
> -        else if (widthBytesLine >= IMAGE_BUFSIZE)
> -            linesPerBuf = 1;
> -        else {
> -            linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
> -            if (linesPerBuf > height)
> -                linesPerBuf = height;
> +    length = linesPerBuf * widthBytesLine;
> +    if (linesPerBuf < height) {
> +        /* we have to make sure intermediate buffers don't need padding */
> +        while ((linesPerBuf > 1) &&
> +               (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1))) {
> +            linesPerBuf--;
> +            length -= widthBytesLine;
>          }
> -        length = linesPerBuf * widthBytesLine;
> -        if (linesPerBuf < height) {
> -            /* we have to make sure intermediate buffers don't need padding */
> -            while ((linesPerBuf > 1) &&
> -                   (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1))) {
> -                linesPerBuf--;
> -                length -= widthBytesLine;
> -            }
> -            while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1)) {
> -                linesPerBuf++;
> -                length += widthBytesLine;
> -            }
> +        while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1)) {
> +            linesPerBuf++;
> +            length += widthBytesLine;
>          }
> -        if (!(pBuf = calloc(1, length)))
> -            return BadAlloc;
> -        WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
>      }
> +    if (!(pBuf = calloc(1, length)))
> +        return BadAlloc;
> +    WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
>  
>      if (pDraw->type == DRAWABLE_WINDOW) {
>          pVisibleRegion = NotClippedByChildren((WindowPtr) pDraw);
> @@ -2137,13 +2123,10 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
>  
>              /* Note that this is NOT a call to WriteSwappedDataToClient,
>                 as we do NOT byte swap */
> -            if (!im_return) {
> -                ReformatImage(pBuf, (int) (nlines * widthBytesLine),
> -                              BitsPerPixel(pDraw->depth), ClientOrder(client));
> +            ReformatImage(pBuf, (int) (nlines * widthBytesLine),
> +                          BitsPerPixel(pDraw->depth), ClientOrder(client));
>  
> -/* Don't split me, gcc pukes when you do */
> -                WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
> -            }
> +            WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
>              linesDone += nlines;
>          }
>      }
> @@ -2168,18 +2151,10 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
>  
>                      /* Note: NOT a call to WriteSwappedDataToClient,
>                         as we do NOT byte swap */
> -                    if (im_return) {
> -                        pBuf += nlines * widthBytesLine;
> -                    }
> -                    else {
> -                        ReformatImage(pBuf,
> -                                      (int) (nlines * widthBytesLine),
> -                                      1, ClientOrder(client));
> -
> -/* Don't split me, gcc pukes when you do */
> -                        WriteToClient(client, (int) (nlines * widthBytesLine),
> -				      pBuf);
> -                    }
> +                    ReformatImage(pBuf, (int) (nlines * widthBytesLine),
> +                                  1, ClientOrder(client));
> +
> +                    WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
>                      linesDone += nlines;
>                  }
>              }
> @@ -2187,8 +2162,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
>      }
>      if (pVisibleRegion)
>          RegionDestroy(pVisibleRegion);
> -    if (!im_return)
> -        free(pBuf);
> +    free(pBuf);
>      return Success;
>  }
>  
> @@ -2202,7 +2176,7 @@ ProcGetImage(ClientPtr client)
>      return DoGetImage(client, stuff->format, stuff->drawable,
>                        stuff->x, stuff->y,
>                        (int) stuff->width, (int) stuff->height,
> -                      stuff->planeMask, (xGetImageReply **) NULL);
> +                      stuff->planeMask);
>  }
>  
>  int
> -- 
> 1.7.12.1
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list