gallium: Add pipe_transfer_reference().
authorMichel Dänzer <daenzer@vmware.com>
Wed, 18 Feb 2009 17:12:31 +0000 (18:12 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Wed, 18 Feb 2009 17:12:31 +0000 (18:12 +0100)
src/gallium/include/pipe/p_inlines.h

index 76460d2724379d104fa8ff0cefb77f3899988a3d..ffbe2d7612a4037621321c66942d88be14a3c00a 100644 (file)
@@ -65,6 +65,31 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
 }
 
 
+/**
+ * \sa pipe_surface_reference
+ */
+static INLINE void
+pipe_transfer_reference(struct pipe_transfer **ptr, struct pipe_transfer *trans)
+{
+   /* bump the refcount first */
+   if (trans) {
+      assert(trans->refcount);
+      trans->refcount++;
+   }
+
+   if (*ptr) {
+      struct pipe_screen *screen;
+      assert((*ptr)->refcount);
+      assert((*ptr)->texture);
+      screen = (*ptr)->texture->screen;
+      screen->tex_transfer_release( screen, ptr );
+      assert(!*ptr);
+   }
+
+   *ptr = trans;
+}
+
+
 /**
  * \sa pipe_surface_reference
  */