VirtualBox

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

Last change on this file since 99743 was 52145, checked in by vboxsync, 10 years ago

Additions/x11/x11include: add header files for X.Org Server 1.16.

  • Property svn:eol-style set to native
File size: 20.0 KB
Line 
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
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_INVERTED_Y_AXIS:
83 * set 1 means the GL env's origin (0,0) is at top-left.
84 * EGL/DRM platform is an example need to set this bit.
85 * glx platform's origin is at bottom-left thus need to
86 * clear this bit.
87 *
88 * @GLAMOR_USE_SCREEN:
89 * If running in an pre-existing X environment, and the
90 * gl context is GLX, then you should set this bit and
91 * let the glamor to handle all the screen related
92 * functions such as GC ops and CreatePixmap/DestroyPixmap.
93 *
94 * @GLAMOR_USE_PICTURE_SCREEN:
95 * If don't use any other underlying DDX driver to handle
96 * the picture related rendering functions, please set this
97 * bit on. Otherwise, clear this bit. And then it is the DDX
98 * driver's responsibility to determine how/when to jump to
99 * glamor's picture compositing path.
100 *
101 * @GLAMOR_USE_EGL_SCREEN:
102 * If you are using EGL layer, then please set this bit
103 * on, otherwise, clear it.
104 *
105 * This function initializes necessary internal data structure
106 * for glamor. And before calling into this function, the OpenGL
107 * environment should be ready. Should be called before any real
108 * glamor rendering or texture allocation functions. And should
109 * be called after the DDX's screen initialization or at the last
110 * step of the DDX's screen initialization.
111 */
112extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
113extern _X_EXPORT void glamor_fini(ScreenPtr screen);
114
115/* This function is used to free the glamor private screen's
116 * resources. If the DDX driver is not set GLAMOR_USE_SCREEN,
117 * then, DDX need to call this function at proper stage, if
118 * it is the xorg DDX driver,then it should be called at free
119 * screen stage not the close screen stage. The reason is after
120 * call to this function, the xorg DDX may need to destroy the
121 * screen pixmap which must be a glamor pixmap and requires
122 * the internal data structure still exist at that time.
123 * Otherwise, the glamor internal structure will not be freed.*/
124extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
125
126/* Let glamor to know the screen's fbo. The low level
127 * driver should already assign a tex
128 * to this pixmap through the set_pixmap_texture. */
129extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
130 PixmapPtr *back_pixmap);
131
132extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap);
133
134extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
135
136extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
137 unsigned int tex);
138
139extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
140 glamor_pixmap_type_t type);
141extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
142extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
143
144extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
145 int depth, unsigned int usage);
146extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
147
148#define GLAMOR_CREATE_PIXMAP_CPU 0x100
149#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
150#define GLAMOR_CREATE_FBO_NO_FBO 0x103
151#define GLAMOR_CREATE_PIXMAP_MAP 0x104
152#define GLAMOR_CREATE_NO_LARGE 0x105
153#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
154
155/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
156 *
157 * @front: front pixmap.
158 * @back: back pixmap.
159 *
160 * Used by the DRI2 page flip. This function will exchange the KHR images and
161 * fbos of the two pixmaps.
162 * */
163extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
164 PixmapPtr back);
165
166extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
167 PixmapPtr back);
168
169/* The DDX is not supposed to call these three functions */
170extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
171extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
172 screen,
173 int w,
174 int h);
175extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
176 unsigned int, Bool,
177 CARD16 *, CARD32 *);
178
179/* @glamor_supports_pixmap_import_export: Returns whether
180 * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
181 * glamor_pixmap_from_fd() are supported.
182 *
183 * @screen: Current screen pointer.
184 *
185 * To have DRI3 support enabled, glamor and glamor_egl need to be
186 * initialized. glamor also has to be compiled with gbm support.
187 *
188 * The EGL layer needs to have the following extensions working:
189 *
190 * .EGL_KHR_gl_texture_2D_image
191 * .EGL_EXT_image_dma_buf_import
192 * */
193extern _X_EXPORT Bool glamor_supports_pixmap_import_export(ScreenPtr screen);
194
195/* @glamor_fd_from_pixmap: Get a dma-buf fd from a pixmap.
196 *
197 * @screen: Current screen pointer.
198 * @pixmap: The pixmap from which we want the fd.
199 * @stride, @size: Pointers to fill the stride and size of the
200 * buffer associated to the fd.
201 *
202 * the pixmap and the buffer associated by the fd will share the same
203 * content.
204 * Returns the fd on success, -1 on error.
205 * */
206extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen,
207 PixmapPtr pixmap,
208 CARD16 *stride, CARD32 *size);
209
210/**
211 * @glamor_name_from_pixmap: Gets a gem name from a pixmap.
212 *
213 * @pixmap: The pixmap from which we want the gem name.
214 *
215 * the pixmap and the buffer associated by the gem name will share the
216 * same content. This function can be used by the DDX to support DRI2,
217 * and needs the same set of buffer export GL extensions as DRI3
218 * support.
219 *
220 * Returns the name on success, -1 on error.
221 * */
222extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr pixmap,
223 CARD16 *stride, CARD32 *size);
224
225/* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd.
226 *
227 * @screen: Current screen pointer.
228 * @fd: The dma-buf fd to import.
229 * @width: The width of the buffer.
230 * @height: The height of the buffer.
231 * @stride: The stride of the buffer.
232 * @depth: The depth of the buffer.
233 * @bpp: The number of bpp of the buffer.
234 *
235 * Returns a valid pixmap if the import succeeded, else NULL.
236 * */
237extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen,
238 int fd,
239 CARD16 width,
240 CARD16 height,
241 CARD16 stride,
242 CARD8 depth,
243 CARD8 bpp);
244
245#ifdef GLAMOR_FOR_XORG
246
247#define GLAMOR_EGL_MODULE_NAME "glamoregl"
248
249/* @glamor_egl_init: Initialize EGL environment.
250 *
251 * @scrn: Current screen info pointer.
252 * @fd: Current drm fd.
253 *
254 * This function creates and intialize EGL contexts.
255 * Should be called from DDX's preInit function.
256 * Return TRUE if success, otherwise return FALSE.
257 * */
258extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
259
260extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
261
262/* @glamor_egl_create_textured_screen: Create textured screen pixmap.
263 *
264 * @screen: screen pointer to be processed.
265 * @handle: screen pixmap's BO handle.
266 * @stride: screen pixmap's stride in bytes.
267 *
268 * This function is similar with the create_textured_pixmap. As the
269 * screen pixmap is a special, we handle it separately in this function.
270 */
271extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
272 int handle, int stride);
273
274/* @glamor_egl_create_textured_screen_ext:
275 *
276 * extent one parameter to track the pointer of the DDX layer's back pixmap.
277 * We need this pointer during the closing screen stage. As before back to
278 * the DDX's close screen, we have to free all the glamor related resources.
279 */
280extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
281 int handle,
282 int stride,
283 PixmapPtr
284 *back_pixmap);
285
286/*
287 * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
288 * a BO handle.
289 *
290 * @pixmap: The pixmap need to be processed.
291 * @handle: The BO's handle attached to this pixmap at DDX layer.
292 * @stride: Stride in bytes for this pixmap.
293 *
294 * This function try to create a texture from the handle and attach
295 * the texture to the pixmap , thus glamor can render to this pixmap
296 * as well. Return true if successful, otherwise return FALSE.
297 */
298extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
299 int handle, int stride);
300
301/*
302 * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
303 * from a gbm_bo.
304 *
305 * @pixmap: The pixmap need to be processed.
306 * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer.
307 *
308 * This function is similar to glamor_egl_create_textured_pixmap.
309 */
310extern _X_EXPORT Bool
311 glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
312
313#endif
314
315extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
316 struct glamor_context *glamor_ctx);
317extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
318
319extern _X_EXPORT int glamor_create_gc(GCPtr gc);
320
321extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
322 DrawablePtr drawable);
323
324extern Bool _X_EXPORT glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
325extern void _X_EXPORT glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_region);
326
327/* Glamor rendering/drawing functions with XXX_nf.
328 * nf means no fallback within glamor internal if possible. If glamor
329 * fail to accelerate the operation, glamor will return a false, and the
330 * caller need to implement fallback method. Return a true means the
331 * rendering request get done successfully. */
332extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
333 GCPtr gc,
334 int n, DDXPointPtr points,
335 int *widths, int sorted);
336
337extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
338 GCPtr gc,
339 int nrect, xRectangle *prect);
340
341extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
342 GCPtr gc, int depth, int x, int y,
343 int w, int h, int left_pad,
344 int image_format, char *bits);
345
346extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
347 DrawablePtr dst,
348 GCPtr gc,
349 BoxPtr box,
350 int nbox,
351 int dx,
352 int dy,
353 Bool reverse,
354 Bool upsidedown, Pixel bitplane,
355 void *closure);
356
357extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
358 PicturePtr source,
359 PicturePtr mask,
360 PicturePtr dest,
361 INT16 x_source,
362 INT16 y_source,
363 INT16 x_mask,
364 INT16 y_mask,
365 INT16 x_dest, INT16 y_dest,
366 CARD16 width, CARD16 height);
367
368extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
369 PicturePtr src, PicturePtr dst,
370 PictFormatPtr mask_format,
371 INT16 x_src, INT16 y_src,
372 int ntrap, xTrapezoid *traps);
373
374extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
375 PicturePtr src,
376 PicturePtr dst,
377 PictFormatPtr mask_format,
378 INT16 x_src,
379 INT16 y_src, int nlist,
380 GlyphListPtr list, GlyphPtr *glyphs);
381
382extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
383 PicturePtr pSrc,
384 PicturePtr pDst,
385 PictFormatPtr maskFormat,
386 INT16 xSrc, INT16 ySrc,
387 int ntris, xTriangle *tris);
388
389extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
390
391extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
392 char *src, DDXPointPtr points,
393 int *widths, int n, int sorted);
394
395extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
396 DDXPointPtr points, int *widths,
397 int count, char *dst);
398
399extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
400 PicturePtr pDst,
401 xRenderColor *color,
402 int nRect, xRectangle *rects);
403
404extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
405 int w, int h, unsigned int format,
406 unsigned long planeMask, char *d);
407
408extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
409 INT16 x_off,
410 INT16 y_off, int ntrap,
411 xTrap *traps);
412
413extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
414 GCPtr pGC, int srcx, int srcy, int w,
415 int h, int dstx, int dsty,
416 unsigned long bitPlane,
417 RegionPtr *pRegion);
418
419extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
420 GCPtr pGC, int x, int y,
421 unsigned int nglyph,
422 CharInfoPtr *ppci,
423 void *pglyphBase);
424
425extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
426 int x, int y,
427 unsigned int nglyph,
428 CharInfoPtr *ppci,
429 void *pglyphBase);
430
431extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
432 DrawablePtr pDrawable, int w, int h,
433 int x, int y);
434
435extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
436 int mode, int npt, DDXPointPtr ppt);
437
438extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
439 int nseg, xSegment *pSeg);
440
441extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
442 int mode, int n, DDXPointPtr points);
443
444extern _X_EXPORT Bool glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
445 int x, int y, int count, char *chars, int *final_pos);
446
447extern _X_EXPORT Bool glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
448 int x, int y, int count, unsigned short *chars, int *final_pos);
449
450extern _X_EXPORT Bool glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
451 int x, int y, int count, char *chars);
452
453extern _X_EXPORT Bool glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
454 int x, int y, int count, unsigned short *chars);
455
456#define HAS_GLAMOR_TEXT 1
457
458#ifdef GLAMOR_FOR_XORG
459extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
460 int num_texture_ports);
461#endif
462
463#endif /* GLAMOR_H */
Note: See TracBrowser for help on using the repository browser.

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