Mercurial > sdl-ios-xcode
comparison src/video/fbcon/SDL_fbvideo.c @ 1780:7a36f01acf71
Fixed bug #49
Added support for non-blocking VT switching on the framebuffer console.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 08 May 2006 05:33:02 +0000 |
parents | 980d2a0dc2a3 |
children | 49b4b8413734 |
comparison
equal
deleted
inserted
replaced
1779:67fc81efcfc3 | 1780:7a36f01acf71 |
---|---|
1236 } | 1236 } |
1237 surface->pixels = NULL; | 1237 surface->pixels = NULL; |
1238 surface->hwdata = NULL; | 1238 surface->hwdata = NULL; |
1239 } | 1239 } |
1240 | 1240 |
1241 /* Routine to check to see if the frame buffer virtual terminal */ | |
1242 /* is the current(active) one. If it is not, result will cause */ | |
1243 /* Lock to fail. (would have waited forever, since the fbevent */ | |
1244 /* keyboard handler maintains a lock when switched away from */ | |
1245 /* current) */ | |
1246 static __inline__ int FB_IsFrameBufferActive(_THIS) | |
1247 { | |
1248 struct vt_stat vtstate; | |
1249 if ( (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) || | |
1250 (current_vt != vtstate.v_active) ) { | |
1251 return 0; | |
1252 } | |
1253 return 1; | |
1254 } | |
1255 | |
1256 | |
1257 static int FB_LockHWSurface(_THIS, SDL_Surface *surface) | 1241 static int FB_LockHWSurface(_THIS, SDL_Surface *surface) |
1258 { | 1242 { |
1259 if ( !FB_IsFrameBufferActive(this) ) { | 1243 if ( switched_away ) { |
1260 return -1; /* fail locking. */ | 1244 return -2; /* no hardware access */ |
1261 } | 1245 } |
1262 if ( surface == this->screen ) { | 1246 if ( surface == this->screen ) { |
1263 SDL_mutexP(hw_lock); | 1247 SDL_mutexP(hw_lock); |
1264 if ( FB_IsSurfaceBusy(surface) ) { | 1248 if ( FB_IsSurfaceBusy(surface) ) { |
1265 FB_WaitBusySurfaces(this); | 1249 FB_WaitBusySurfaces(this); |
1291 return; | 1275 return; |
1292 } | 1276 } |
1293 | 1277 |
1294 static int FB_FlipHWSurface(_THIS, SDL_Surface *surface) | 1278 static int FB_FlipHWSurface(_THIS, SDL_Surface *surface) |
1295 { | 1279 { |
1280 if ( switched_away ) { | |
1281 return -2; /* no hardware access */ | |
1282 } | |
1283 | |
1296 /* Wait for vertical retrace and then flip display */ | 1284 /* Wait for vertical retrace and then flip display */ |
1297 cache_vinfo.yoffset = flip_page*surface->h; | 1285 cache_vinfo.yoffset = flip_page*surface->h; |
1298 if ( FB_IsSurfaceBusy(this->screen) ) { | 1286 if ( FB_IsSurfaceBusy(this->screen) ) { |
1299 FB_WaitBusySurfaces(this); | 1287 FB_WaitBusySurfaces(this); |
1300 } | 1288 } |
1330 int width, height, FBPitch, left, i, j, SRCPitch, phase; | 1318 int width, height, FBPitch, left, i, j, SRCPitch, phase; |
1331 register Uint32 m; | 1319 register Uint32 m; |
1332 Uint8 s1, s2, s3, s4; | 1320 Uint8 s1, s2, s3, s4; |
1333 Uint32 *src, *srcPtr; | 1321 Uint32 *src, *srcPtr; |
1334 Uint8 *dst, *dstPtr; | 1322 Uint8 *dst, *dstPtr; |
1323 | |
1324 if ( switched_away ) { | |
1325 return; /* no hardware access */ | |
1326 } | |
1335 | 1327 |
1336 screen = this->screen; | 1328 screen = this->screen; |
1337 FBPitch = screen->w >> 3; | 1329 FBPitch = screen->w >> 3; |
1338 SRCPitch = screen->pitch >> 2; | 1330 SRCPitch = screen->pitch >> 2; |
1339 | 1331 |