Xext: panoramiX: PanoramiXGetImage() reply payload in one block
Simplify writing reply payload into just one block. This also makes further simplifications by subsequent patches easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
165eb1be2b
commit
48918f28d9
|
@ -1960,7 +1960,6 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
DrawablePtr pDraw;
|
DrawablePtr pDraw;
|
||||||
PanoramiXRes *draw;
|
PanoramiXRes *draw;
|
||||||
Bool isRoot;
|
Bool isRoot;
|
||||||
char *pBuf;
|
|
||||||
int i, x, y, w, h, format, rc;
|
int i, x, y, w, h, format, rc;
|
||||||
Mask plane = 0, planemask;
|
Mask plane = 0, planemask;
|
||||||
int linesDone, nlines, linesPerBuf;
|
int linesDone, nlines, linesPerBuf;
|
||||||
|
@ -2032,7 +2031,6 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
IncludeInferiors);
|
IncludeInferiors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format == ZPixmap) {
|
if (format == ZPixmap) {
|
||||||
widthBytesLine = PixmapBytePad(w, pDraw->depth);
|
widthBytesLine = PixmapBytePad(w, pDraw->depth);
|
||||||
length = widthBytesLine * h;
|
length = widthBytesLine * h;
|
||||||
|
@ -2046,14 +2044,6 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xGetImageReply rep = {
|
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client->sequence,
|
|
||||||
.visual = wVisual(((WindowPtr) pDraw)),
|
|
||||||
.depth = pDraw->depth,
|
|
||||||
.length = bytes_to_int32(length),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (widthBytesLine == 0 || h == 0)
|
if (widthBytesLine == 0 || h == 0)
|
||||||
linesPerBuf = 0;
|
linesPerBuf = 0;
|
||||||
else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
|
else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
|
||||||
|
@ -2063,15 +2053,9 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
if (linesPerBuf > h)
|
if (linesPerBuf > h)
|
||||||
linesPerBuf = h;
|
linesPerBuf = h;
|
||||||
}
|
}
|
||||||
if (!(pBuf = calloc(linesPerBuf, widthBytesLine)))
|
|
||||||
return BadAlloc;
|
|
||||||
|
|
||||||
if (client->swapped) {
|
char *payload = calloc(1, length);
|
||||||
swaps(&rep.sequenceNumber);
|
char *walk = payload;
|
||||||
swapl(&rep.length);
|
|
||||||
swapl(&rep.visual);
|
|
||||||
}
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
|
||||||
|
|
||||||
if (linesPerBuf == 0) {
|
if (linesPerBuf == 0) {
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
|
@ -2081,14 +2065,11 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
while (h - linesDone > 0) {
|
while (h - linesDone > 0) {
|
||||||
nlines = min(linesPerBuf, h - linesDone);
|
nlines = min(linesPerBuf, h - linesDone);
|
||||||
|
|
||||||
if (pDraw->depth == 1)
|
|
||||||
memset(pBuf, 0, nlines * widthBytesLine);
|
|
||||||
|
|
||||||
XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
|
XineramaGetImageData(drawables, x, y + linesDone, w, nlines,
|
||||||
format, planemask, pBuf, widthBytesLine,
|
format, planemask, walk, widthBytesLine,
|
||||||
isRoot);
|
isRoot);
|
||||||
|
|
||||||
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
|
walk += nlines * widthBytesLine;
|
||||||
linesDone += nlines;
|
linesDone += nlines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2099,20 +2080,30 @@ PanoramiXGetImage(ClientPtr client)
|
||||||
while (h - linesDone > 0) {
|
while (h - linesDone > 0) {
|
||||||
nlines = min(linesPerBuf, h - linesDone);
|
nlines = min(linesPerBuf, h - linesDone);
|
||||||
|
|
||||||
memset(pBuf, 0, nlines * widthBytesLine);
|
|
||||||
|
|
||||||
XineramaGetImageData(drawables, x, y + linesDone, w,
|
XineramaGetImageData(drawables, x, y + linesDone, w,
|
||||||
nlines, format, plane, pBuf,
|
nlines, format, plane, walk,
|
||||||
widthBytesLine, isRoot);
|
widthBytesLine, isRoot);
|
||||||
|
|
||||||
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
|
walk += nlines * widthBytesLine;
|
||||||
|
|
||||||
linesDone += nlines;
|
linesDone += nlines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(pBuf);
|
|
||||||
|
xGetImageReply xgi = {
|
||||||
|
.type = X_Reply,
|
||||||
|
.sequenceNumber = client->sequence,
|
||||||
|
.visual = wVisual(((WindowPtr) pDraw)),
|
||||||
|
.depth = pDraw->depth,
|
||||||
|
.length = bytes_to_int32(length),
|
||||||
|
};
|
||||||
|
|
||||||
|
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
|
||||||
|
|
||||||
|
if (length)
|
||||||
|
WriteToClient(client, length, payload);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue