Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11yuv.c @ 1642:f1211a4b7380
Fixed bug #189
Clip the overlay destination rectangle to the screen area on X11
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 17 Apr 2006 05:38:33 +0000 |
parents | 3ba88cb7eb1b |
children | 51038e80ae59 |
comparison
equal
deleted
inserted
replaced
1641:5cf11b00b900 | 1642:f1211a4b7380 |
---|---|
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 *dstrect) |
358 { | 358 { |
359 struct private_yuvhwdata *hwdata; | 359 struct private_yuvhwdata *hwdata; |
360 int srcx, srcy, srcw, srch; | |
361 int dstx, dsty, dstw, dsth; | |
360 | 362 |
361 hwdata = overlay->hwdata; | 363 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 #ifndef NO_SHARED_MEMORY | 401 #ifndef NO_SHARED_MEMORY |
363 if ( hwdata->yuv_use_mitshm ) { | 402 if ( hwdata->yuv_use_mitshm ) { |
364 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 403 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
365 hwdata->image, 0, 0, overlay->w, overlay->h, | 404 hwdata->image, |
366 dstrect->x, dstrect->y, dstrect->w, dstrect->h, False); | 405 srcx, srcy, srcw, srch, dstx, dsty, dstw, dsth, False); |
367 } | 406 } |
368 else | 407 else |
369 #endif | 408 #endif |
370 { | 409 { |
371 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 410 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, |
372 hwdata->image, 0, 0, overlay->w, overlay->h, | 411 hwdata->image, |
373 dstrect->x, dstrect->y, dstrect->w, dstrect->h); | 412 srcx, srcy, srcw, srch, dstx, dsty, dstw, dsth); |
374 } | 413 } |
375 XSync(GFX_Display, False); | 414 XSync(GFX_Display, False); |
376 return(0); | 415 return(0); |
377 } | 416 } |
378 | 417 |