(!1796) dri3: consolidate reply buffers
Allocate reply buffers on stack and put multiple fragments into one buffer, in order to make it easier doing write out by generic macros, in subsequent commits. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
e32927e8cf
commit
73a8b21464
|
|
@ -391,13 +391,19 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
|
||||||
&nwindowmodifiers, &window_modifiers,
|
&nwindowmodifiers, &window_modifiers,
|
||||||
&nscreenmodifiers, &screen_modifiers);
|
&nscreenmodifiers, &screen_modifiers);
|
||||||
|
|
||||||
|
CARD64 buf[nwindowmodifiers+nscreenmodifiers];
|
||||||
|
memcpy(buf, window_modifiers, sizeof(CARD64)*nwindowmodifiers);
|
||||||
|
memcpy(&buf[nwindowmodifiers], screen_modifiers, sizeof(CARD64)*nscreenmodifiers);
|
||||||
|
|
||||||
|
free(window_modifiers);
|
||||||
|
free(screen_modifiers);
|
||||||
|
|
||||||
xDRI3GetSupportedModifiersReply rep = {
|
xDRI3GetSupportedModifiersReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.numWindowModifiers = nwindowmodifiers,
|
.numWindowModifiers = nwindowmodifiers,
|
||||||
.numScreenModifiers = nscreenmodifiers,
|
.numScreenModifiers = nscreenmodifiers,
|
||||||
.length = bytes_to_int32(nwindowmodifiers * sizeof(CARD64)) +
|
.length = bytes_to_int32(sizeof(buf)),
|
||||||
bytes_to_int32(nscreenmodifiers* sizeof(CARD64)),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
|
|
@ -405,19 +411,12 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
swapl(&rep.numWindowModifiers);
|
swapl(&rep.numWindowModifiers);
|
||||||
swapl(&rep.numScreenModifiers);
|
swapl(&rep.numScreenModifiers);
|
||||||
for (i = 0; i < nwindowmodifiers; i++)
|
for (i = 0; i < nwindowmodifiers+nscreenmodifiers; i++)
|
||||||
swapll(&window_modifiers[i]);
|
swapll(&buf[i]);
|
||||||
for (i = 0; i < nscreenmodifiers; i++)
|
|
||||||
swapll(&screen_modifiers[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
WriteToClient(client, sizeof(rep), &rep);
|
||||||
WriteToClient(client, nwindowmodifiers * sizeof(CARD64), window_modifiers);
|
WriteToClient(client, sizeof(buf), buf);
|
||||||
WriteToClient(client, nscreenmodifiers * sizeof(CARD64), screen_modifiers);
|
|
||||||
|
|
||||||
free(window_modifiers);
|
|
||||||
free(screen_modifiers);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -547,11 +546,15 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CARD32 buf[num_fds * 2];
|
||||||
|
memcpy(buf, strides, num_fds * sizeof(CARD32));
|
||||||
|
memcpy(&buf[num_fds], offsets, num_fds * sizeof(CARD32));
|
||||||
|
|
||||||
xDRI3BuffersFromPixmapReply rep = {
|
xDRI3BuffersFromPixmapReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.nfd = num_fds,
|
.nfd = num_fds,
|
||||||
.length = bytes_to_int32(num_fds * 2 * sizeof(CARD32)),
|
.length = bytes_to_int32(sizeof(buf)),
|
||||||
.width = pixmap->drawable.width,
|
.width = pixmap->drawable.width,
|
||||||
.height = pixmap->drawable.height,
|
.height = pixmap->drawable.height,
|
||||||
.depth = pixmap->drawable.depth,
|
.depth = pixmap->drawable.depth,
|
||||||
|
|
@ -565,15 +568,12 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
||||||
swaps(&rep.width);
|
swaps(&rep.width);
|
||||||
swaps(&rep.height);
|
swaps(&rep.height);
|
||||||
swapll(&rep.modifier);
|
swapll(&rep.modifier);
|
||||||
for (i = 0; i < num_fds; i++) {
|
for (i = 0; i < num_fds * 2; i++)
|
||||||
swapl(&strides[i]);
|
swapl(&buf[i]);
|
||||||
swapl(&offsets[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteToClient(client, sizeof(rep), &rep);
|
WriteToClient(client, sizeof(rep), &rep);
|
||||||
WriteToClient(client, num_fds * sizeof(CARD32), strides);
|
WriteToClient(client, sizeof(buf), buf);
|
||||||
WriteToClient(client, num_fds * sizeof(CARD32), offsets);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue