VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.17.1/glamor.h

最後變更 在這個檔案是 54163,由 vboxsync 提交於 10 年 前

Additions/x11/vboxvideo: support X.Org Server 1.17 (still untested).

  • 屬性 svn:eol-style 設為 native
檔案大小: 20.5 KB
 
1/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <[email protected]>
25 * Zhigang Gong <[email protected]>
26 *
27 */
28
29#ifndef GLAMOR_H
30#define GLAMOR_H
31
32#include <scrnintstr.h>
33#include <pixmapstr.h>
34#include <gcstruct.h>
35#include <picturestr.h>
36#include <fb.h>
37#include <fbpict.h>
38#ifdef GLAMOR_FOR_XORG
39#include <xf86xv.h>
40#endif
41
42struct glamor_context;
43
44/*
45 * glamor_pixmap_type : glamor pixmap's type.
46 * @MEMORY: pixmap is in memory.
47 * @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer.
48 * @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but
49 * the format is incompatible, so this type of pixmap
50 * will never fallback to DDX layer.
51 * @DRM_ONLY: pixmap is in a external DRM buffer.
52 * @TEXTURE_ONLY: pixmap is in an internal texture.
53 */
54typedef enum glamor_pixmap_type {
55 GLAMOR_MEMORY,
56 GLAMOR_MEMORY_MAP,
57 GLAMOR_TEXTURE_DRM,
58 GLAMOR_SEPARATE_TEXTURE,
59 GLAMOR_DRM_ONLY,
60 GLAMOR_TEXTURE_ONLY,
61 GLAMOR_TEXTURE_LARGE,
62 GLAMOR_TEXTURE_PACK
63} glamor_pixmap_type_t;
64
65#define GLAMOR_EGL_EXTERNAL_BUFFER 3
66#define GLAMOR_INVERTED_Y_AXIS 1 /* compat stub */
67#define GLAMOR_USE_SCREEN (1 << 1)
68#define GLAMOR_USE_PICTURE_SCREEN (1 << 2)
69#define GLAMOR_USE_EGL_SCREEN (1 << 3)
70#define GLAMOR_NO_DRI3 (1 << 4)
71#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS \
72 | GLAMOR_USE_SCREEN \
73 | GLAMOR_USE_PICTURE_SCREEN \
74 | GLAMOR_USE_EGL_SCREEN \
75 | GLAMOR_NO_DRI3)
76
77/* @glamor_init: Initialize glamor internal data structure.
78 *
79 * @screen: Current screen pointer.
80 * @flags: Please refer the flags description above.
81 *
82 * @GLAMOR_USE_SCREEN:
83 * If running in an pre-existing X environment, and the
84 * gl context is GLX, then you should set this bit and
85 * let the glamor to handle all the screen related
86 * functions such as GC ops and CreatePixmap/DestroyPixmap.
87 *
88 * @GLAMOR_USE_PICTURE_SCREEN:
89 * If don't use any other underlying DDX driver to handle
90 * the picture related rendering functions, please set this
91 * bit on. Otherwise, clear this bit. And then it is the DDX
92 * driver's responsibility to determine how/when to jump to
93 * glamor's picture compositing path.
94 *
95 * @GLAMOR_USE_EGL_SCREEN:
96 * If you are using EGL layer, then please set this bit
97 * on, otherwise, clear it.
98 *
99 * This function initializes necessary internal data structure
100 * for glamor. And before calling into this function, the OpenGL
101 * environment should be ready. Should be called before any real
102 * glamor rendering or texture allocation functions. And should
103 * be called after the DDX's screen initialization or at the last
104 * step of the DDX's screen initialization.
105 */
106extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
107extern _X_EXPORT void glamor_fini(ScreenPtr screen);
108
109/* This function is used to free the glamor private screen's
110 * resources. If the DDX driver is not set GLAMOR_USE_SCREEN,
111 * then, DDX need to call this function at proper stage, if
112 * it is the xorg DDX driver,then it should be called at free
113 * screen stage not the close screen stage. The reason is after
114 * call to this function, the xorg DDX may need to destroy the
115 * screen pixmap which must be a glamor pixmap and requires
116 * the internal data structure still exist at that time.
117 * Otherwise, the glamor internal structure will not be freed.*/
118extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
119
120/* Let glamor to know the screen's fbo. The low level
121 * driver should already assign a tex
122 * to this pixmap through the set_pixmap_texture. */
123extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
124 PixmapPtr *back_pixmap);
125
126extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap);
127
128extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
129
130extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
131 unsigned int tex);
132
133extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
134 glamor_pixmap_type_t type);
135extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
136extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
137
138extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
139 int depth, unsigned int usage);
140extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
141
142#define GLAMOR_CREATE_PIXMAP_CPU 0x100
143#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
144#define GLAMOR_CREATE_FBO_NO_FBO 0x103
145#define GLAMOR_CREATE_PIXMAP_MAP 0x104
146#define GLAMOR_CREATE_NO_LARGE 0x105
147#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
148
149/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
150 *
151 * @front: front pixmap.
152 * @back: back pixmap.
153 *
154 * Used by the DRI2 page flip. This function will exchange the KHR images and
155 * fbos of the two pixmaps.
156 * */
157extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
158 PixmapPtr back);
159
160extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
161 PixmapPtr back);
162
163/* The DDX is not supposed to call these three functions */
164extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
165extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
166 screen,
167 int w,
168 int h);
169extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
170 unsigned int, Bool,
171 CARD16 *, CARD32 *);
172
173extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
174
175extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
176
177/* @glamor_supports_pixmap_import_export: Returns whether
178 * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
179 * glamor_pixmap_from_fd() are supported.
180 *
181 * @screen: Current screen pointer.
182 *
183 * To have DRI3 support enabled, glamor and glamor_egl need to be
184 * initialized. glamor also has to be compiled with gbm support.
185 *
186 * The EGL layer needs to have the following extensions working:
187 *
188 * .EGL_KHR_gl_texture_2D_image
189 * .EGL_EXT_image_dma_buf_import
190 * */
191extern _X_EXPORT Bool glamor_supports_pixmap_import_export(ScreenPtr screen);
192
193/* @glamor_fd_from_pixmap: Get a dma-buf fd from a pixmap.
194 *
195 * @screen: Current screen pointer.
196 * @pixmap: The pixmap from which we want the fd.
197 * @stride, @size: Pointers to fill the stride and size of the
198 * buffer associated to the fd.
199 *
200 * the pixmap and the buffer associated by the fd will share the same
201 * content.
202 * Returns the fd on success, -1 on error.
203 * */
204extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen,
205 PixmapPtr pixmap,
206 CARD16 *stride, CARD32 *size);
207
208/**
209 * @glamor_name_from_pixmap: Gets a gem name from a pixmap.
210 *
211 * @pixmap: The pixmap from which we want the gem name.
212 *
213 * the pixmap and the buffer associated by the gem name will share the
214 * same content. This function can be used by the DDX to support DRI2,
215 * and needs the same set of buffer export GL extensions as DRI3
216 * support.
217 *
218 * Returns the name on success, -1 on error.
219 * */
220extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr pixmap,
221 CARD16 *stride, CARD32 *size);
222
223/* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd.
224 *
225 * @screen: Current screen pointer.
226 * @fd: The dma-buf fd to import.
227 * @width: The width of the buffer.
228 * @height: The height of the buffer.
229 * @stride: The stride of the buffer.
230 * @depth: The depth of the buffer.
231 * @bpp: The number of bpp of the buffer.
232 *
233 * Returns a valid pixmap if the import succeeded, else NULL.
234 * */
235extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen,
236 int fd,
237 CARD16 width,
238 CARD16 height,
239 CARD16 stride,
240 CARD8 depth,
241 CARD8 bpp);
242
243#ifdef GLAMOR_FOR_XORG
244
245#define GLAMOR_EGL_MODULE_NAME "glamoregl"
246
247/* @glamor_egl_init: Initialize EGL environment.
248 *
249 * @scrn: Current screen info pointer.
250 * @fd: Current drm fd.
251 *
252 * This function creates and intialize EGL contexts.
253 * Should be called from DDX's preInit function.
254 * Return TRUE if success, otherwise return FALSE.
255 * */
256extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
257
258extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
259
260/* @glamor_egl_create_textured_screen: Create textured screen pixmap.
261 *
262 * @screen: screen pointer to be processed.
263 * @handle: screen pixmap's BO handle.
264 * @stride: screen pixmap's stride in bytes.
265 *
266 * This function is similar with the create_textured_pixmap. As the
267 * screen pixmap is a special, we handle it separately in this function.
268 */
269extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
270 int handle, int stride);
271
272/* @glamor_egl_create_textured_screen_ext:
273 *
274 * extent one parameter to track the pointer of the DDX layer's back pixmap.
275 * We need this pointer during the closing screen stage. As before back to
276 * the DDX's close screen, we have to free all the glamor related resources.
277 */
278extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
279 int handle,
280 int stride,
281 PixmapPtr
282 *back_pixmap);
283
284/*
285 * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
286 * a BO handle.
287 *
288 * @pixmap: The pixmap need to be processed.
289 * @handle: The BO's handle attached to this pixmap at DDX layer.
290 * @stride: Stride in bytes for this pixmap.
291 *
292 * This function try to create a texture from the handle and attach
293 * the texture to the pixmap , thus glamor can render to this pixmap
294 * as well. Return true if successful, otherwise return FALSE.
295 */
296extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
297 int handle, int stride);
298
299/*
300 * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
301 * from a gbm_bo.
302 *
303 * @pixmap: The pixmap need to be processed.
304 * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer.
305 *
306 * This function is similar to glamor_egl_create_textured_pixmap.
307 */
308extern _X_EXPORT Bool
309 glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
310
311#endif
312
313extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
314 struct glamor_context *glamor_ctx);
315extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
316
317extern _X_EXPORT int glamor_create_gc(GCPtr gc);
318
319extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
320 DrawablePtr drawable);
321
322extern _X_EXPORT void glamor_destroy_gc(GCPtr gc);
323
324#define HAS_GLAMOR_DESTROY_GC 1
325
326extern Bool _X_EXPORT glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
327extern void _X_EXPORT glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_region);
328
329/* Glamor rendering/drawing functions with XXX_nf.
330 * nf means no fallback within glamor internal if possible. If glamor
331 * fail to accelerate the operation, glamor will return a false, and the
332 * caller need to implement fallback method. Return a true means the
333 * rendering request get done successfully. */
334extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
335 GCPtr gc,
336 int n, DDXPointPtr points,
337 int *widths, int sorted);
338
339extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
340 GCPtr gc,
341 int nrect, xRectangle *prect);
342
343extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
344 GCPtr gc, int depth, int x, int y,
345 int w, int h, int left_pad,
346 int image_format, char *bits);
347
348extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
349 DrawablePtr dst,
350 GCPtr gc,
351 BoxPtr box,
352 int nbox,
353 int dx,
354 int dy,
355 Bool reverse,
356 Bool upsidedown, Pixel bitplane,
357 void *closure);
358
359extern _X_EXPORT Bool glamor_copy_nf(DrawablePtr src,
360 DrawablePtr dst,
361 GCPtr gc,
362 BoxPtr box,
363 int nbox,
364 int dx,
365 int dy,
366 Bool reverse,
367 Bool upsidedown, Pixel bitplane,
368 void *closure);
369
370extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
371 PicturePtr source,
372 PicturePtr mask,
373 PicturePtr dest,
374 INT16 x_source,
375 INT16 y_source,
376 INT16 x_mask,
377 INT16 y_mask,
378 INT16 x_dest, INT16 y_dest,
379 CARD16 width, CARD16 height);
380
381extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
382 PicturePtr src, PicturePtr dst,
383 PictFormatPtr mask_format,
384 INT16 x_src, INT16 y_src,
385 int ntrap, xTrapezoid *traps);
386
387extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
388 PicturePtr src,
389 PicturePtr dst,
390 PictFormatPtr mask_format,
391 INT16 x_src,
392 INT16 y_src, int nlist,
393 GlyphListPtr list, GlyphPtr *glyphs);
394
395extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
396 PicturePtr pSrc,
397 PicturePtr pDst,
398 PictFormatPtr maskFormat,
399 INT16 xSrc, INT16 ySrc,
400 int ntris, xTriangle *tris);
401
402extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
403
404extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
405 char *src, DDXPointPtr points,
406 int *widths, int n, int sorted);
407
408extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
409 DDXPointPtr points, int *widths,
410 int count, char *dst);
411
412extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
413 PicturePtr pDst,
414 xRenderColor *color,
415 int nRect, xRectangle *rects);
416
417extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
418 int w, int h, unsigned int format,
419 unsigned long planeMask, char *d);
420
421extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
422 INT16 x_off,
423 INT16 y_off, int ntrap,
424 xTrap *traps);
425
426extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
427 GCPtr pGC, int srcx, int srcy, int w,
428 int h, int dstx, int dsty,
429 unsigned long bitPlane,
430 RegionPtr *pRegion);
431
432extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
433 GCPtr pGC, int x, int y,
434 unsigned int nglyph,
435 CharInfoPtr *ppci,
436 void *pglyphBase);
437
438extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
439 int x, int y,
440 unsigned int nglyph,
441 CharInfoPtr *ppci,
442 void *pglyphBase);
443
444extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
445 DrawablePtr pDrawable, int w, int h,
446 int x, int y);
447
448extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
449 int mode, int npt, DDXPointPtr ppt);
450
451extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
452 int nseg, xSegment *pSeg);
453
454extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
455 int mode, int n, DDXPointPtr points);
456
457extern _X_EXPORT Bool glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
458 int x, int y, int count, char *chars, int *final_pos);
459
460extern _X_EXPORT Bool glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
461 int x, int y, int count, unsigned short *chars, int *final_pos);
462
463extern _X_EXPORT Bool glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
464 int x, int y, int count, char *chars);
465
466extern _X_EXPORT Bool glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
467 int x, int y, int count, unsigned short *chars);
468
469#define HAS_GLAMOR_TEXT 1
470
471#ifdef GLAMOR_FOR_XORG
472extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
473 int num_texture_ports);
474#endif
475
476#endif /* GLAMOR_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette