1848b8605Smrg/*
2848b8605Smrg Copyright (c) 2008, 2009 Apple Inc.
3848b8605Smrg
4848b8605Smrg Permission is hereby granted, free of charge, to any person
5848b8605Smrg obtaining a copy of this software and associated documentation files
6848b8605Smrg (the "Software"), to deal in the Software without restriction,
7848b8605Smrg including without limitation the rights to use, copy, modify, merge,
8848b8605Smrg publish, distribute, sublicense, and/or sell copies of the Software,
9848b8605Smrg and to permit persons to whom the Software is furnished to do so,
10848b8605Smrg subject to the following conditions:
11848b8605Smrg
12848b8605Smrg The above copyright notice and this permission notice shall be
13848b8605Smrg included in all copies or substantial portions of the Software.
14848b8605Smrg
15848b8605Smrg THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16848b8605Smrg EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17848b8605Smrg MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18848b8605Smrg NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
19848b8605Smrg HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20848b8605Smrg WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21848b8605Smrg OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22848b8605Smrg DEALINGS IN THE SOFTWARE.
23848b8605Smrg
24848b8605Smrg Except as contained in this notice, the name(s) of the above
25848b8605Smrg copyright holders shall not be used in advertising or otherwise to
26848b8605Smrg promote the sale, use or other dealings in this Software without
27848b8605Smrg prior written authorization.
28848b8605Smrg*/
29848b8605Smrg#ifndef APPLE_GLX_CONTEXT_H
30848b8605Smrg#define APPLE_GLX_CONTEXT_H
31848b8605Smrg
32848b8605Smrg/* <rdar://problem/6953344> */
33848b8605Smrg#define glTexImage1D glTexImage1D_OSX
34848b8605Smrg#define glTexImage2D glTexImage2D_OSX
35848b8605Smrg#define glTexImage3D glTexImage3D_OSX
36848b8605Smrg#include <OpenGL/CGLTypes.h>
37848b8605Smrg#include <OpenGL/CGLContext.h>
38848b8605Smrg#undef glTexImage1D
39848b8605Smrg#undef glTexImage2D
40848b8605Smrg#undef glTexImage3D
41848b8605Smrg
42848b8605Smrg#include <stdbool.h>
43848b8605Smrg#include <X11/Xlib.h>
44848b8605Smrg#include <GL/glx.h>
45848b8605Smrg#define XP_NO_X_HEADERS
46848b8605Smrg#include <Xplugin.h>
47848b8605Smrg#undef XP_NO_X_HEADERS
48848b8605Smrg
49848b8605Smrg#include "apple_glx_drawable.h"
50848b8605Smrg
51848b8605Smrgstruct apple_glx_context
52848b8605Smrg{
53848b8605Smrg   CGLContextObj context_obj;
54848b8605Smrg   CGLPixelFormatObj pixel_format_obj;
55848b8605Smrg   struct apple_glx_drawable *drawable;
56848b8605Smrg   pthread_t thread_id;
57848b8605Smrg   int screen;
58848b8605Smrg   bool double_buffered;
59848b8605Smrg   bool uses_stereo;
60848b8605Smrg   bool need_update;
61848b8605Smrg   bool is_current;             /* True if the context is current in some thread. */
62848b8605Smrg   bool made_current;           /* True if the context has ever been made current. */
63848b8605Smrg
64848b8605Smrg   /*
65848b8605Smrg    * last_surface is set by the pending_destroy code handler for a drawable.
66848b8605Smrg    * Due to a CG difference, we have to recreate a surface if the window
67848b8605Smrg    * is unmapped and mapped again.
68848b8605Smrg    */
69848b8605Smrg   Window last_surface_window;
70848b8605Smrg   struct apple_glx_context *previous, *next;
71848b8605Smrg};
72848b8605Smrg
73848b8605Smrgbool apple_glx_create_context(void **ptr, Display * dpy, int screen,
74848b8605Smrg                              const void *mode, void *sharedContext,
75848b8605Smrg                              int *errorptr, bool * x11errorptr);
76848b8605Smrgvoid apple_glx_destroy_context(void **ptr, Display * dpy);
77848b8605Smrg
78848b8605Smrgbool apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
79848b8605Smrg                                    GLXDrawable drawable);
80848b8605Smrgbool apple_glx_is_current_drawable(Display * dpy, void *ptr,
81848b8605Smrg                                   GLXDrawable drawable);
82848b8605Smrg
83848b8605Smrgbool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
84848b8605Smrg                            unsigned long mask, int *errorptr,
85848b8605Smrg                            bool * x11errorptr);
86848b8605Smrg
87848b8605Smrgint apple_glx_context_surface_changed(unsigned int uid, pthread_t caller);
88848b8605Smrg
89848b8605Smrgvoid apple_glx_context_update(Display * dpy, void *ptr);
90848b8605Smrg
91848b8605Smrgbool apple_glx_context_uses_stereo(void *ptr);
92848b8605Smrg
93848b8605Smrg#endif /*APPLE_GLX_CONTEXT_H */
94