Merge remote branch 'vdpau/pipe-video' into pipe-video
[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 struct pipe_surface *(*create_surface)(struct pipe_video_context *vpipe,
78 struct pipe_resource *resource,
79 const struct pipe_surface *templat);
80
81 /**
82 * Picture decoding and displaying
83 */
84 /*@{*/
85 void (*decode_bitstream)(struct pipe_video_context *vpipe,
86 unsigned num_bufs,
87 struct pipe_buffer **bitstream_buf);
88
89 void (*decode_macroblocks)(struct pipe_video_context *vpipe,
90 struct pipe_surface *past,
91 struct pipe_surface *future,
92 unsigned num_macroblocks,
93 struct pipe_macroblock *macroblocks,
94 struct pipe_fence_handle **fence);
95
96 void (*render_picture)(struct pipe_video_context *vpipe,
97 struct pipe_surface *src_surface,
98 enum pipe_mpeg12_picture_type picture_type,
99 /*unsigned num_past_surfaces,
100 struct pipe_surface *past_surfaces,
101 unsigned num_future_surfaces,
102 struct pipe_surface *future_surfaces,*/
103 struct pipe_video_rect *src_area,
104 struct pipe_surface *dst_surface,
105 struct pipe_video_rect *dst_area,
106 struct pipe_fence_handle **fence);
107
108 void (*clear_render_target)(struct pipe_video_context *vpipe,
109 struct pipe_surface *dst,
110 unsigned dstx, unsigned dsty,
111 const float *rgba,
112 unsigned width, unsigned height);
113
114 void (*resource_copy_region)(struct pipe_video_context *vpipe,
115 struct pipe_resource *dst,
116 struct pipe_subresource subdst,
117 unsigned dstx, unsigned dsty, unsigned dstz,
118 struct pipe_resource *src,
119 struct pipe_subresource subsrc,
120 unsigned srcx, unsigned srcy, unsigned srcz,
121 unsigned width, unsigned height);
122
123 struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
124 struct pipe_resource *resource,
125 unsigned level,
126 unsigned usage, /* a combination of PIPE_TRANSFER_x */
127 const struct pipe_box *box);
128
129 void (*transfer_destroy)(struct pipe_video_context *vpipe,
130 struct pipe_transfer *transfer);
131
132 void* (*transfer_map)(struct pipe_video_context *vpipe,
133 struct pipe_transfer *transfer);
134
135 void (*transfer_flush_region)(struct pipe_video_context *vpipe,
136 struct pipe_transfer *transfer,
137 const struct pipe_box *box);
138
139 void (*transfer_unmap)(struct pipe_video_context *vpipe,
140 struct pipe_transfer *transfer);
141
142 void (*transfer_inline_write)(struct pipe_video_context *vpipe,
143 struct pipe_resource *resource,
144 unsigned level,
145 unsigned usage, /* a combination of PIPE_TRANSFER_x */
146 const struct pipe_box *box,
147 const void *data,
148 unsigned stride,
149 unsigned slice_stride);
150
151 /*@}*/
152
153 /**
154 * Parameter-like states (or properties)
155 */
156 /*@{*/
157 void (*set_picture_background)(struct pipe_video_context *vpipe,
158 struct pipe_surface *bg,
159 struct pipe_video_rect *bg_src_rect);
160
161 void (*set_picture_layers)(struct pipe_video_context *vpipe,
162 struct pipe_surface *layers[],
163 struct pipe_video_rect *src_rects[],
164 struct pipe_video_rect *dst_rects[],
165 unsigned num_layers);
166
167 void (*set_picture_desc)(struct pipe_video_context *vpipe,
168 const struct pipe_picture_desc *desc);
169
170 void (*set_decode_target)(struct pipe_video_context *vpipe,
171 struct pipe_surface *dt);
172
173 void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
174
175 /* TODO: Interface for scaling modes, post-processing, etc. */
176 /*@}*/
177 };
178
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* PIPE_VIDEO_CONTEXT_H */