Merge branch 'pipe-video' of git://anongit.freedesktop.org/~deathsimple/xvmc-r600...
[mesa.git] / src / gallium / include / pipe / p_video_context.h
1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef PIPE_VIDEO_CONTEXT_H
29 #define PIPE_VIDEO_CONTEXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <pipe/p_video_state.h>
36
37 /* XXX: Move to an appropriate place */
38 #define PIPE_CAP_DECODE_TARGET_PREFERRED_FORMAT 256
39
40 struct pipe_screen;
41 struct pipe_buffer;
42 struct pipe_surface;
43 struct pipe_macroblock;
44 struct pipe_picture_desc;
45 struct pipe_fence_handle;
46
47 /**
48 * Gallium video rendering context
49 */
50 struct pipe_video_context
51 {
52 struct pipe_screen *screen;
53 enum pipe_video_profile profile;
54 enum pipe_video_chroma_format chroma_format;
55 unsigned width;
56 unsigned height;
57
58 void *priv; /**< context private data (for DRI for example) */
59
60 /**
61 * Query an integer-valued capability/parameter/limit
62 * \param param one of PIPE_CAP_x
63 */
64 int (*get_param)(struct pipe_video_context *vpipe, int param);
65
66 /**
67 * Check if the given pipe_format is supported as a texture or
68 * drawing surface.
69 */
70 boolean (*is_format_supported)(struct pipe_video_context *vpipe,
71 enum pipe_format format,
72 unsigned usage,
73 unsigned geom);
74
75 void (*destroy)(struct pipe_video_context *vpipe);
76
77 /**
78 * Picture decoding and displaying
79 */
80 /*@{*/
81 void (*decode_bitstream)(struct pipe_video_context *vpipe,
82 unsigned num_bufs,
83 struct pipe_buffer **bitstream_buf);
84
85 void (*decode_macroblocks)(struct pipe_video_context *vpipe,
86 struct pipe_surface *past,
87 struct pipe_surface *future,
88 unsigned num_macroblocks,
89 struct pipe_macroblock *macroblocks,
90 struct pipe_fence_handle **fence);
91
92 void (*render_picture)(struct pipe_video_context *vpipe,
93 struct pipe_surface *src_surface,
94 enum pipe_mpeg12_picture_type picture_type,
95 /*unsigned num_past_surfaces,
96 struct pipe_surface *past_surfaces,
97 unsigned num_future_surfaces,
98 struct pipe_surface *future_surfaces,*/
99 struct pipe_video_rect *src_area,
100 struct pipe_surface *dst_surface,
101 struct pipe_video_rect *dst_area,
102 struct pipe_fence_handle **fence);
103
104 void (*clear_render_target)(struct pipe_video_context *vpipe,
105 struct pipe_surface *dst,
106 unsigned dstx, unsigned dsty,
107 const float *rgba,
108 unsigned width, unsigned height);
109
110 void (*resource_copy_region)(struct pipe_video_context *vpipe,
111 struct pipe_resource *dst,
112 struct pipe_subresource subdst,
113 unsigned dstx, unsigned dsty, unsigned dstz,
114 struct pipe_resource *src,
115 struct pipe_subresource subsrc,
116 unsigned srcx, unsigned srcy, unsigned srcz,
117 unsigned width, unsigned height);
118
119 struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
120 struct pipe_resource *resource,
121 struct pipe_subresource subresource,
122 unsigned usage, /* a combination of PIPE_TRANSFER_x */
123 const struct pipe_box *box);
124
125 void (*transfer_destroy)(struct pipe_video_context *vpipe,
126 struct pipe_transfer *transfer);
127
128 void* (*transfer_map)(struct pipe_video_context *vpipe,
129 struct pipe_transfer *transfer);
130
131 void (*transfer_flush_region)(struct pipe_video_context *vpipe,
132 struct pipe_transfer *transfer,
133 const struct pipe_box *box);
134
135 void (*transfer_unmap)(struct pipe_video_context *vpipe,
136 struct pipe_transfer *transfer);
137
138 void (*transfer_inline_write)(struct pipe_video_context *vpipe,
139 struct pipe_resource *resource,
140 struct pipe_subresource subresource,
141 unsigned usage, /* a combination of PIPE_TRANSFER_x */
142 const struct pipe_box *box,
143 const void *data,
144 unsigned stride,
145 unsigned slice_stride);
146
147 /*@}*/
148
149 /**
150 * Parameter-like states (or properties)
151 */
152 /*@{*/
153 void (*set_picture_background)(struct pipe_video_context *vpipe,
154 struct pipe_surface *bg,
155 struct pipe_video_rect *bg_src_rect);
156
157 void (*set_picture_layers)(struct pipe_video_context *vpipe,
158 struct pipe_surface *layers[],
159 struct pipe_video_rect *src_rects[],
160 struct pipe_video_rect *dst_rects[],
161 unsigned num_layers);
162
163 void (*set_picture_desc)(struct pipe_video_context *vpipe,
164 const struct pipe_picture_desc *desc);
165
166 void (*set_decode_target)(struct pipe_video_context *vpipe,
167 struct pipe_surface *dt);
168
169 void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
170
171 /* TODO: Interface for scaling modes, post-processing, etc. */
172 /*@}*/
173 };
174
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif /* PIPE_VIDEO_CONTEXT_H */