Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / drivers / dri / common / drisw_util.h
1 /*
2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * All Rights Reserved.
4 * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24 /**
25 * @file
26 * Binding of the DRI interface (dri_interface.h) for DRISW.
27 *
28 * The DRISW structs are 'base classes' of the corresponding DRI1 / DRI2 (DRM)
29 * structs. The bindings for SW and DRM can be unified by making the DRM structs
30 * 'sub-classes' of the SW structs, either proper or with field re-ordering.
31 *
32 * The code can also be unified but that requires cluttering the common code
33 * with ifdef's and guarding with (__DRIscreen::fd >= 0) for DRM.
34 */
35
36 #ifndef _DRISW_UTIL_H
37 #define _DRISW_UTIL_H
38
39 #include <GL/gl.h>
40 #include <GL/internal/glcore.h>
41 #include <GL/internal/dri_interface.h>
42 typedef struct _drmLock drmLock;
43
44
45 /**
46 * Extensions
47 */
48 extern const __DRIcoreExtension driCoreExtension;
49 extern const __DRIswrastExtension driSWRastExtension;
50
51
52 /**
53 * Driver callback functions
54 */
55 struct __DriverAPIRec {
56 const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
57
58 void (*DestroyScreen)(__DRIscreen *driScrnPriv);
59
60 GLboolean (*CreateContext)(const __GLcontextModes *glVis,
61 __DRIcontext *driContextPriv,
62 void *sharedContextPrivate);
63
64 void (*DestroyContext)(__DRIcontext *driContextPriv);
65
66 GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
67 __DRIdrawable *driDrawPriv,
68 const __GLcontextModes *glVis,
69 GLboolean pixmapBuffer);
70
71 void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
72
73 void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
74
75 GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
76 __DRIdrawable *driDrawPriv,
77 __DRIdrawable *driReadPriv);
78
79 GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
80 };
81
82 extern const struct __DriverAPIRec driDriverAPI;
83
84
85 /**
86 * Data types
87 */
88 struct __DRIscreenRec {
89 int myNum;
90
91 int fd;
92
93 void *private;
94
95 const __DRIextension **extensions;
96
97 const __DRIswrastLoaderExtension *swrast_loader;
98 };
99
100 struct __DRIcontextRec {
101
102 void *driverPrivate;
103
104 void *loaderPrivate;
105
106 __DRIdrawable *driDrawablePriv;
107
108 __DRIdrawable *driReadablePriv;
109
110 __DRIscreen *driScreenPriv;
111 };
112
113 struct __DRIdrawableRec {
114
115 void *driverPrivate;
116
117 void *loaderPrivate;
118
119 __DRIcontext *driContextPriv;
120
121 __DRIscreen *driScreenPriv;
122
123 int refcount;
124
125 /* gallium */
126 unsigned int lastStamp;
127
128 int w;
129 int h;
130 };
131
132 #endif /* _DRISW_UTIL_H */