summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-02-24 15:34:16 +0800
committerChia-I Wu <[email protected]>2010-02-25 21:29:37 +0800
commit29ec53d8439eab85f39de02bd18539c26410d2bf (patch)
treeafed732062ce39238830b3fe441259309926af05 /src/gallium
parent545ac97f9b95e9b5ebd04d2960abb224b5adbe17 (diff)
st/egl: Refactor dri2_surface_get_buffers.
Add dri2_surface_process_drawable_buffers to process the buffers returned by the server.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c118
1 files changed, 67 insertions, 51 deletions
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index feae025dcc7..f4072bb0cda 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -98,65 +98,23 @@ dri2_config(const struct native_config *nconf)
}
/**
- * Get the buffers from the server.
+ * Process the buffers returned by the server.
*/
static void
-dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask)
+dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
+ struct x11_drawable_buffer *xbufs,
+ int num_xbufs)
{
struct dri2_surface *dri2surf = dri2_surface(nsurf);
struct dri2_display *dri2dpy = dri2surf->dri2dpy;
- unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS];
- int num_ins, num_outs, att, i;
- struct x11_drawable_buffer *xbufs;
struct pipe_texture templ;
uint valid_mask;
+ int i;
- /* prepare the attachments */
- num_ins = 0;
- for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
- if (native_attachment_mask_test(buffer_mask, att)) {
- unsigned int dri2att;
-
- switch (att) {
- case NATIVE_ATTACHMENT_FRONT_LEFT:
- dri2att = DRI2BufferFrontLeft;
- break;
- case NATIVE_ATTACHMENT_BACK_LEFT:
- dri2att = DRI2BufferBackLeft;
- break;
- case NATIVE_ATTACHMENT_FRONT_RIGHT:
- dri2att = DRI2BufferFrontRight;
- break;
- case NATIVE_ATTACHMENT_BACK_RIGHT:
- dri2att = DRI2BufferBackRight;
- break;
- default:
- assert(0);
- dri2att = 0;
- break;
- }
-
- dri2atts[num_ins] = dri2att;
- num_ins++;
- }
- }
-
- xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable,
- &dri2surf->width, &dri2surf->height,
- dri2atts, FALSE, num_ins, &num_outs);
-
- /* we should be able to do better... */
- if (xbufs && dri2surf->last_num_xbufs == num_outs &&
- memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) {
- free(xbufs);
- return;
- }
-
- /* free the old buffers */
+ /* free the old textures */
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
pipe_texture_reference(&dri2surf->textures[i], NULL);
dri2surf->valid_mask = 0x0;
- dri2surf->sequence_number++;
dri2surf->have_back = FALSE;
dri2surf->have_fake = FALSE;
@@ -174,7 +132,7 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask)
templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
valid_mask = 0x0;
- for (i = 0; i < num_outs; i++) {
+ for (i = 0; i < num_xbufs; i++) {
struct x11_drawable_buffer *xbuf = &xbufs[i];
const char *desc;
enum native_attachment natt;
@@ -214,12 +172,70 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask)
valid_mask |= 1 << natt;
}
+ dri2surf->valid_mask = valid_mask;
+}
+
+/**
+ * Get the buffers from the server.
+ */
+static void
+dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask)
+{
+ struct dri2_surface *dri2surf = dri2_surface(nsurf);
+ struct dri2_display *dri2dpy = dri2surf->dri2dpy;
+ unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS];
+ int num_ins, num_outs, att;
+ struct x11_drawable_buffer *xbufs;
+
+ /* prepare the attachments */
+ num_ins = 0;
+ for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
+ if (native_attachment_mask_test(buffer_mask, att)) {
+ unsigned int dri2att;
+
+ switch (att) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ dri2att = DRI2BufferFrontLeft;
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ dri2att = DRI2BufferBackLeft;
+ break;
+ case NATIVE_ATTACHMENT_FRONT_RIGHT:
+ dri2att = DRI2BufferFrontRight;
+ break;
+ case NATIVE_ATTACHMENT_BACK_RIGHT:
+ dri2att = DRI2BufferBackRight;
+ break;
+ default:
+ assert(0);
+ dri2att = 0;
+ break;
+ }
+
+ dri2atts[num_ins] = dri2att;
+ num_ins++;
+ }
+ }
+
+ xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable,
+ &dri2surf->width, &dri2surf->height,
+ dri2atts, FALSE, num_ins, &num_outs);
+
+ /* we should be able to do better... */
+ if (xbufs && dri2surf->last_num_xbufs == num_outs &&
+ memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) {
+ free(xbufs);
+ return;
+ }
+
+ dri2_surface_process_drawable_buffers(&dri2surf->base, xbufs, num_outs);
+
+ dri2surf->sequence_number++;
+
if (dri2surf->last_xbufs)
free(dri2surf->last_xbufs);
dri2surf->last_xbufs = xbufs;
dri2surf->last_num_xbufs = num_outs;
-
- dri2surf->valid_mask = valid_mask;
}
/**