mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
SDL_SoftStretch: add a check for input pixel format
and function re-naming
This commit is contained in:
parent
b5f0483cb3
commit
2127ed2574
@ -197,8 +197,8 @@ copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_SoftStretchLowerNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
static int SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
static int SDL_SoftStretchLowerLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
static int SDL_LowerSoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
static int SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
static int SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||||
|
|
||||||
/* Perform a stretch blit between two surfaces of the same format.
|
/* Perform a stretch blit between two surfaces of the same format.
|
||||||
@ -232,6 +232,12 @@ SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||||||
return SDL_SetError("Only works with same format surfaces");
|
return SDL_SetError("Only works with same format surfaces");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scaleMode != SDL_ScaleModeNearest) {
|
||||||
|
if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||||
|
return SDL_SetError("Wrong format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Verify the blit rectangles */
|
/* Verify the blit rectangles */
|
||||||
if (srcrect) {
|
if (srcrect) {
|
||||||
if ((srcrect->x < 0) || (srcrect->y < 0) ||
|
if ((srcrect->x < 0) || (srcrect->y < 0) ||
|
||||||
@ -285,9 +291,9 @@ SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scaleMode == SDL_ScaleModeNearest) {
|
if (scaleMode == SDL_ScaleModeNearest) {
|
||||||
ret = SDL_SoftStretchLowerNearest(src, srcrect, dst, dstrect);
|
ret = SDL_LowerSoftStretchNearest(src, srcrect, dst, dstrect);
|
||||||
} else {
|
} else {
|
||||||
ret = SDL_SoftStretchLowerLinear(src, srcrect, dst, dstrect);
|
ret = SDL_LowerSoftStretchLinear(src, srcrect, dst, dstrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to unlock the surfaces if they're locked */
|
/* We need to unlock the surfaces if they're locked */
|
||||||
@ -303,7 +309,7 @@ SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SoftStretchLowerNearest(SDL_Surface *src, const SDL_Rect *srcrect,
|
SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect)
|
SDL_Surface *dst, const SDL_Rect *dstrect)
|
||||||
{
|
{
|
||||||
int pos, inc;
|
int pos, inc;
|
||||||
@ -1066,7 +1072,7 @@ scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *d
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SoftStretchLowerLinear(SDL_Surface *s, const SDL_Rect *srcrect,
|
SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *d, const SDL_Rect *dstrect)
|
SDL_Surface *d, const SDL_Rect *dstrect)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user