1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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 VMWARE 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.
25 *
26 **************************************************************************/
27
28 /*
29 * Target makefiles directly refer to vl_winsys_dri.c to avoid DRI dependency
30 */
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #ifndef vl_winsys_h
37 #define vl_winsys_h
38
39 #ifdef HAVE_X11_PLATFORM
40 #include <X11/Xlib.h>
41 #include <xcb/xcb.h>
42 #endif
43 #ifdef _WIN32
44 #include <windows.h>
45 #include <unknwn.h>
46 #endif
47 #include "pipe/p_defines.h"
48 #include "util/format/u_formats.h"
49
50 struct pipe_screen;
51 struct pipe_surface;
52 struct pipe_loader_device;
53
54 struct vl_screen
55 {
56 void (*destroy)(struct vl_screen *vscreen);
57
58 struct pipe_resource *
59 (*texture_from_drawable)(struct vl_screen *vscreen, void *drawable);
60
61 struct u_rect *
62 (*get_dirty_area)(struct vl_screen *vscreen);
63
64 uint64_t
65 (*get_timestamp)(struct vl_screen *vscreen, void *drawable);
66
67 void
68 (*set_next_timestamp)(struct vl_screen *vscreen, uint64_t stamp);
69
70 void *
71 (*get_private)(struct vl_screen *vscreen);
72
73 void
74 (*set_back_texture_from_output)(struct vl_screen *vscreen,
75 struct pipe_resource *buffer,
76 uint32_t width, uint32_t height);
77
78 struct pipe_screen *pscreen;
79 struct pipe_loader_device *dev;
80
81 void *xcb_screen;
82 uint32_t color_depth;
83 };
84
85 #ifdef HAVE_X11_PLATFORM
86 xcb_screen_t *
87 vl_dri_get_screen_for_root(xcb_connection_t *conn, xcb_window_t root);
88 uint32_t
89 vl_dri2_format_for_depth(struct vl_screen *vscreen, int depth);
90
91 struct vl_screen *
92 vl_dri2_screen_create(Display *display, int screen);
93 #else
94 static inline struct vl_screen *
vl_dri2_screen_create(void * display,int screen)95 vl_dri2_screen_create(void *display, int screen) { return NULL; };
96 #endif
97
98 #if defined(HAVE_X11_PLATFORM) && defined(HAVE_LIBDRM)
99 struct vl_screen *
100 vl_dri3_screen_create(Display *display, int screen);
101 struct vl_screen *
102 vl_kopper_screen_create(Display *display, int screen);
103 #else
104 static inline struct vl_screen *
vl_dri3_screen_create(void * display,int screen)105 vl_dri3_screen_create(void *display, int screen) { return NULL; };
106 static inline struct vl_screen *
vl_kopper_screen_create(void * display,int screen)107 vl_kopper_screen_create(void *display, int screen) { return NULL; };
108 #endif
109
110 #ifdef _WIN32
111 struct vl_screen *vl_win32_screen_create(LUID *adapter);
112 struct vl_screen *vl_win32_screen_create_from_d3d12_device(IUnknown* d3d12_device, struct sw_winsys* winsys);
113 #else
114 /* Always enable the DRM vl winsys */
115 struct vl_screen *
116 vl_drm_screen_create(int fd, bool honor_dri_prime);
117
118 #ifdef USE_XSHM
119 struct vl_screen *
120 vl_xlib_swrast_screen_create(Display *display, int screen);
121 static inline struct vl_screen *
vl_vgem_drm_screen_create(int fd)122 vl_vgem_drm_screen_create(int fd) { return NULL; }
123 #else
124 struct vl_screen *
125 vl_vgem_drm_screen_create(int fd);
126 static inline struct vl_screen *
vl_xlib_swrast_screen_create(void * display,int screen)127 vl_xlib_swrast_screen_create(void *display, int screen) { return NULL; }
128 #endif
129 #endif
130
131 #endif
132 #ifdef __cplusplus
133 }
134 #endif
135