1 /**************************************************************************
3 * Copyright 2009 Younes Manton.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef PIPE_VIDEO_CONTEXT_H
29 #define PIPE_VIDEO_CONTEXT_H
35 #include <pipe/p_video_state.h>
37 /* XXX: Move to an appropriate place */
38 #define PIPE_CAP_DECODE_TARGET_PREFERRED_FORMAT 256
43 struct pipe_macroblock
;
44 struct pipe_picture_desc
;
45 struct pipe_fence_handle
;
48 * Gallium video rendering context
50 struct pipe_video_context
52 struct pipe_screen
*screen
;
53 enum pipe_video_profile profile
;
54 enum pipe_video_chroma_format chroma_format
;
58 void *priv
; /**< context private data (for DRI for example) */
61 * Query an integer-valued capability/parameter/limit
62 * \param param one of PIPE_CAP_x
64 int (*get_param
)(struct pipe_video_context
*vpipe
, int param
);
67 * Check if the given pipe_format is supported as a texture or
70 boolean (*is_format_supported
)(struct pipe_video_context
*vpipe
,
71 enum pipe_format format
,
75 void (*destroy
)(struct pipe_video_context
*vpipe
);
77 struct pipe_surface
*(*create_surface
)(struct pipe_video_context
*vpipe
,
78 struct pipe_resource
*resource
,
79 const struct pipe_surface
*templat
);
82 * Picture decoding and displaying
85 void (*decode_bitstream
)(struct pipe_video_context
*vpipe
,
87 struct pipe_buffer
**bitstream_buf
);
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
);
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
);
108 void (*clear_render_target
)(struct pipe_video_context
*vpipe
,
109 struct pipe_surface
*dst
,
110 unsigned dstx
, unsigned dsty
,
112 unsigned width
, unsigned height
);
114 void (*resource_copy_region
)(struct pipe_video_context
*vpipe
,
115 struct pipe_resource
*dst
,
116 unsigned dstx
, unsigned dsty
, unsigned dstz
,
117 struct pipe_resource
*src
,
118 unsigned srcx
, unsigned srcy
, unsigned srcz
,
119 unsigned width
, unsigned height
);
121 struct pipe_transfer
*(*get_transfer
)(struct pipe_video_context
*vpipe
,
122 struct pipe_resource
*resource
,
124 unsigned usage
, /* a combination of PIPE_TRANSFER_x */
125 const struct pipe_box
*box
);
127 void (*transfer_destroy
)(struct pipe_video_context
*vpipe
,
128 struct pipe_transfer
*transfer
);
130 void* (*transfer_map
)(struct pipe_video_context
*vpipe
,
131 struct pipe_transfer
*transfer
);
133 void (*transfer_flush_region
)(struct pipe_video_context
*vpipe
,
134 struct pipe_transfer
*transfer
,
135 const struct pipe_box
*box
);
137 void (*transfer_unmap
)(struct pipe_video_context
*vpipe
,
138 struct pipe_transfer
*transfer
);
140 void (*transfer_inline_write
)(struct pipe_video_context
*vpipe
,
141 struct pipe_resource
*resource
,
143 unsigned usage
, /* a combination of PIPE_TRANSFER_x */
144 const struct pipe_box
*box
,
147 unsigned slice_stride
);
152 * Parameter-like states (or properties)
155 void (*set_picture_background
)(struct pipe_video_context
*vpipe
,
156 struct pipe_surface
*bg
,
157 struct pipe_video_rect
*bg_src_rect
);
159 void (*set_picture_layers
)(struct pipe_video_context
*vpipe
,
160 struct pipe_surface
*layers
[],
161 struct pipe_video_rect
*src_rects
[],
162 struct pipe_video_rect
*dst_rects
[],
163 unsigned num_layers
);
165 void (*set_picture_desc
)(struct pipe_video_context
*vpipe
,
166 const struct pipe_picture_desc
*desc
);
168 void (*set_decode_target
)(struct pipe_video_context
*vpipe
,
169 struct pipe_surface
*dt
);
171 void (*set_csc_matrix
)(struct pipe_video_context
*vpipe
, const float *mat
);
173 /* TODO: Interface for scaling modes, post-processing, etc. */
182 #endif /* PIPE_VIDEO_CONTEXT_H */