xref: /aosp_15_r20/external/mesa3d/src/gallium/targets/libgl-xlib/xlib.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2007 VMware, Inc., Bismarck, ND., USA
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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20  * USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  *
26  *
27  **************************************************************************/
28 
29 /*
30  * Authors:
31  *   Keith Whitwell
32  */
33 #include "util/compiler.h"
34 #include "util/u_debug.h"
35 #include "sw/xlib/xlib_sw_winsys.h"
36 
37 #include "target-helpers/inline_sw_helper.h"
38 #include "target-helpers/inline_debug_helper.h"
39 
40 
41 
42 /* Helper function to build a subset of a driver stack consisting of
43  * one of the software rasterizers (llvmpipe, softpipe) and the
44  * xlib winsys.
45  */
46 struct pipe_screen *
47 xlib_create_screen( Display *display );
48 
49 struct pipe_screen *
xlib_create_screen(Display * display)50 xlib_create_screen( Display *display )
51 {
52    struct sw_winsys *winsys;
53    struct pipe_screen *screen = NULL;
54 
55    /* Create the underlying winsys, which performs presents to Xlib
56     * drawables:
57     */
58    winsys = xlib_create_sw_winsys( display );
59    if (winsys == NULL)
60       return NULL;
61 
62    /* Create a software rasterizer on top of that winsys:
63     */
64    screen = sw_screen_create( winsys );
65    if (screen == NULL)
66       goto fail;
67 
68    /* Inject any wrapping layers we want to here:
69     */
70    return debug_screen_wrap( screen );
71 
72 fail:
73    if (winsys)
74       winsys->destroy( winsys );
75 
76    return NULL;
77 }
78 
79