Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11yuv.c @ 1575:3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 22 Mar 2006 05:00:59 +0000 |
parents | d910939febfa |
children | f1211a4b7380 |
comparison
equal
deleted
inserted
replaced
1574:0fd72308659e | 1575:3ba88cb7eb1b |
---|---|
149 } | 149 } |
150 } | 150 } |
151 } | 151 } |
152 } | 152 } |
153 if ( formats ) { | 153 if ( formats ) { |
154 pXFree(formats); | 154 XFree(formats); |
155 } | 155 } |
156 } | 156 } |
157 } | 157 } |
158 SDL_NAME(XvFreeAdaptorInfo)(ainfo); | 158 SDL_NAME(XvFreeAdaptorInfo)(ainfo); |
159 } | 159 } |
198 { | 198 { |
199 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; | 199 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
200 unsigned int i; | 200 unsigned int i; |
201 | 201 |
202 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); | 202 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); |
203 X_handler = pXSetErrorHandler(xv_errhandler); | 203 X_handler = XSetErrorHandler(xv_errhandler); |
204 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { | 204 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { |
205 Atom a; | 205 Atom a; |
206 | 206 |
207 xv_error = False; | 207 xv_error = False; |
208 a = pXInternAtom(GFX_Display, attr[i], True); | 208 a = XInternAtom(GFX_Display, attr[i], True); |
209 if ( a != None ) { | 209 if ( a != None ) { |
210 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); | 210 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); |
211 pXSync(GFX_Display, True); | 211 XSync(GFX_Display, True); |
212 if ( ! xv_error ) { | 212 if ( ! xv_error ) { |
213 break; | 213 break; |
214 } | 214 } |
215 } | 215 } |
216 } | 216 } |
217 pXSetErrorHandler(X_handler); | 217 XSetErrorHandler(X_handler); |
218 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); | 218 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); |
219 } | 219 } |
220 | 220 |
221 /* Create the overlay structure */ | 221 /* Create the overlay structure */ |
222 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); | 222 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); |
252 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, | 252 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
253 0, width, height, yuvshm); | 253 0, width, height, yuvshm); |
254 #ifdef PITCH_WORKAROUND | 254 #ifdef PITCH_WORKAROUND |
255 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { | 255 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
256 /* Ajust overlay width according to pitch */ | 256 /* Ajust overlay width according to pitch */ |
257 pXFree(hwdata->image); | 257 XFree(hwdata->image); |
258 width = hwdata->image->pitches[0] / bpp; | 258 width = hwdata->image->pitches[0] / bpp; |
259 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, | 259 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, |
260 0, width, height, yuvshm); | 260 0, width, height, yuvshm); |
261 } | 261 } |
262 #endif /* PITCH_WORKAROUND */ | 262 #endif /* PITCH_WORKAROUND */ |
267 if ( yuvshm->shmid >= 0 ) { | 267 if ( yuvshm->shmid >= 0 ) { |
268 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); | 268 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); |
269 yuvshm->readOnly = False; | 269 yuvshm->readOnly = False; |
270 if ( yuvshm->shmaddr != (char *)-1 ) { | 270 if ( yuvshm->shmaddr != (char *)-1 ) { |
271 shm_error = False; | 271 shm_error = False; |
272 X_handler = pXSetErrorHandler(shm_errhandler); | 272 X_handler = XSetErrorHandler(shm_errhandler); |
273 pXShmAttach(GFX_Display, yuvshm); | 273 XShmAttach(GFX_Display, yuvshm); |
274 pXSync(GFX_Display, True); | 274 XSync(GFX_Display, True); |
275 pXSetErrorHandler(X_handler); | 275 XSetErrorHandler(X_handler); |
276 if ( shm_error ) | 276 if ( shm_error ) |
277 shmdt(yuvshm->shmaddr); | 277 shmdt(yuvshm->shmaddr); |
278 } else { | 278 } else { |
279 shm_error = True; | 279 shm_error = True; |
280 } | 280 } |
281 shmctl(yuvshm->shmid, IPC_RMID, NULL); | 281 shmctl(yuvshm->shmid, IPC_RMID, NULL); |
282 } else { | 282 } else { |
283 shm_error = True; | 283 shm_error = True; |
284 } | 284 } |
285 if ( shm_error ) { | 285 if ( shm_error ) { |
286 pXFree(hwdata->image); | 286 XFree(hwdata->image); |
287 hwdata->yuv_use_mitshm = 0; | 287 hwdata->yuv_use_mitshm = 0; |
288 } else { | 288 } else { |
289 hwdata->image->data = yuvshm->shmaddr; | 289 hwdata->image->data = yuvshm->shmaddr; |
290 } | 290 } |
291 } | 291 } |
296 0, width, height); | 296 0, width, height); |
297 | 297 |
298 #ifdef PITCH_WORKAROUND | 298 #ifdef PITCH_WORKAROUND |
299 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { | 299 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { |
300 /* Ajust overlay width according to pitch */ | 300 /* Ajust overlay width according to pitch */ |
301 pXFree(hwdata->image); | 301 XFree(hwdata->image); |
302 width = hwdata->image->pitches[0] / bpp; | 302 width = hwdata->image->pitches[0] / bpp; |
303 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, | 303 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, |
304 0, width, height); | 304 0, width, height); |
305 } | 305 } |
306 #endif /* PITCH_WORKAROUND */ | 306 #endif /* PITCH_WORKAROUND */ |
370 { | 370 { |
371 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 371 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
372 hwdata->image, 0, 0, overlay->w, overlay->h, | 372 hwdata->image, 0, 0, overlay->w, overlay->h, |
373 dstrect->x, dstrect->y, dstrect->w, dstrect->h); | 373 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
374 } | 374 } |
375 pXSync(GFX_Display, False); | 375 XSync(GFX_Display, False); |
376 return(0); | 376 return(0); |
377 } | 377 } |
378 | 378 |
379 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | 379 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) |
380 { | 380 { |
383 hwdata = overlay->hwdata; | 383 hwdata = overlay->hwdata; |
384 if ( hwdata ) { | 384 if ( hwdata ) { |
385 SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); | 385 SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); |
386 #ifndef NO_SHARED_MEMORY | 386 #ifndef NO_SHARED_MEMORY |
387 if ( hwdata->yuv_use_mitshm ) { | 387 if ( hwdata->yuv_use_mitshm ) { |
388 pXShmDetach(GFX_Display, &hwdata->yuvshm); | 388 XShmDetach(GFX_Display, &hwdata->yuvshm); |
389 shmdt(hwdata->yuvshm.shmaddr); | 389 shmdt(hwdata->yuvshm.shmaddr); |
390 } | 390 } |
391 #endif | 391 #endif |
392 if ( hwdata->image ) { | 392 if ( hwdata->image ) { |
393 pXFree(hwdata->image); | 393 XFree(hwdata->image); |
394 } | 394 } |
395 SDL_free(hwdata); | 395 SDL_free(hwdata); |
396 } | 396 } |
397 if ( overlay->pitches ) { | 397 if ( overlay->pitches ) { |
398 SDL_free(overlay->pitches); | 398 SDL_free(overlay->pitches); |