st/dri: Make st_framebuffer_iface the base for dri_drawable
authorJakob Bornecrantz <wallbraker@gmail.com>
Sat, 24 Apr 2010 13:05:59 +0000 (14:05 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sun, 25 Apr 2010 23:40:17 +0000 (00:40 +0100)
src/gallium/state_trackers/dri/common/dri_context.c
src/gallium/state_trackers/dri/common/dri_drawable.c
src/gallium/state_trackers/dri/common/dri_drawable.h
src/gallium/state_trackers/dri/common/dri_st_api.c
src/gallium/state_trackers/dri/common/dri_st_api.h
src/gallium/state_trackers/dri/drm/dri1.c
src/gallium/state_trackers/dri/drm/dri2.c
src/gallium/state_trackers/dri/sw/drisw.c

index 97e3b0628f184dcfdbecc0c748de7a7d5cb9628a..ba9fe62125dff3669ba5fb2be331863a5bf879c1 100644 (file)
@@ -165,7 +165,7 @@ dri_make_current(__DRIcontext * cPriv,
          read->texture_stamp = driReadPriv->lastStamp - 1;
       }
 
-      stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb);
+      stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
    }
    else {
       stapi->make_current(stapi, NULL, NULL, NULL);
index 6b551ea3f960157bb1dcb73b9e95915ee5943f13..a61e7e1b1b46032dce6ac95215df86b1503e905b 100644 (file)
@@ -58,9 +58,7 @@ dri_create_buffer(__DRIscreen * sPriv,
       goto fail;
 
    dri_fill_st_visual(&drawable->stvis, screen, visual);
-   drawable->stfb = dri_create_st_framebuffer(drawable);
-   if (drawable->stfb == NULL)
-      goto fail;
+   dri_init_st_framebuffer(drawable);
 
    drawable->sPriv = sPriv;
    drawable->dPriv = dPriv;
@@ -83,7 +81,7 @@ dri_destroy_buffer(__DRIdrawable * dPriv)
 
    dri1_destroy_pipe_surface(drawable);
 
-   dri_destroy_st_framebuffer(drawable->stfb);
+   dri_close_st_framebuffer(drawable);
 
    drawable->desired_fences = 0;
 
index dad218bde290fc5996361b1329d3fe3fd7e22653..6c54a6953b339c47572a6a0bfbe04bf3d9923b05 100644 (file)
@@ -42,14 +42,13 @@ struct dri_context;
 
 struct dri_drawable
 {
+   struct st_framebuffer_iface base;
+   struct st_visual stvis;
+
    /* dri */
    __DRIdrawable *dPriv;
    __DRIscreen *sPriv;
 
-   /* gallium */
-   struct st_framebuffer_iface *stfb;
-   struct st_visual stvis;
-
    __DRIbuffer old[8];
    unsigned old_num;
    unsigned old_w;
index 6c8a7e82abe96b4f47222c91f38b7e726b36bdd2..42e0ba020ad70a032fb7b6f881915734a48b8452 100644 (file)
@@ -106,38 +106,27 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
 }
 
 /**
- * Create a framebuffer from the given drawable.
+ * Init a framebuffer from the given drawable.
  */
-struct st_framebuffer_iface *
-dri_create_st_framebuffer(struct dri_drawable *drawable)
+void
+dri_init_st_framebuffer(struct dri_drawable *drawable)
 {
-   struct st_framebuffer_iface *stfbi;
-
-   stfbi = CALLOC_STRUCT(st_framebuffer_iface);
-   if (stfbi) {
-      stfbi->visual = &drawable->stvis;
-      stfbi->flush_front = dri_st_framebuffer_flush_front;
-      stfbi->validate = dri_st_framebuffer_validate;
-      stfbi->st_manager_private = (void *) drawable;
-   }
-
-   return stfbi;
+   drawable->base.visual = &drawable->stvis;
+   drawable->base.flush_front = dri_st_framebuffer_flush_front;
+   drawable->base.validate = dri_st_framebuffer_validate;
+   drawable->base.st_manager_private = (void *) drawable;
 }
 
 /**
  * Destroy a framebuffer.
  */
 void
-dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
+dri_close_st_framebuffer(struct dri_drawable *drawable)
 {
-   struct dri_drawable *drawable =
-      (struct dri_drawable *) stfbi->st_manager_private;
    int i;
 
    for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
       pipe_resource_reference(&drawable->textures[i], NULL);
-
-   FREE(stfbi);
 }
 
 /**
@@ -145,11 +134,9 @@ dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
  * exist.
  */
 void
-dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
+dri_st_framebuffer_validate_att(struct dri_drawable *drawable,
                                 enum st_attachment_type statt)
 {
-   struct dri_drawable *drawable =
-      (struct dri_drawable *) stfbi->st_manager_private;
    enum st_attachment_type statts[ST_ATTACHMENT_COUNT];
    unsigned i, count = 0;
 
@@ -167,7 +154,8 @@ dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
 
    drawable->texture_stamp = drawable->dPriv->lastStamp - 1;
 
-   stfbi->validate(stfbi, statts, count, NULL);
+   /* this calles into the manager */
+   drawable->base.validate(&drawable->base, statts, count, NULL);
 }
 
 static boolean
index 0a0d43073cb1fda9ed8f4ee0b4f08db2ea278024..8cb9fabd4e4ab64d8f7b5b6a0139ce5727b8a508 100644 (file)
@@ -49,14 +49,14 @@ dri_init_st_manager(struct dri_screen *screen);
 void
 dri_close_st_manager(struct dri_screen *screen);
 
-struct st_framebuffer_iface *
-dri_create_st_framebuffer(struct dri_drawable *drawable);
+void
+dri_init_st_framebuffer(struct dri_drawable *drawable);
 
 void
-dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi);
+dri_close_st_framebuffer(struct dri_drawable *drawable);
 
 void
-dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
+dri_st_framebuffer_validate_att(struct dri_drawable *drawable,
                                 enum st_attachment_type statt);
 
 #endif /* _DRI_ST_API_H_ */
index 3f6f930edef82a6e5740f75697a34b3bf37d0210..313195b096757a2768be8223bf4163b48edff029 100644 (file)
@@ -104,13 +104,13 @@ dri1_propagate_drawable_change(struct dri_context *ctx)
    if (dPriv && draw->texture_stamp != dPriv->lastStamp) {
       ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
       flushed = TRUE;
-      ctx->st->notify_invalid_framebuffer(ctx->st, draw->stfb);
+      ctx->st->notify_invalid_framebuffer(ctx->st, &draw->base);
    }
 
    if (rPriv && dPriv != rPriv && read->texture_stamp != rPriv->lastStamp) {
       if (!flushed)
         ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-      ctx->st->notify_invalid_framebuffer(ctx->st, read->stfb);
+      ctx->st->notify_invalid_framebuffer(ctx->st, &read->base);
    }
 }
 
index fa296a874a2a1dd3f81eb13c8f1bb38e1383c1e3..f2d6fc1e5a8de464547b250ad246e0cdfa628b57 100644 (file)
@@ -61,7 +61,7 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
    drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
 
    if (ctx)
-      ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb);
+      ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
 }
 
 static const __DRI2flushExtension dri2FlushExtension = {
@@ -81,7 +81,7 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
    struct dri_drawable *drawable = dri_drawable(dPriv);
    struct pipe_resource *pt;
 
-   dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT);
+   dri_st_framebuffer_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT);
 
    pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
 
index 9bd838e6227484423883afb1e84bdf60ca0cc9aa..c3f88c936ef06bae76a1a0d109c3968196c5058d 100644 (file)
@@ -112,7 +112,7 @@ drisw_invalidate_drawable(__DRIdrawable *dPriv)
 
    /* check if swapping currently bound buffer */
    if (ctx && ctx->dPriv == dPriv)
-      ctx->st->notify_invalid_framebuffer(ctx->st, drawable->stfb);
+      ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
 }
 
 static INLINE void