• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  * Version:  7.8
4  *
5  * Copyright (C) 2009-2010 Chia-I Wu <olv@0xlab.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef _X11_SCREEN_H_
27 #define _X11_SCREEN_H_
28 
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
31 #include <X11/extensions/dri2tokens.h>
32 #include "GL/gl.h" /* for GL types needed by __GLcontextModes */
33 #include "glcore.h"  /* for __GLcontextModes */
34 #include "pipe/p_compiler.h"
35 #include "common/native.h"
36 
37 enum x11_screen_extension {
38    X11_SCREEN_EXTENSION_XSHM,
39    X11_SCREEN_EXTENSION_GLX,
40    X11_SCREEN_EXTENSION_DRI2,
41 };
42 
43 /* the same as DRI2Buffer */
44 struct x11_drawable_buffer {
45    unsigned int attachment;
46    unsigned int name;
47    unsigned int pitch;
48    unsigned int cpp;
49    unsigned int flags;
50 };
51 
52 struct x11_screen;
53 
54 typedef void (*x11_drawable_invalidate_buffers)(struct x11_screen *xscr,
55                                                 Drawable drawable,
56                                                 void *user_data);
57 
58 struct x11_screen *
59 x11_screen_create(Display *dpy, int screen);
60 
61 void
62 x11_screen_destroy(struct x11_screen *xscr);
63 
64 boolean
65 x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext);
66 
67 const XVisualInfo *
68 x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals);
69 
70 uint
71 x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable);
72 
73 #ifdef GLX_DIRECT_RENDERING
74 
75 /* GLX */
76 const __GLcontextModes *
77 x11_screen_get_glx_configs(struct x11_screen *xscr);
78 
79 const __GLcontextModes *
80 x11_screen_get_glx_visuals(struct x11_screen *xscr);
81 
82 __GLcontextModes *
83 x11_context_modes_create(unsigned count);
84 
85 void
86 x11_context_modes_destroy(__GLcontextModes *modes);
87 
88 unsigned
89 x11_context_modes_count(const __GLcontextModes *modes);
90 
91 /* DRI2 */
92 const char *
93 x11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor);
94 
95 int
96 x11_screen_enable_dri2(struct x11_screen *xscr,
97                        x11_drawable_invalidate_buffers invalidate_buffers,
98                        void *user_data);
99 
100 char *
101 x11_screen_get_device_name(struct x11_screen *xscr);
102 
103 int
104 x11_screen_authenticate(struct x11_screen *xscr, uint32_t id);
105 
106 void
107 x11_drawable_enable_dri2(struct x11_screen *xscr,
108                          Drawable drawable, boolean on);
109 
110 void
111 x11_drawable_copy_buffers_region(struct x11_screen *xscr, Drawable drawable,
112                                  int num_rects, const int *rects,
113                                  int src_buf, int dst_buf);
114 
115 /**
116  * Copy between buffers of the DRI2 drawable.
117  */
118 static INLINE void
x11_drawable_copy_buffers(struct x11_screen * xscr,Drawable drawable,int x,int y,int width,int height,int src_buf,int dst_buf)119 x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable,
120                           int x, int y, int width, int height,
121                           int src_buf, int dst_buf)
122 {
123     int rect[4] = { x, y, width, height };
124     x11_drawable_copy_buffers_region(xscr, drawable, 1, rect, src_buf, dst_buf);
125 }
126 
127 struct x11_drawable_buffer *
128 x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
129                          int *width, int *height, unsigned int *attachments,
130                          boolean with_format, int num_ins, int *num_outs);
131 
132 #endif /* GLX_DIRECT_RENDERING */
133 
134 #endif /* _X11_SCREEN_H_ */
135