mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-28 10:14:14 +00:00
SDL_BlitSurface() and SDL_BlitSurfaceScaled() now have a const dstrect parameter
This was originally to avoid duplicating clipping work in Maelstrom on a 486 computer. This has been confusing for users and computers are a little faster these days, so we'll make it work the way people expect.
This commit is contained in:
@@ -68,8 +68,8 @@ SDL_DYNAPI_PROC(SDL_JoystickID,SDL_AttachVirtualJoystick,(const SDL_VirtualJoyst
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AudioDevicePaused,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BindAudioStream,(SDL_AudioDeviceID a, SDL_AudioStream *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BindAudioStreams,(SDL_AudioDeviceID a, SDL_AudioStream **b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceTiled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceTiledWithScale,(SDL_Surface *a, const SDL_Rect *b, float c, SDL_ScaleMode d, SDL_Surface *e, const SDL_Rect *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_BlitSurfaceUnchecked,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
||||
|
||||
@@ -874,7 +874,7 @@ int SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
}
|
||||
|
||||
int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect)
|
||||
SDL_Surface *dst, const SDL_Rect *dstrect)
|
||||
{
|
||||
SDL_Rect r_src, r_dst;
|
||||
|
||||
@@ -905,7 +905,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
if (srcrect) {
|
||||
SDL_Rect tmp;
|
||||
if (SDL_GetRectIntersection(srcrect, &r_src, &tmp) == SDL_FALSE) {
|
||||
goto end;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Shift dstrect, if srcrect origin has changed */
|
||||
@@ -924,7 +924,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
{
|
||||
SDL_Rect tmp;
|
||||
if (SDL_GetRectIntersection(&r_dst, &dst->internal->clip_rect, &tmp) == SDL_FALSE) {
|
||||
goto end;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Shift srcrect, if dstrect has changed */
|
||||
@@ -937,28 +937,22 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
r_dst = tmp;
|
||||
}
|
||||
|
||||
if (r_dst.w <= 0 || r_dst.h <= 0) {
|
||||
/* No-op. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Switch back to a fast blit if we were previously stretching */
|
||||
if (src->internal->map.info.flags & SDL_COPY_NEAREST) {
|
||||
src->internal->map.info.flags &= ~SDL_COPY_NEAREST;
|
||||
SDL_InvalidateMap(&src->internal->map);
|
||||
}
|
||||
|
||||
if (r_dst.w > 0 && r_dst.h > 0) {
|
||||
if (dstrect) { /* update output parameter */
|
||||
*dstrect = r_dst;
|
||||
}
|
||||
return SDL_BlitSurfaceUnchecked(src, &r_src, dst, &r_dst);
|
||||
}
|
||||
|
||||
end:
|
||||
if (dstrect) { /* update output parameter */
|
||||
dstrect->w = dstrect->h = 0;
|
||||
}
|
||||
return 0;
|
||||
return SDL_BlitSurfaceUnchecked(src, &r_src, dst, &r_dst);
|
||||
}
|
||||
|
||||
int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect,
|
||||
SDL_Surface *dst, const SDL_Rect *dstrect,
|
||||
SDL_ScaleMode scaleMode)
|
||||
{
|
||||
SDL_Rect *clip_rect;
|
||||
@@ -1106,10 +1100,6 @@ int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
/* Clip again */
|
||||
SDL_GetRectIntersection(clip_rect, &final_dst, &final_dst);
|
||||
|
||||
if (dstrect) {
|
||||
*dstrect = final_dst;
|
||||
}
|
||||
|
||||
if (final_dst.w == 0 || final_dst.h == 0 ||
|
||||
final_src.w <= 0 || final_src.h <= 0) {
|
||||
/* No-op. */
|
||||
|
||||
Reference in New Issue
Block a user