2 Copyright (c) 2008, 2009 Apple Inc.
4 Permission is hereby granted, free of charge, to any person
5 obtaining a copy of this software and associated documentation files
6 (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge,
8 publish, distribute, sublicense, and/or sell copies of the Software,
9 and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
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 ABOVE LISTED COPYRIGHT
19 HOLDER(S) 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.
24 Except as contained in this notice, the name(s) of the above
25 copyright holders shall not be used in advertising or otherwise to
26 promote the sale, use or other dealings in this Software without
27 prior written authorization.
29 #ifndef APPLE_GLX_DRAWABLE_H
30 #define APPLE_GLX_DRAWABLE_H
33 * <rdar://problem/6953344>
35 #include "apple_glx_context.h"
41 #define XP_NO_X_HEADERS
43 #undef XP_NO_X_HEADERS
47 APPLE_GLX_DRAWABLE_SURFACE
= 1,
48 APPLE_GLX_DRAWABLE_PBUFFER
,
49 APPLE_GLX_DRAWABLE_PIXMAP
52 /* The flag for the find routine. */
55 APPLE_GLX_DRAWABLE_LOCK
= 2,
56 APPLE_GLX_DRAWABLE_REFERENCE
= 4
59 struct apple_glx_context
;
60 struct apple_glx_drawable
;
62 struct apple_glx_surface
64 xp_surface_id surface_id
;
69 struct apple_glx_pbuffer
71 GLXPbuffer xid
; /* our pixmap */
74 CGLPBufferObj buffer_obj
;
75 unsigned long event_mask
;
78 struct apple_glx_pixmap
82 int width
, height
, pitch
, /*bytes per pixel */ bpp
;
86 CGLPixelFormatObj pixel_format_obj
;
87 CGLContextObj context_obj
;
91 struct apple_glx_drawable_callbacks
94 bool(*make_current
) (struct apple_glx_context
* ac
,
95 struct apple_glx_drawable
* d
);
96 void (*destroy
) (Display
* dpy
, struct apple_glx_drawable
* d
);
99 struct apple_glx_drawable
103 GLXDrawable drawable
;
104 int type
; /* APPLE_GLX_DRAWABLE_* */
108 struct apple_glx_pixmap pixmap
;
109 struct apple_glx_pbuffer pbuffer
;
110 struct apple_glx_surface surface
;
113 struct apple_glx_drawable_callbacks callbacks
;
116 * This mutex protects the reference count and any other drawable data.
117 * It's used to prevent an early release of a drawable.
119 pthread_mutex_t mutex
;
120 void (*lock
) (struct apple_glx_drawable
* agd
);
121 void (*unlock
) (struct apple_glx_drawable
* agd
);
123 void (*reference
) (struct apple_glx_drawable
* agd
);
124 void (*release
) (struct apple_glx_drawable
* agd
);
126 bool(*destroy
) (struct apple_glx_drawable
* agd
);
128 bool(*is_pbuffer
) (struct apple_glx_drawable
* agd
);
130 bool(*is_pixmap
) (struct apple_glx_drawable
* agd
);
132 /*BEGIN These are used for the mixed mode drawing... */
136 int fd
; /* The file descriptor for this drawable's shared memory. */
137 void *buffer
; /* The memory for the drawable. Typically shared memory. */
138 size_t buffer_length
;
139 /*END*/ struct apple_glx_drawable
*previous
, *next
;
142 struct apple_glx_context
;
144 /* May return NULL if not found */
145 struct apple_glx_drawable
*apple_glx_find_drawable(Display
* dpy
,
146 GLXDrawable drawable
);
148 /* Returns true on error and locks the agd result with a reference. */
149 bool apple_glx_drawable_create(Display
* dpy
,
151 GLXDrawable drawable
,
152 struct apple_glx_drawable
**agd
,
153 struct apple_glx_drawable_callbacks
156 /* Returns true on error */
157 bool apple_glx_create_drawable(Display
* dpy
,
158 struct apple_glx_context
*ac
,
159 GLXDrawable drawable
,
160 struct apple_glx_drawable
**agd
);
162 void apple_glx_garbage_collect_drawables(Display
* dpy
);
165 * This returns the total number of drawables.
166 * It's mostly intended for debugging and introspection.
168 unsigned int apple_glx_get_drawable_count(void);
170 struct apple_glx_drawable
*apple_glx_drawable_find_by_type(GLXDrawable
174 struct apple_glx_drawable
*apple_glx_drawable_find(GLXDrawable drawable
,
178 bool apple_glx_drawable_destroy_by_type(Display
* dpy
, GLXDrawable drawable
,
181 struct apple_glx_drawable
*apple_glx_drawable_find_by_uid(unsigned int uid
,
186 bool apple_glx_surface_create(Display
* dpy
, int screen
, GLXDrawable drawable
,
187 struct apple_glx_drawable
**resultptr
);
189 void apple_glx_surface_destroy(unsigned int uid
);
193 /* Returns true if an error occurred. */
194 bool apple_glx_pbuffer_create(Display
* dpy
, GLXFBConfig config
,
195 int width
, int height
, int *errorcode
,
198 /* Returns true if the pbuffer was invalid. */
199 bool apple_glx_pbuffer_destroy(Display
* dpy
, GLXPbuffer pbuf
);
201 /* Returns true if the pbuffer was valid and the attribute. */
202 bool apple_glx_pbuffer_query(GLXDrawable d
, int attribute
,
203 unsigned int *value
);
205 /* Returns true if the GLXDrawable is a valid GLXPbuffer, and the mask is set. */
206 bool apple_glx_pbuffer_set_event_mask(GLXDrawable d
, unsigned long mask
);
208 /* Returns true if the GLXDrawable is a valid GLXPbuffer, and the *mask is set. */
209 bool apple_glx_pbuffer_get_event_mask(GLXDrawable d
, unsigned long *mask
);
214 /* mode is a struct glx_config * */
215 /* Returns true if an error occurred. */
216 bool apple_glx_pixmap_create(Display
* dpy
, int screen
, Pixmap pixmap
,
219 /* Returns true if an error occurred. */
220 bool apple_glx_pixmap_destroy(Display
* dpy
, Pixmap pixmap
);
222 bool apple_glx_pixmap_query(GLXPixmap pixmap
, int attribute
,
223 unsigned int *value
);