vl: Add transfer funcs to pipe_video_context and softpipe.
authorYounes Manton <younes.m@gmail.com>
Sun, 13 Jun 2010 21:36:34 +0000 (17:36 -0400)
committerYounes Manton <younes.m@gmail.com>
Sun, 13 Jun 2010 21:36:34 +0000 (17:36 -0400)
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/include/pipe/p_video_context.h

index 9d3a1ab5f5b075510bb555aef80a786f279a857c..44df00e0b78c4d3f32e33a772cff8a5588f607e3 100644 (file)
@@ -161,6 +161,94 @@ sp_mpeg12_surface_copy(struct pipe_video_context *vpipe,
       util_surface_copy(ctx->pipe, FALSE, dst, dstx, dsty, src, srcx, srcy, width, height);
 }
 
+static struct pipe_transfer*
+sp_mpeg12_get_transfer(struct pipe_video_context *vpipe,
+                       struct pipe_resource *resource,
+                       struct pipe_subresource subresource,
+                       unsigned usage,  /* a combination of PIPE_TRANSFER_x */
+                       const struct pipe_box *box)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(resource);
+   assert(box);
+
+   return ctx->pipe->get_transfer(ctx->pipe, resource, subresource, usage, box);
+}
+
+static void
+sp_mpeg12_transfer_destroy(struct pipe_video_context *vpipe,
+                           struct pipe_transfer *transfer)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(transfer);
+
+   ctx->pipe->transfer_destroy(ctx->pipe, transfer);
+}
+
+static void*
+sp_mpeg12_transfer_map(struct pipe_video_context *vpipe,
+                       struct pipe_transfer *transfer)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(transfer);
+
+   return ctx->pipe->transfer_map(ctx->pipe, transfer);
+}
+
+static void
+sp_mpeg12_transfer_flush_region(struct pipe_video_context *vpipe,
+                                struct pipe_transfer *transfer,
+                                const struct pipe_box *box)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(transfer);
+   assert(box);
+
+   ctx->pipe->transfer_flush_region(ctx->pipe, transfer, box);
+}
+
+static void
+sp_mpeg12_transfer_unmap(struct pipe_video_context *vpipe,
+                         struct pipe_transfer *transfer)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(transfer);
+
+   ctx->pipe->transfer_unmap(ctx->pipe, transfer);
+}
+
+static void
+sp_mpeg12_transfer_inline_write(struct pipe_video_context *vpipe,
+                                struct pipe_resource *resource,
+                                struct pipe_subresource subresource,
+                                unsigned usage, /* a combination of PIPE_TRANSFER_x */
+                                const struct pipe_box *box,
+                                const void *data,
+                                unsigned stride,
+                                unsigned slice_stride)
+{
+   struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
+
+   assert(vpipe);
+   assert(resource);
+   assert(box);
+   assert(data);
+   assert(ctx->pipe->transfer_inline_write);
+
+   ctx->pipe->transfer_inline_write(ctx->pipe, resource, subresource, usage,
+                                    box, data, stride, slice_stride);
+}
+
 static void
 sp_mpeg12_render_picture(struct pipe_video_context     *vpipe,
                          struct pipe_surface           *src_surface,
@@ -346,6 +434,13 @@ sp_mpeg12_create(struct pipe_context *pipe, enum pipe_video_profile profile,
    ctx->base.render_picture = sp_mpeg12_render_picture;
    ctx->base.surface_fill = sp_mpeg12_surface_fill;
    ctx->base.surface_copy = sp_mpeg12_surface_copy;
+   ctx->base.get_transfer = sp_mpeg12_get_transfer;
+   ctx->base.transfer_destroy = sp_mpeg12_transfer_destroy;
+   ctx->base.transfer_map = sp_mpeg12_transfer_map;
+   ctx->base.transfer_flush_region = sp_mpeg12_transfer_flush_region;
+   ctx->base.transfer_unmap = sp_mpeg12_transfer_unmap;
+   if (pipe->transfer_inline_write)
+      ctx->base.transfer_inline_write = sp_mpeg12_transfer_inline_write;
    ctx->base.set_picture_background = sp_mpeg12_set_picture_background;
    ctx->base.set_picture_layers = sp_mpeg12_set_picture_layers;
    ctx->base.set_decode_target = sp_mpeg12_set_decode_target;
index d90b667de6c5e01bf10bb616ca4cc51aadfc5b54..294dc464c36a3f8b9c341d3981d8fa3d5641caa0 100644 (file)
@@ -114,6 +114,34 @@ struct pipe_video_context
                         unsigned srcx, unsigned srcy,
                         unsigned width, unsigned height);
 
+   struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
+                                         struct pipe_resource *resource,
+                                         struct pipe_subresource subresource,
+                                         unsigned usage,  /* a combination of PIPE_TRANSFER_x */
+                                         const struct pipe_box *box);
+
+   void (*transfer_destroy)(struct pipe_video_context *vpipe,
+                            struct pipe_transfer *transfer);
+
+   void* (*transfer_map)(struct pipe_video_context *vpipe,
+                         struct pipe_transfer *transfer);
+
+   void (*transfer_flush_region)(struct pipe_video_context *vpipe,
+                                 struct pipe_transfer *transfer,
+                                 const struct pipe_box *box);
+
+   void (*transfer_unmap)(struct pipe_video_context *vpipe,
+                          struct pipe_transfer *transfer);
+
+   void (*transfer_inline_write)(struct pipe_video_context *vpipe,
+                                 struct pipe_resource *resource,
+                                 struct pipe_subresource subresource,
+                                 unsigned usage, /* a combination of PIPE_TRANSFER_x */
+                                 const struct pipe_box *box,
+                                 const void *data,
+                                 unsigned stride,
+                                 unsigned slice_stride);
+
    /*@}*/
 
    /**