comparison src/video/SDL_video.c @ 2908:aa6ba38c1714

Added clipping for render copy
author Sam Lantinga <slouken@libsdl.org>
date Tue, 23 Dec 2008 01:28:06 +0000
parents 133601e3b255
children 3da0bb421d83
comparison
equal deleted inserted replaced
2907:5f89d3751ce7 2908:aa6ba38c1714
2153 if (!renderer->RenderFill) { 2153 if (!renderer->RenderFill) {
2154 SDL_Unsupported(); 2154 SDL_Unsupported();
2155 return -1; 2155 return -1;
2156 } 2156 }
2157 window = SDL_GetWindowFromID(renderer->window); 2157 window = SDL_GetWindowFromID(renderer->window);
2158
2158 real_rect.x = 0; 2159 real_rect.x = 0;
2159 real_rect.y = 0; 2160 real_rect.y = 0;
2160 real_rect.w = window->w; 2161 real_rect.w = window->w;
2161 real_rect.h = window->h; 2162 real_rect.h = window->h;
2162 if (rect) { 2163 if (rect) {
2187 if (!renderer->RenderCopy) { 2188 if (!renderer->RenderCopy) {
2188 SDL_Unsupported(); 2189 SDL_Unsupported();
2189 return -1; 2190 return -1;
2190 } 2191 }
2191 window = SDL_GetWindowFromID(renderer->window); 2192 window = SDL_GetWindowFromID(renderer->window);
2193
2194 real_srcrect.x = 0;
2195 real_srcrect.y = 0;
2196 real_srcrect.w = texture->w;
2197 real_srcrect.h = texture->h;
2192 if (srcrect) { 2198 if (srcrect) {
2193 real_srcrect = *srcrect; 2199 if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
2194 } else { 2200 return 0;
2195 real_srcrect.x = 0; 2201 }
2196 real_srcrect.y = 0; 2202 }
2197 real_srcrect.w = texture->w; 2203
2198 real_srcrect.h = texture->h; 2204 real_dstrect.x = 0;
2199 } 2205 real_dstrect.y = 0;
2206 real_dstrect.w = window->w;
2207 real_dstrect.h = window->h;
2200 if (dstrect) { 2208 if (dstrect) {
2201 real_dstrect = *dstrect; 2209 if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
2202 } else { 2210 return 0;
2203 real_dstrect.x = 0; 2211 }
2204 real_dstrect.y = 0;
2205 real_dstrect.w = window->w;
2206 real_dstrect.h = window->h;
2207 } 2212 }
2208 2213
2209 return renderer->RenderCopy(renderer, texture, &real_srcrect, 2214 return renderer->RenderCopy(renderer, texture, &real_srcrect,
2210 &real_dstrect); 2215 &real_dstrect);
2211 } 2216 }