comparison src/video/quartz/SDL_QuartzVideo.h @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 9f59d4c5aaea
children
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
52 #include "SDL_opengl.h" 52 #include "SDL_opengl.h"
53 53
54 #include <Cocoa/Cocoa.h> 54 #include <Cocoa/Cocoa.h>
55 #include <Carbon/Carbon.h> 55 #include <Carbon/Carbon.h>
56 #include <QuickTime/QuickTime.h> 56 #include <QuickTime/QuickTime.h>
57 #include <OpenGL/CGLTypes.h> /* For CGLContextObj */ 57 #include <OpenGL/CGLTypes.h> /* For CGLContextObj */
58 #include <IOKit/IOKitLib.h> /* For powersave handling */ 58 #include <IOKit/IOKitLib.h> /* For powersave handling */
59 #include <pthread.h> 59 #include <pthread.h>
60 60
61 #include "SDL_thread.h" 61 #include "SDL_thread.h"
62 #include "SDL_video.h" 62 #include "SDL_video.h"
63 #include "SDL_error.h" 63 #include "SDL_error.h"
70 70
71 /* 71 /*
72 This is a workaround to directly access NSOpenGLContext's CGL context 72 This is a workaround to directly access NSOpenGLContext's CGL context
73 We need this to check for errors NSOpenGLContext doesn't support 73 We need this to check for errors NSOpenGLContext doesn't support
74 */ 74 */
75 @interface NSOpenGLContext (CGLContextAccess) 75 @ interface NSOpenGLContext(CGLContextAccess) - (CGLContextObj) cglContext;
76 - (CGLContextObj) cglContext;
77 @end 76 @end
78
79
80 /* Main driver structure to store required state information */ 77 /* Main driver structure to store required state information */
81 typedef struct SDL_PrivateVideoData { 78 typedef struct SDL_PrivateVideoData
82 79 {
83 CGDirectDisplayID display; /* 0 == main display (only support single display) */ 80
84 CFDictionaryRef mode; /* current mode of the display */ 81 CGDirectDisplayID
85 CFDictionaryRef save_mode; /* original mode of the display */ 82 display; /* 0 == main display (only support single display) */
86 CFArrayRef mode_list; /* list of available fullscreen modes */ 83 CFDictionaryRef
87 CGDirectPaletteRef palette; /* palette of an 8-bit display */ 84 mode; /* current mode of the display */
88 NSOpenGLContext *gl_context; /* OpenGL rendering context */ 85 CFDictionaryRef
89 Uint32 width, height, bpp; /* frequently used data about the display */ 86 save_mode; /* original mode of the display */
90 Uint32 flags; /* flags for current mode, for teardown purposes */ 87 CFArrayRef
91 Uint32 video_set; /* boolean; indicates if video was set correctly */ 88 mode_list; /* list of available fullscreen modes */
92 Uint32 warp_flag; /* boolean; notify to event loop that a warp just occured */ 89 CGDirectPaletteRef
93 Uint32 warp_ticks; /* timestamp when the warp occured */ 90 palette; /* palette of an 8-bit display */
94 NSWindow *window; /* Cocoa window to implement the SDL window */ 91 NSOpenGLContext *
95 NSQuickDrawView *view; /* the window's view; draw 2D and OpenGL into this view */ 92 gl_context; /* OpenGL rendering context */
96 SDL_Surface *resize_icon; /* icon for the resize badge, we have to draw it by hand */ 93 Uint32
97 SDL_GrabMode current_grab_mode; /* default value is SDL_GRAB_OFF */ 94 width,
98 SDL_Rect **client_mode_list; /* resolution list to pass back to client */ 95 height,
99 SDLKey keymap[256]; /* Mac OS X to SDL key mapping */ 96 bpp; /* frequently used data about the display */
100 Uint32 current_mods; /* current keyboard modifiers, to track modifier state */ 97 Uint32
101 Uint32 last_virtual_button;/* last virtual mouse button pressed */ 98 flags; /* flags for current mode, for teardown purposes */
102 io_connect_t power_connection; /* used with IOKit to detect wake from sleep */ 99 Uint32
103 Uint8 expect_mouse_up; /* used to determine when to send mouse up events */ 100 video_set; /* boolean; indicates if video was set correctly */
104 Uint8 grab_state; /* used to manage grab behavior */ 101 Uint32
105 NSPoint cursor_loc; /* saved cursor coords, for activate/deactivate when grabbed */ 102 warp_flag; /* boolean; notify to event loop that a warp just occured */
106 BOOL cursor_should_be_visible; /* tells if cursor is supposed to be visible (SDL_ShowCursor) */ 103 Uint32
107 BOOL cursor_visible; /* tells if cursor is *actually* visible or not */ 104 warp_ticks; /* timestamp when the warp occured */
108 Uint8* sw_buffers[2]; /* pointers to the two software buffers for double-buffer emulation */ 105 NSWindow *
109 SDL_Thread *thread; /* thread for async updates to the screen */ 106 window; /* Cocoa window to implement the SDL window */
110 SDL_sem *sem1, *sem2; /* synchronization for async screen updates */ 107 NSQuickDrawView *
111 Uint8 *current_buffer; /* the buffer being copied to the screen */ 108 view; /* the window's view; draw 2D and OpenGL into this view */
112 BOOL quit_thread; /* used to quit the async blitting thread */ 109 SDL_Surface *
113 SInt32 system_version; /* used to dis-/enable workarounds depending on the system version */ 110 resize_icon; /* icon for the resize badge, we have to draw it by hand */
114 111 SDL_GrabMode
115 ImageDescriptionHandle yuv_idh; 112 current_grab_mode; /* default value is SDL_GRAB_OFF */
116 MatrixRecordPtr yuv_matrix; 113 SDL_Rect **
117 DecompressorComponent yuv_codec; 114 client_mode_list; /* resolution list to pass back to client */
118 ImageSequence yuv_seq; 115 SDLKey
119 PlanarPixmapInfoYUV420 *yuv_pixmap; 116 keymap[256]; /* Mac OS X to SDL key mapping */
120 Sint16 yuv_width, yuv_height; 117 Uint32
121 CGrafPtr yuv_port; 118 current_mods; /* current keyboard modifiers, to track modifier state */
122 119 Uint32
123 void *opengl_library; /* dynamically loaded OpenGL library. */ 120 last_virtual_button; /* last virtual mouse button pressed */
124 } SDL_PrivateVideoData; 121 io_connect_t
122 power_connection; /* used with IOKit to detect wake from sleep */
123 Uint8
124 expect_mouse_up; /* used to determine when to send mouse up events */
125 Uint8
126 grab_state; /* used to manage grab behavior */
127 NSPoint
128 cursor_loc; /* saved cursor coords, for activate/deactivate when grabbed */
129 BOOL
130 cursor_should_be_visible; /* tells if cursor is supposed to be visible (SDL_ShowCursor) */
131 BOOL
132 cursor_visible; /* tells if cursor is *actually* visible or not */
133 Uint8 *
134 sw_buffers[2]; /* pointers to the two software buffers for double-buffer emulation */
135 SDL_Thread *
136 thread; /* thread for async updates to the screen */
137 SDL_sem *
138 sem1, *
139 sem2; /* synchronization for async screen updates */
140 Uint8 *
141 current_buffer; /* the buffer being copied to the screen */
142 BOOL
143 quit_thread; /* used to quit the async blitting thread */
144 SInt32
145 system_version; /* used to dis-/enable workarounds depending on the system version */
146
147 ImageDescriptionHandle
148 yuv_idh;
149 MatrixRecordPtr
150 yuv_matrix;
151 DecompressorComponent
152 yuv_codec;
153 ImageSequence
154 yuv_seq;
155 PlanarPixmapInfoYUV420 *
156 yuv_pixmap;
157 Sint16
158 yuv_width,
159 yuv_height;
160 CGrafPtr
161 yuv_port;
162
163 void *
164 opengl_library; /* dynamically loaded OpenGL library. */
165 } SDL_PrivateVideoData;
125 166
126 #define _THIS SDL_VideoDevice *this 167 #define _THIS SDL_VideoDevice *this
127 #define display_id (this->hidden->display) 168 #define display_id (this->hidden->display)
128 #define mode (this->hidden->mode) 169 #define mode (this->hidden->mode)
129 #define save_mode (this->hidden->save_mode) 170 #define save_mode (this->hidden->save_mode)
159 #define quit_thread (this->hidden->quit_thread) 200 #define quit_thread (this->hidden->quit_thread)
160 #define system_version (this->hidden->system_version) 201 #define system_version (this->hidden->system_version)
161 #define opengl_library (this->hidden->opengl_library) 202 #define opengl_library (this->hidden->opengl_library)
162 203
163 /* grab states - the input is in one of these states */ 204 /* grab states - the input is in one of these states */
164 enum { 205 enum
165 QZ_UNGRABBED = 0, 206 {
166 QZ_VISIBLE_GRAB, 207 QZ_UNGRABBED = 0,
167 QZ_INVISIBLE_GRAB 208 QZ_VISIBLE_GRAB,
168 }; 209 QZ_INVISIBLE_GRAB
210 };
169 211
170 /* grab actions - these can change the grabbed state */ 212 /* grab actions - these can change the grabbed state */
171 enum { 213 enum
172 QZ_ENABLE_GRAB = 0, 214 {
173 QZ_DISABLE_GRAB, 215 QZ_ENABLE_GRAB = 0,
174 QZ_HIDECURSOR, 216 QZ_DISABLE_GRAB,
175 QZ_SHOWCURSOR 217 QZ_HIDECURSOR,
176 }; 218 QZ_SHOWCURSOR
219 };
177 220
178 /* Gamma Functions */ 221 /* Gamma Functions */
179 int QZ_SetGamma (_THIS, float red, float green, float blue); 222 int
180 int QZ_GetGamma (_THIS, float *red, float *green, float *blue); 223 QZ_SetGamma(_THIS, float red, float green, float blue);
181 int QZ_SetGammaRamp (_THIS, Uint16 *ramp); 224 int
182 int QZ_GetGammaRamp (_THIS, Uint16 *ramp); 225 QZ_GetGamma(_THIS, float *red, float *green, float *blue);
226 int
227 QZ_SetGammaRamp(_THIS, Uint16 * ramp);
228 int
229 QZ_GetGammaRamp(_THIS, Uint16 * ramp);
183 230
184 /* OpenGL functions */ 231 /* OpenGL functions */
185 int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags); 232 int
186 void QZ_TearDownOpenGL (_THIS); 233 QZ_SetupOpenGL(_THIS, int bpp, Uint32 flags);
187 void* QZ_GL_GetProcAddress (_THIS, const char *proc); 234 void
188 int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value); 235 QZ_TearDownOpenGL(_THIS);
189 int QZ_GL_MakeCurrent (_THIS); 236 void *
190 void QZ_GL_SwapBuffers (_THIS); 237 QZ_GL_GetProcAddress(_THIS, const char *proc);
191 int QZ_GL_LoadLibrary (_THIS, const char *location); 238 int
239 QZ_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
240 int
241 QZ_GL_MakeCurrent(_THIS);
242 void
243 QZ_GL_SwapBuffers(_THIS);
244 int
245 QZ_GL_LoadLibrary(_THIS, const char *location);
192 246
193 /* Cursor and Mouse functions */ 247 /* Cursor and Mouse functions */
194 void QZ_FreeWMCursor (_THIS, WMcursor *cursor); 248 void
195 WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, 249 QZ_FreeWMCursor(_THIS, WMcursor * cursor);
196 int w, int h, int hot_x, int hot_y); 250 WMcursor *
197 int QZ_ShowWMCursor (_THIS, WMcursor *cursor); 251 QZ_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask,
198 void QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y); 252 int w, int h, int hot_x, int hot_y);
199 void QZ_MoveWMCursor (_THIS, int x, int y); 253 int
200 void QZ_CheckMouseMode (_THIS); 254 QZ_ShowWMCursor(_THIS, WMcursor * cursor);
201 void QZ_UpdateMouse (_THIS); 255 void
256 QZ_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
257 void
258 QZ_MoveWMCursor(_THIS, int x, int y);
259 void
260 QZ_CheckMouseMode(_THIS);
261 void
262 QZ_UpdateMouse(_THIS);
202 263
203 /* Event functions */ 264 /* Event functions */
204 void QZ_InitOSKeymap (_THIS); 265 void
205 void QZ_PumpEvents (_THIS); 266 QZ_InitOSKeymap(_THIS);
267 void
268 QZ_PumpEvents(_THIS);
206 269
207 /* Window Manager functions */ 270 /* Window Manager functions */
208 void QZ_SetCaption (_THIS, const char *title, const char *icon); 271 void
209 void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask); 272 QZ_SetCaption(_THIS, const char *title, const char *icon);
210 int QZ_IconifyWindow (_THIS); 273 void
211 SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode); 274 QZ_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask);
275 int
276 QZ_IconifyWindow(_THIS);
277 SDL_GrabMode
278 QZ_GrabInput(_THIS, SDL_GrabMode grab_mode);
212 /*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/ 279 /*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/
213 280
214 /* YUV functions */ 281 /* YUV functions */
215 SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, 282 SDL_Overlay *QZ_CreateYUVOverlay(_THIS, int width, int height,
216 Uint32 format, SDL_Surface *display); 283 Uint32 format, SDL_Surface * display);
217 284
218 285
219 /* Private functions (used internally) */ 286 /* Private functions (used internally) */
220 void QZ_PrivateWarpCursor (_THIS, int x, int y); 287 void QZ_PrivateWarpCursor(_THIS, int x, int y);
221 void QZ_ChangeGrabState (_THIS, int action); 288 void QZ_ChangeGrabState(_THIS, int action);
222 void QZ_RegisterForSleepNotifications (_THIS); 289 void QZ_RegisterForSleepNotifications(_THIS);
223 void QZ_ShowMouse (_THIS); 290 void QZ_ShowMouse(_THIS);
224 void QZ_HideMouse (_THIS); 291 void QZ_HideMouse(_THIS);
225 void QZ_PrivateGlobalToLocal (_THIS, NSPoint *p); 292 void QZ_PrivateGlobalToLocal(_THIS, NSPoint * p);
226 void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p); 293 void QZ_PrivateCocoaToSDL(_THIS, NSPoint * p);
227 BOOL QZ_IsMouseInWindow (_THIS); 294 BOOL
228 void QZ_DoActivate (_THIS); 295 QZ_IsMouseInWindow(_THIS);
229 void QZ_DoDeactivate (_THIS); 296 void QZ_DoActivate(_THIS);
297 void QZ_DoDeactivate(_THIS);
298 /* vi: set ts=4 sw=4 expandtab: */