static int ProcDRI2GetBuffers(ClientPtr client) { REQUEST(xDRI2GetBuffersReq); DrawablePtr pDrawable; DRI2BufferPtr *buffers; int status, width, height, count; unsigned int *attachments; REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4); if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess, &pDrawable, &status)) return status; if (DRI2ThrottleClient(client, pDrawable)) return Success; attachments = (unsigned int *) &stuff[1]; buffers = DRI2GetBuffers(pDrawable, &width, &height, attachments, stuff->count, &count); return send_buffers_reply(client, pDrawable, buffers, count, width, height); }
static int send_buffers_reply(ClientPtr client, DrawablePtr pDrawable, DRI2BufferPtr * buffers, int count, int width, int height) { xDRI2GetBuffersReply rep; int skip = 0; int i; if (buffers == NULL) return BadAlloc; if (pDrawable->type == DRAWABLE_WINDOW) { for (i = 0; i < count; i++) { /* Do not send the real front buffer of a window to the client. */ if (buffers[i]->attachment == DRI2BufferFrontLeft) { skip++; continue; } } } rep = (xDRI2GetBuffersReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = (count - skip) * sizeof(xDRI2Buffer) / 4, .width = width, .height = height, .count = count - skip }; WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep); for (i = 0; i < count; i++) { xDRI2Buffer buffer; /* Do not send the real front buffer of a window to the client. */ if ((pDrawable->type == DRAWABLE_WINDOW) && (buffers[i]->attachment == DRI2BufferFrontLeft)) { continue; } buffer.attachment = buffers[i]->attachment; buffer.name = buffers[i]->name; buffer.pitch = buffers[i]->pitch; buffer.cpp = buffers[i]->cpp; buffer.flags = buffers[i]->flags; WriteToClient(client, sizeof(xDRI2Buffer), &buffer); } return Success; } static int ProcDRI2GetBuffers(ClientPtr client) { REQUEST(xDRI2GetBuffersReq); DrawablePtr pDrawable; DRI2BufferPtr *buffers; int status, width, height, count; unsigned int *attachments; REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4); if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess, &pDrawable, &status)) return status; if (DRI2ThrottleClient(client, pDrawable)) return Success; attachments = (unsigned int *) &stuff[1]; buffers = DRI2GetBuffers(pDrawable, &width, &height, attachments, stuff->count, &count); return send_buffers_reply(client, pDrawable, buffers, count, width, height); }