summaryrefslogtreecommitdiff
path: root/glx/glxdri2.c
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-04-24 12:49:19 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-04-24 12:49:19 -0700
commitff6c7764c2909e4126403b7211faa6c58556b341 (patch)
tree87301de7ca62ce0676def6b8c7ef2a75b8e10c98 /glx/glxdri2.c
parent28ddfc88d8d547941c7f4713db527a3c2f9ec35a (diff)
DRI2: Implement protocol for DRI2GetBuffersWithFormat
This change implements the protocol for DRI2GetBuffersWithFormat, but the bulk of the differences are the changes to the extension / driver interface to make this function work. The old CreateBuffers and DeleteBuffers routines are replaced with CreateBuffer and DeleteBuffer (both singular). This allows drivers to allocate buffers for a drawable one at a time. As a result, 3D drivers can now allocate the (fake) front-buffer for a window only when it is needed. Since 3D drivers only ask for the front-buffer on demand, the real front-buffer is always created. This allows CopyRegion impelemenations of SwapBuffers to continue working. As with previous version of this code, if the client asks for the front-buffer for a window, we instead give it the fake front-buffer. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'glx/glxdri2.c')
-rw-r--r--glx/glxdri2.c59
1 files changed, 52 insertions, 7 deletions
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 612defb3f..529b2df10 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -406,7 +406,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
int *out_count, void *loaderPrivate)
{
__GLXDRIdrawable *private = loaderPrivate;
- DRI2BufferPtr buffers;
+ DRI2BufferPtr *buffers;
int i;
int j;
@@ -427,15 +427,59 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
/* Do not send the real front buffer of a window to the client.
*/
if ((private->base.pDraw->type == DRAWABLE_WINDOW)
- && (buffers[i].attachment == DRI2BufferFrontLeft)) {
+ && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
continue;
}
- private->buffers[j].attachment = buffers[i].attachment;
- private->buffers[j].name = buffers[i].name;
- private->buffers[j].pitch = buffers[i].pitch;
- private->buffers[j].cpp = buffers[i].cpp;
- private->buffers[j].flags = buffers[i].flags;
+ private->buffers[j].attachment = buffers[i]->attachment;
+ private->buffers[j].name = buffers[i]->name;
+ private->buffers[j].pitch = buffers[i]->pitch;
+ private->buffers[j].cpp = buffers[i]->cpp;
+ private->buffers[j].flags = buffers[i]->flags;
+ j++;
+ }
+
+ *out_count = j;
+ return private->buffers;
+}
+
+static __DRIbuffer *
+dri2GetBuffersWithFormat(__DRIdrawable *driDrawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *out_count, void *loaderPrivate)
+{
+ __GLXDRIdrawable *private = loaderPrivate;
+ DRI2BufferPtr *buffers;
+ int i;
+ int j = 0;
+
+ buffers = DRI2GetBuffersWithFormat(private->base.pDraw,
+ width, height, attachments, count,
+ out_count);
+ if (*out_count > MAX_DRAWABLE_BUFFERS) {
+ *out_count = 0;
+ return NULL;
+ }
+
+ private->width = *width;
+ private->height = *height;
+
+ /* This assumes the DRI2 buffer attachment tokens matches the
+ * __DRIbuffer tokens. */
+ for (i = 0; i < *out_count; i++) {
+ /* Do not send the real front buffer of a window to the client.
+ */
+ if ((private->base.pDraw->type == DRAWABLE_WINDOW)
+ && (buffers[i]->attachment == DRI2BufferFrontLeft)) {
+ continue;
+ }
+
+ private->buffers[j].attachment = buffers[i]->attachment;
+ private->buffers[j].name = buffers[i]->name;
+ private->buffers[j].pitch = buffers[i]->pitch;
+ private->buffers[j].cpp = buffers[i]->cpp;
+ private->buffers[j].flags = buffers[i]->flags;
j++;
}
@@ -454,6 +498,7 @@ static const __DRIdri2LoaderExtension loaderExtension = {
{ __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION },
dri2GetBuffers,
dri2FlushFrontBuffer,
+ dri2GetBuffersWithFormat,
};
static const __DRIextension *loader_extensions[] = {