# HG changeset patch # User Sam Lantinga # Date 1229995686 0 # Node ID aa6ba38c17142901cbffbf5bb4013255835da08a # Parent 5f89d3751ce7dac8129b7bdc3e8eb60eae7830fa Added clipping for render copy diff -r 5f89d3751ce7 -r aa6ba38c1714 src/video/SDL_video.c --- a/src/video/SDL_video.c Mon Dec 22 05:29:55 2008 +0000 +++ b/src/video/SDL_video.c Tue Dec 23 01:28:06 2008 +0000 @@ -2155,6 +2155,7 @@ return -1; } window = SDL_GetWindowFromID(renderer->window); + real_rect.x = 0; real_rect.y = 0; real_rect.w = window->w; @@ -2189,21 +2190,25 @@ return -1; } window = SDL_GetWindowFromID(renderer->window); + + real_srcrect.x = 0; + real_srcrect.y = 0; + real_srcrect.w = texture->w; + real_srcrect.h = texture->h; if (srcrect) { - real_srcrect = *srcrect; - } else { - real_srcrect.x = 0; - real_srcrect.y = 0; - real_srcrect.w = texture->w; - real_srcrect.h = texture->h; + if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { + return 0; + } } + + real_dstrect.x = 0; + real_dstrect.y = 0; + real_dstrect.w = window->w; + real_dstrect.h = window->h; if (dstrect) { - real_dstrect = *dstrect; - } else { - real_dstrect.x = 0; - real_dstrect.y = 0; - real_dstrect.w = window->w; - real_dstrect.h = window->h; + if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) { + return 0; + } } return renderer->RenderCopy(renderer, texture, &real_srcrect,