Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * Copyright © 2013 Keith Packard | |
3 | * | |
4 | * Permission to use, copy, modify, distribute, and sell this software and its | |
5 | * documentation for any purpose is hereby granted without fee, provided that | |
6 | * the above copyright notice appear in all copies and that both that copyright | |
7 | * notice and this permission notice appear in supporting documentation, and | |
8 | * that the name of the copyright holders not be used in advertising or | |
9 | * publicity pertaining to distribution of the software without specific, | |
10 | * written prior permission. The copyright holders make no representations | |
11 | * about the suitability of this software for any purpose. It is provided "as | |
12 | * is" without express or implied warranty. | |
13 | * | |
14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
20 | * OF THIS SOFTWARE. | |
21 | */ | |
22 | ||
23 | #ifdef HAVE_XORG_CONFIG_H | |
24 | #include <xorg-config.h> | |
25 | #endif | |
26 | ||
27 | #include "dri3_priv.h" | |
28 | ||
29 | int dri3_request; | |
30 | DevPrivateKeyRec dri3_screen_private_key; | |
31 | DevPrivateKeyRec dri3_window_private_key; | |
32 | ||
33 | static Bool | |
34 | dri3_close_screen(ScreenPtr screen) | |
35 | { | |
36 | dri3_screen_priv_ptr screen_priv = dri3_screen_priv(screen); | |
37 | ||
38 | unwrap(screen_priv, screen, CloseScreen); | |
39 | ||
40 | free(screen_priv); | |
41 | return (*screen->CloseScreen) (screen); | |
42 | } | |
43 | ||
44 | Bool | |
45 | dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info) | |
46 | { | |
47 | if (!dixRegisterPrivateKey(&dri3_screen_private_key, PRIVATE_SCREEN, 0)) | |
48 | return FALSE; | |
49 | ||
50 | if (!dri3_screen_priv(screen)) { | |
51 | dri3_screen_priv_ptr screen_priv = calloc(1, sizeof (dri3_screen_priv_rec)); | |
52 | if (!screen_priv) | |
53 | return FALSE; | |
54 | ||
55 | wrap(screen_priv, screen, CloseScreen, dri3_close_screen); | |
56 | ||
57 | screen_priv->info = info; | |
58 | ||
59 | dixSetPrivate(&screen->devPrivates, &dri3_screen_private_key, screen_priv); | |
60 | } | |
61 | ||
62 | return TRUE; | |
63 | } | |
64 | ||
65 | void | |
66 | dri3_extension_init(void) | |
67 | { | |
68 | ExtensionEntry *extension; | |
69 | int i; | |
70 | ||
71 | #ifdef PANORAMIX | |
72 | if (!noPanoramiXExtension) | |
73 | return; | |
74 | #endif | |
75 | ||
76 | extension = AddExtension(DRI3_NAME, DRI3NumberEvents, DRI3NumberErrors, | |
77 | proc_dri3_dispatch, sproc_dri3_dispatch, | |
78 | NULL, StandardMinorOpcode); | |
79 | if (!extension) | |
80 | goto bail; | |
81 | ||
82 | dri3_request = extension->base; | |
83 | ||
84 | for (i = 0; i < screenInfo.numScreens; i++) { | |
85 | if (!dri3_screen_init(screenInfo.screens[i], NULL)) | |
86 | goto bail; | |
87 | } | |
88 | return; | |
89 | ||
90 | bail: | |
91 | FatalError("Cannot initialize DRI3 extension"); | |
92 | } |