Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11yuv.c @ 1643:51038e80ae59
More general fix for bug #189
The clipping is done at a higher level, and the low level functions are
passed clipped rectangles. Drivers which don't support source clipping
have not been changed, so the image will be squished instead of clipped,
but at least they will no longer crash when the destination rect was out
of bounds.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 17 Apr 2006 06:47:23 +0000 |
parents | f1211a4b7380 |
children | 782fd950bd46 c121d94672cb 12bb6311fd5d |
comparison
equal
deleted
inserted
replaced
1642:f1211a4b7380 | 1643:51038e80ae59 |
---|---|
352 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | 352 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) |
353 { | 353 { |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) | 357 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) |
358 { | 358 { |
359 struct private_yuvhwdata *hwdata; | 359 struct private_yuvhwdata *hwdata; |
360 int srcx, srcy, srcw, srch; | |
361 int dstx, dsty, dstw, dsth; | |
362 | 360 |
363 hwdata = overlay->hwdata; | 361 hwdata = overlay->hwdata; |
364 | |
365 /* Clip the rectangle to the screen area */ | |
366 srcx = 0; | |
367 srcy = 0; | |
368 srcw = overlay->w; | |
369 srch = overlay->h; | |
370 dstx = dstrect->x; | |
371 dsty = dstrect->y; | |
372 dstw = dstrect->w; | |
373 dsth = dstrect->h; | |
374 if ( dstx < 0 ) { | |
375 srcw += (dstx * overlay->w) / dstrect->w; | |
376 dstw += dstx; | |
377 srcx -= (dstx * overlay->w) / dstrect->w; | |
378 dstx = 0; | |
379 } | |
380 if ( (dstx+dstw) > this->screen->w ) { | |
381 int extra = (dstx+dstw - this->screen->w); | |
382 srcw -= (extra * overlay->w) / dstrect->w; | |
383 dstw -= extra; | |
384 } | |
385 if ( dsty < 0 ) { | |
386 srch += (dsty * overlay->h) / dstrect->h; | |
387 dsth += dsty; | |
388 srcy -= (dsty * overlay->h) / dstrect->h; | |
389 dsty = 0; | |
390 } | |
391 if ( (dsty+dsth) > this->screen->h ) { | |
392 int extra = (dsty+dsth - this->screen->h); | |
393 srch -= (extra * overlay->h) / dstrect->h; | |
394 dsth -= extra; | |
395 } | |
396 if ( srcw <= 0 || srch <= 0 || | |
397 srch <= 0 || dsth <= 0 ) { | |
398 return; | |
399 } | |
400 | 362 |
401 #ifndef NO_SHARED_MEMORY | 363 #ifndef NO_SHARED_MEMORY |
402 if ( hwdata->yuv_use_mitshm ) { | 364 if ( hwdata->yuv_use_mitshm ) { |
403 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 365 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
404 hwdata->image, | 366 hwdata->image, |
405 srcx, srcy, srcw, srch, dstx, dsty, dstw, dsth, False); | 367 src->x, src->y, src->w, src->h, |
368 dst->x, dst->y, dst->w, dst->h, False); | |
406 } | 369 } |
407 else | 370 else |
408 #endif | 371 #endif |
409 { | 372 { |
410 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 373 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
411 hwdata->image, | 374 hwdata->image, |
412 srcx, srcy, srcw, srch, dstx, dsty, dstw, dsth); | 375 src->x, src->y, src->w, src->h, |
376 dst->x, dst->y, dst->w, dst->h); | |
413 } | 377 } |
414 XSync(GFX_Display, False); | 378 XSync(GFX_Display, False); |
415 return(0); | 379 return(0); |
416 } | 380 } |
417 | 381 |