Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzVideo.h @ 272:d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
From: Darrell Walisser <dwaliss1@purdue.edu>
Subject: SDL Quartz video update
-better mouse motion events
-fixed minification bugs (except OpenGL)
-fixed QZ_SetGamma for correct semantics
-fade/unfade display before/after rez switch
-experimental obscured-check/blind-copy code
The obscured code, while it speeds up window drawing substantially, isn't
ready yet. The reason is that there doesn't (yet) seem to be a way to know
when the window is dragged or when the window suddenly comes to the
foreground. Since Carbon windows seem to allow detection of such things, I
suspect it is possible through some window server API. Cocoa(NSWindow) has no
functions for such things, AFAIK.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 22 Jan 2002 18:46:28 +0000 |
parents | e8157fcb3114 |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
271:9631db4d9ee1 | 272:d1447a846d80 |
---|---|
32 - Hardware Cursor support with NSCursor instead of Carbon | 32 - Hardware Cursor support with NSCursor instead of Carbon |
33 - Keyboard repeat/mouse speed adjust (if needed) | 33 - Keyboard repeat/mouse speed adjust (if needed) |
34 - Multiple monitor support (currently only main display) | 34 - Multiple monitor support (currently only main display) |
35 - Accelerated blitting support | 35 - Accelerated blitting support |
36 - Set the window icon (dock icon when API is available) | 36 - Set the window icon (dock icon when API is available) |
37 - Avoid erasing window on minimize, or disable minimize | 37 - Fix white OpenGL window on minimize |
38 - Find out what events should be sent/ignored if window is mimimized | |
39 - Find a better way to deal with resolution/depth switch while app is running | |
40 - Resizeable windows | |
41 - Check accuracy of QZ_SetGamma() | |
38 Problems: | 42 Problems: |
39 - OGL not working in full screen with software renderer | 43 - OGL not working in full screen with software renderer |
40 - SetColors sets palette correctly but clears framebuffer | 44 - SetColors sets palette correctly but clears framebuffer |
41 - Crash in CG after several mode switches | 45 - Crash in CG after several mode switches |
42 - Retained windows don't draw their title bar quite right (OS Bug) | 46 - Retained windows don't draw their title bar quite right (OS Bug) (not using retained windows) |
43 - Should I do depth switching for windowed modes? - No, not usually. | 47 - Cursor in 8 bit modes is screwy (might just be Radeon PCI bug) |
44 - Launch times are slow, maybe prebinding will help | 48 - Warping cursor delays mouse events for a fraction of a second, |
45 - Direct framebuffer access has some artifacts, maybe a driver issue | 49 there is a hack around this that helps a bit |
46 - Cursor in 8 bit modes is screwy | |
47 */ | 50 */ |
48 | 51 |
49 #include <ApplicationServices/ApplicationServices.h> | 52 #include <Cocoa/Cocoa.h> |
50 #include <OpenGL/OpenGL.h> | 53 #include <OpenGL/OpenGL.h> |
51 #include <Cocoa/Cocoa.h> | |
52 #include <Carbon/Carbon.h> | 54 #include <Carbon/Carbon.h> |
53 | 55 |
54 #include "SDL_video.h" | 56 #include "SDL_video.h" |
55 #include "SDL_error.h" | 57 #include "SDL_error.h" |
58 #include "SDL_timer.h" | |
56 #include "SDL_syswm.h" | 59 #include "SDL_syswm.h" |
57 #include "SDL_sysvideo.h" | 60 #include "SDL_sysvideo.h" |
58 #include "SDL_pixels_c.h" | 61 #include "SDL_pixels_c.h" |
59 #include "SDL_events_c.h" | 62 #include "SDL_events_c.h" |
60 | 63 |
69 { | 72 { |
70 return _contextAuxiliary; | 73 return _contextAuxiliary; |
71 } | 74 } |
72 @end | 75 @end |
73 | 76 |
77 /* Structure for rez switch gamma fades */ | |
78 /* We can hide the monitor flicker by setting the gamma tables to 0 */ | |
79 #define QZ_GAMMA_TABLE_SIZE 256 | |
80 | |
81 typedef struct { | |
82 | |
83 CGGammaValue red[QZ_GAMMA_TABLE_SIZE]; | |
84 CGGammaValue green[QZ_GAMMA_TABLE_SIZE]; | |
85 CGGammaValue blue[QZ_GAMMA_TABLE_SIZE]; | |
86 | |
87 } SDL_QuartzGammaTable; | |
88 | |
89 /* Main driver structure to store required state information */ | |
74 typedef struct SDL_PrivateVideoData { | 90 typedef struct SDL_PrivateVideoData { |
75 | 91 |
76 CGDirectDisplayID display; /* 0 == main display */ | 92 CGDirectDisplayID display; /* 0 == main display (only support single display) */ |
77 CFDictionaryRef mode; | 93 CFDictionaryRef mode; /* current mode of the display */ |
78 CFDictionaryRef save_mode; | 94 CFDictionaryRef save_mode; /* original mode of the display */ |
79 CFArrayRef mode_list; | 95 CFArrayRef mode_list; /* list of available fullscreen modes */ |
80 CGDirectPaletteRef palette; | 96 CGDirectPaletteRef palette; /* palette of an 8-bit display */ |
81 NSOpenGLContext *gl_context; | 97 NSOpenGLContext *gl_context; /* object that represents an OpenGL rendering context */ |
82 Uint32 width, height, bpp; | 98 Uint32 width, height, bpp; /* frequently used data about the display */ |
83 Uint32 flags; | 99 Uint32 flags; /* flags for mode, for teardown purposes */ |
84 SDL_bool video_is_set; /* tell if the video mode was set */ | 100 Uint32 video_set; /* boolean; indicates if video was set correctly */ |
85 | 101 Uint32 warp_flag; /* boolean; notify to event loop that a warp just occured */ |
86 /* Window-only fields */ | 102 Uint32 warp_ticks; /* timestamp when the warp occured */ |
87 NSWindow *window; | 103 NSWindow *window; /* Cocoa window to implement the SDL window */ |
88 NSQuickDrawView *view; | 104 NSQuickDrawView *view; /* the window's view; draw 2D into this view */ |
89 | 105 |
90 } SDL_PrivateVideoData ; | 106 } SDL_PrivateVideoData ; |
91 | 107 |
92 #define _THIS SDL_VideoDevice *this | 108 #define _THIS SDL_VideoDevice *this |
93 #define display_id (this->hidden->display) | 109 #define display_id (this->hidden->display) |
94 #define mode (this->hidden->mode) | 110 #define mode (this->hidden->mode) |
95 #define save_mode (this->hidden->save_mode) | 111 #define save_mode (this->hidden->save_mode) |
96 #define mode_list (this->hidden->mode_list) | 112 #define mode_list (this->hidden->mode_list) |
97 #define palette (this->hidden->palette) | 113 #define palette (this->hidden->palette) |
98 #define glcontext (this->hidden->glcontext) | |
99 #define objc_video (this->hidden->objc_video) | |
100 #define gl_context (this->hidden->gl_context) | 114 #define gl_context (this->hidden->gl_context) |
101 #define device_width (this->hidden->width) | 115 #define device_width (this->hidden->width) |
102 #define device_height (this->hidden->height) | 116 #define device_height (this->hidden->height) |
103 #define device_bpp (this->hidden->bpp) | 117 #define device_bpp (this->hidden->bpp) |
104 #define mode_flags (this->hidden->flags) | 118 #define mode_flags (this->hidden->flags) |
105 #define video_set (this->hidden->video_is_set) | |
106 #define qz_window (this->hidden->window) | 119 #define qz_window (this->hidden->window) |
107 #define windowView (this->hidden->view) | 120 #define window_view (this->hidden->view) |
108 | 121 #define video_set (this->hidden->video_set) |
109 /* Interface for hardware fill not (yet) in the public API */ | 122 #define warp_ticks (this->hidden->warp_ticks) |
110 int CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, unsigned int y, | 123 #define warp_flag (this->hidden->warp_flag) |
124 | |
125 /* Obscuring code: maximum number of windows above ours (inclusive) */ | |
126 #define kMaxWindows 256 | |
127 | |
128 /* Some of the Core Graphics Server API for obscuring code */ | |
129 #define kCGSWindowLevelTop 2147483632 | |
130 #define kCGSWindowLevelDockIconDrag 500 | |
131 #define kCGSWindowLevelDockMenu 101 | |
132 #define kCGSWindowLevelMenuIgnore 21 | |
133 #define kCGSWindowLevelMenu 20 | |
134 #define kCGSWindowLevelDockLabel 12 | |
135 #define kCGSWindowLevelDockIcon 11 | |
136 #define kCGSWindowLevelDock 10 | |
137 #define kCGSWindowLevelUtility 3 | |
138 #define kCGSWindowLevelNormal 0 | |
139 | |
140 /* For completeness; We never use these window levels, they are always below us | |
141 #define kCGSWindowLevelMBarShadow -20 | |
142 #define kCGSWindowLevelDesktopPicture -2147483647 | |
143 #define kCGSWindowLevelDesktop -2147483648 | |
144 */ | |
145 | |
146 typedef CGError CGSError; | |
147 typedef long CGSWindowCount; | |
148 typedef void * CGSConnectionID; | |
149 typedef int CGSWindowID; | |
150 typedef CGSWindowID* CGSWindowIDList; | |
151 typedef CGWindowLevel CGSWindowLevel; | |
152 typedef NSRect CGSRect; | |
153 | |
154 extern CGSConnectionID _CGSDefaultConnection (); | |
155 | |
156 extern CGSError CGSGetOnScreenWindowList (CGSConnectionID cid, | |
157 CGSConnectionID owner, | |
158 CGSWindowCount listCapacity, | |
159 CGSWindowIDList list, | |
160 CGSWindowCount *listCount); | |
161 | |
162 extern CGSError CGSGetScreenRectForWindow (CGSConnectionID cid, | |
163 CGSWindowID wid, | |
164 CGSRect *rect); | |
165 | |
166 extern CGWindowLevel CGSGetWindowLevel (CGSConnectionID cid, | |
167 CGSWindowID wid, | |
168 CGSWindowLevel *level); | |
169 | |
170 extern CGSError CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, unsigned int y, | |
111 unsigned int w, unsigned int h, unsigned int color); | 171 unsigned int w, unsigned int h, unsigned int color); |
112 int CGSDisplayCanHWFill (CGDirectDisplayID id); | 172 |
173 extern CGSError CGSDisplayCanHWFill (CGDirectDisplayID id); | |
174 | |
175 extern CGSError CGSGetMouseEnabledFlags (CGSConnectionID cid, CGSWindowID wid, int *flags); | |
113 | 176 |
114 /* Bootstrap functions */ | 177 /* Bootstrap functions */ |
115 static int QZ_Available (); | 178 static int QZ_Available (); |
116 static SDL_VideoDevice* QZ_CreateDevice (int device_index); | 179 static SDL_VideoDevice* QZ_CreateDevice (int device_index); |
117 static void QZ_DeleteDevice (SDL_VideoDevice *device); | 180 static void QZ_DeleteDevice (SDL_VideoDevice *device); |
154 static int QZ_GL_MakeCurrent (_THIS); | 217 static int QZ_GL_MakeCurrent (_THIS); |
155 static void QZ_GL_SwapBuffers (_THIS); | 218 static void QZ_GL_SwapBuffers (_THIS); |
156 static int QZ_GL_LoadLibrary (_THIS, const char *location); | 219 static int QZ_GL_LoadLibrary (_THIS, const char *location); |
157 | 220 |
158 /* Private function to warp the cursor (used internally) */ | 221 /* Private function to warp the cursor (used internally) */ |
159 static void QZ_PrivateWarpCursor (_THIS, int fullscreen, int h, int x, int y); | 222 static void QZ_PrivateWarpCursor (_THIS, int x, int y); |
160 | 223 |
161 /* Cursor and Mouse functions */ | 224 /* Cursor and Mouse functions */ |
162 static void QZ_FreeWMCursor (_THIS, WMcursor *cursor); | 225 static void QZ_FreeWMCursor (_THIS, WMcursor *cursor); |
163 static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, | 226 static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, |
164 int w, int h, int hot_x, int hot_y); | 227 int w, int h, int hot_x, int hot_y); |
175 static void QZ_SetCaption (_THIS, const char *title, const char *icon); | 238 static void QZ_SetCaption (_THIS, const char *title, const char *icon); |
176 static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask); | 239 static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask); |
177 static int QZ_IconifyWindow (_THIS); | 240 static int QZ_IconifyWindow (_THIS); |
178 static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode); | 241 static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode); |
179 /*static int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/ | 242 /*static int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/ |
243 |