egl_dri2: Split out drm platform implementation to a separate file
[mesa.git] / src / egl / drivers / dri2 / egl_dri2.h
1 /*
2 * Copyright © 2011 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,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Kristian Høgsberg <krh@bitplanet.net>
26 */
27
28 #ifndef EGL_DRI2_INCLUDED
29 #define EGL_DRI2_INCLUDED
30
31 #include <xcb/xcb.h>
32 #include <xcb/dri2.h>
33 #include <xcb/xfixes.h>
34 #include <X11/Xlib-xcb.h>
35
36 #include <GL/gl.h>
37 #include <GL/internal/dri_interface.h>
38
39 #include "eglconfig.h"
40 #include "eglcontext.h"
41 #include "egldisplay.h"
42 #include "egldriver.h"
43 #include "eglcurrent.h"
44 #include "egllog.h"
45 #include "eglsurface.h"
46 #include "eglimage.h"
47
48 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
49
50 struct dri2_egl_driver
51 {
52 _EGLDriver base;
53
54 void *handle;
55 _EGLProc (*get_proc_address)(const char *procname);
56 void (*glFlush)(void);
57 };
58
59 struct dri2_egl_display
60 {
61 xcb_connection_t *conn;
62 int dri2_major;
63 int dri2_minor;
64 __DRIscreen *dri_screen;
65 const __DRIconfig **driver_configs;
66 void *driver;
67 __DRIcoreExtension *core;
68 __DRIdri2Extension *dri2;
69 __DRI2flushExtension *flush;
70 __DRItexBufferExtension *tex_buffer;
71 __DRIimageExtension *image;
72 int fd;
73
74 char *device_name;
75 char *driver_name;
76
77 __DRIdri2LoaderExtension loader_extension;
78 const __DRIextension *extensions[3];
79 };
80
81 struct dri2_egl_context
82 {
83 _EGLContext base;
84 __DRIcontext *dri_context;
85 };
86
87 struct dri2_egl_surface
88 {
89 _EGLSurface base;
90 __DRIdrawable *dri_drawable;
91 xcb_drawable_t drawable;
92 __DRIbuffer buffers[5];
93 int buffer_count;
94 xcb_xfixes_region_t region;
95 int have_fake_front;
96 int swap_interval;
97 };
98
99 struct dri2_egl_config
100 {
101 _EGLConfig base;
102 const __DRIconfig *dri_config;
103 };
104
105 struct dri2_egl_image
106 {
107 _EGLImage base;
108 __DRIimage *dri_image;
109 };
110
111 /* standard typecasts */
112 _EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl)
113 _EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj)
114
115 extern const __DRIimageLookupExtension image_lookup_extension;
116 extern const __DRIuseInvalidateExtension use_invalidate;
117
118 EGLBoolean
119 dri2_load_driver(_EGLDisplay *disp);
120
121 EGLBoolean
122 dri2_create_screen(_EGLDisplay *disp);
123
124 struct dri2_egl_config *
125 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
126 int depth, EGLint surface_type);
127
128 _EGLImage *
129 dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
130 _EGLContext *ctx, EGLenum target,
131 EGLClientBuffer buffer, const EGLint *attr_list);
132
133 EGLBoolean
134 dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp);
135
136 EGLBoolean
137 dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp);
138
139 #endif /* EGL_DRI2_INCLUDED */