mirror of https://github.com/libsdl-org/SDL
Add scaleMode to SDL_SoftStretch(), remove SDL_SoftStretchLinear().
This commit is contained in:
parent
5dba04b29b
commit
ffd82fb7c4
|
@ -2754,3 +2754,13 @@ expression w, i, s;
|
||||||
- SDL_GameControllerGetSteamHandle
|
- SDL_GameControllerGetSteamHandle
|
||||||
+ SDL_GetGamepadSteamHandle
|
+ SDL_GetGamepadSteamHandle
|
||||||
(...)
|
(...)
|
||||||
|
@@
|
||||||
|
expression e1, e2, e3, e4;
|
||||||
|
@@
|
||||||
|
- SDL_SoftStretch(e1, e2, e3, e4)
|
||||||
|
+ SDL_SoftStretch(e1, e2, e3, e4, SDL_SCALEMODE_NEAREST)
|
||||||
|
@@
|
||||||
|
expression e1, e2, e3, e4;
|
||||||
|
@@
|
||||||
|
- SDL_SoftStretchLinear(e1, e2, e3, e4)
|
||||||
|
+ SDL_SoftStretch(e1, e2, e3, e4, SDL_SCALEMODE_LINEAR)
|
||||||
|
|
|
@ -1160,6 +1160,8 @@ But if you're migrating your code which uses masks, you probably have a format i
|
||||||
|
|
||||||
SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale paramater.
|
SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale paramater.
|
||||||
|
|
||||||
|
SDL_SoftStretch() now takes a scale paramater.
|
||||||
|
|
||||||
The following functions have been renamed:
|
The following functions have been renamed:
|
||||||
* SDL_FillRect() => SDL_FillSurfaceRect()
|
* SDL_FillRect() => SDL_FillSurfaceRect()
|
||||||
* SDL_FillRects() => SDL_FillSurfaceRects()
|
* SDL_FillRects() => SDL_FillSurfaceRects()
|
||||||
|
@ -1175,6 +1177,9 @@ The following functions have been renamed:
|
||||||
* SDL_UpperBlit() => SDL_BlitSurface()
|
* SDL_UpperBlit() => SDL_BlitSurface()
|
||||||
* SDL_UpperBlitScaled() => SDL_BlitSurfaceScaled()
|
* SDL_UpperBlitScaled() => SDL_BlitSurfaceScaled()
|
||||||
|
|
||||||
|
The following functions have been removed:
|
||||||
|
* SDL_SoftStretchLinear() - use SDL_SoftStretch() with SDL_SCALEMODE_LINEAR
|
||||||
|
|
||||||
## SDL_system.h
|
## SDL_system.h
|
||||||
|
|
||||||
SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.
|
SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.
|
||||||
|
|
|
@ -861,8 +861,10 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect);
|
SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a fast, low quality, stretch blit between two surfaces of the same
|
* Perform stretch blit between two surfaces of the same format.
|
||||||
* format.
|
*
|
||||||
|
* Using SDL_SCALEMODE_NEAREST: fast, low quality.
|
||||||
|
* Using SDL_SCALEMODE_LINEAR: bilinear scaling, slower, better quality, only 32BPP.
|
||||||
*
|
*
|
||||||
* \param src the SDL_Surface structure to be copied from
|
* \param src the SDL_Surface structure to be copied from
|
||||||
* \param srcrect the SDL_Rect structure representing the rectangle to be
|
* \param srcrect the SDL_Rect structure representing the rectangle to be
|
||||||
|
@ -870,6 +872,7 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
|
||||||
* \param dst the SDL_Surface structure that is the blit target
|
* \param dst the SDL_Surface structure that is the blit target
|
||||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
||||||
* the destination surface
|
* the destination surface
|
||||||
|
* \param scaleMode scale algorithm to be used
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
|
@ -880,29 +883,8 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
|
||||||
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src,
|
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src,
|
||||||
const SDL_Rect *srcrect,
|
const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst,
|
SDL_Surface *dst,
|
||||||
const SDL_Rect *dstrect);
|
const SDL_Rect *dstrect,
|
||||||
|
SDL_ScaleMode scaleMode);
|
||||||
/**
|
|
||||||
* Perform bilinear scaling between two surfaces of the same format, 32BPP.
|
|
||||||
*
|
|
||||||
* \param src the SDL_Surface structure to be copied from
|
|
||||||
* \param srcrect the SDL_Rect structure representing the rectangle to be
|
|
||||||
* copied
|
|
||||||
* \param dst the SDL_Surface structure that is the blit target
|
|
||||||
* \param dstrect the SDL_Rect structure representing the target rectangle in
|
|
||||||
* the destination surface
|
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
|
||||||
* SDL_GetError() for more information.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 3.0.0.
|
|
||||||
*
|
|
||||||
* \sa SDL_BlitSurfaceScaled
|
|
||||||
*/
|
|
||||||
extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface *src,
|
|
||||||
const SDL_Rect *srcrect,
|
|
||||||
SDL_Surface *dst,
|
|
||||||
const SDL_Rect *dstrect);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a scaled surface copy to a destination surface.
|
* Perform a scaled surface copy to a destination surface.
|
||||||
|
|
|
@ -613,7 +613,6 @@ SDL3_0.0.0 {
|
||||||
SDL_ShowWindow;
|
SDL_ShowWindow;
|
||||||
SDL_SignalCondition;
|
SDL_SignalCondition;
|
||||||
SDL_SoftStretch;
|
SDL_SoftStretch;
|
||||||
SDL_SoftStretchLinear;
|
|
||||||
SDL_StartTextInput;
|
SDL_StartTextInput;
|
||||||
SDL_StopTextInput;
|
SDL_StopTextInput;
|
||||||
SDL_SurfaceHasColorKey;
|
SDL_SurfaceHasColorKey;
|
||||||
|
|
|
@ -636,7 +636,6 @@
|
||||||
#define SDL_ShowWindow SDL_ShowWindow_REAL
|
#define SDL_ShowWindow SDL_ShowWindow_REAL
|
||||||
#define SDL_SignalCondition SDL_SignalCondition_REAL
|
#define SDL_SignalCondition SDL_SignalCondition_REAL
|
||||||
#define SDL_SoftStretch SDL_SoftStretch_REAL
|
#define SDL_SoftStretch SDL_SoftStretch_REAL
|
||||||
#define SDL_SoftStretchLinear SDL_SoftStretchLinear_REAL
|
|
||||||
#define SDL_StartTextInput SDL_StartTextInput_REAL
|
#define SDL_StartTextInput SDL_StartTextInput_REAL
|
||||||
#define SDL_StopTextInput SDL_StopTextInput_REAL
|
#define SDL_StopTextInput SDL_StopTextInput_REAL
|
||||||
#define SDL_SurfaceHasColorKey SDL_SurfaceHasColorKey_REAL
|
#define SDL_SurfaceHasColorKey SDL_SurfaceHasColorKey_REAL
|
||||||
|
|
|
@ -677,8 +677,7 @@ SDL_DYNAPI_PROC(int,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,
|
||||||
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(Uint32 a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
|
SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(Uint32 a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
SDL_DYNAPI_PROC(int,SDL_SoftStretch,(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_SoftStretchLinear,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
|
||||||
SDL_DYNAPI_PROC(void,SDL_StartTextInput,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_StartTextInput,(void),(),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_StopTextInput,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_StopTextInput,(void),(),)
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasColorKey,(SDL_Surface *a),(a),return)
|
SDL_DYNAPI_PROC(SDL_bool,SDL_SurfaceHasColorKey,(SDL_Surface *a),(a),return)
|
||||||
|
|
|
@ -382,7 +382,7 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||||
}
|
}
|
||||||
if (stretch) {
|
if (stretch) {
|
||||||
SDL_Rect rect = *srcrect;
|
SDL_Rect rect = *srcrect;
|
||||||
SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL);
|
SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL, SDL_SCALEMODE_NEAREST);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,10 @@
|
||||||
|
|
||||||
static int SDL_LowerSoftStretchNearest(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_LowerSoftStretchLinear(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);
|
|
||||||
|
|
||||||
int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect)
|
SDL_Surface *dst, const SDL_Rect *dstrect,
|
||||||
{
|
SDL_ScaleMode scaleMode)
|
||||||
return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST);
|
|
||||||
}
|
|
||||||
|
|
||||||
int SDL_SoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect,
|
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect)
|
|
||||||
{
|
|
||||||
return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_LINEAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int src_locked;
|
int src_locked;
|
||||||
|
@ -47,11 +35,20 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Rect full_src;
|
SDL_Rect full_src;
|
||||||
SDL_Rect full_dst;
|
SDL_Rect full_dst;
|
||||||
|
|
||||||
|
|
||||||
if (src->format->format != dst->format->format) {
|
if (src->format->format != dst->format->format) {
|
||||||
return SDL_SetError("Only works with same format surfaces");
|
return SDL_SetError("Only works with same format surfaces");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scaleMode != SDL_SCALEMODE_NEAREST && scaleMode != SDL_SCALEMODE_LINEAR && scaleMode != SDL_SCALEMODE_BEST) {
|
||||||
|
return SDL_InvalidParamError("scaleMode");
|
||||||
|
}
|
||||||
|
|
||||||
if (scaleMode != SDL_SCALEMODE_NEAREST) {
|
if (scaleMode != SDL_SCALEMODE_NEAREST) {
|
||||||
|
scaleMode = SDL_SCALEMODE_LINEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scaleMode == SDL_SCALEMODE_LINEAR) {
|
||||||
if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
|
if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||||
return SDL_SetError("Wrong format");
|
return SDL_SetError("Wrong format");
|
||||||
}
|
}
|
||||||
|
|
|
@ -974,7 +974,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
if (!(src->map->info.flags & complex_copy_flags) &&
|
if (!(src->map->info.flags & complex_copy_flags) &&
|
||||||
src->format->format == dst->format->format &&
|
src->format->format == dst->format->format &&
|
||||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format)) {
|
!SDL_ISPIXELFORMAT_INDEXED(src->format->format)) {
|
||||||
return SDL_SoftStretch(src, srcrect, dst, dstrect);
|
return SDL_SoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST);
|
||||||
} else {
|
} else {
|
||||||
return SDL_BlitSurfaceUnchecked(src, srcrect, dst, dstrect);
|
return SDL_BlitSurfaceUnchecked(src, srcrect, dst, dstrect);
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
src->format->BytesPerPixel == 4 &&
|
src->format->BytesPerPixel == 4 &&
|
||||||
src->format->format != SDL_PIXELFORMAT_ARGB2101010) {
|
src->format->format != SDL_PIXELFORMAT_ARGB2101010) {
|
||||||
/* fast path */
|
/* fast path */
|
||||||
return SDL_SoftStretchLinear(src, srcrect, dst, dstrect);
|
return SDL_SoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_LINEAR);
|
||||||
} else {
|
} else {
|
||||||
/* Use intermediate surface(s) */
|
/* Use intermediate surface(s) */
|
||||||
SDL_Surface *tmp1 = NULL;
|
SDL_Surface *tmp1 = NULL;
|
||||||
|
@ -1035,7 +1035,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
if (is_complex_copy_flags || src->format->format != dst->format->format) {
|
if (is_complex_copy_flags || src->format->format != dst->format->format) {
|
||||||
SDL_Rect tmprect;
|
SDL_Rect tmprect;
|
||||||
SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format->format);
|
SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format->format);
|
||||||
SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
|
SDL_SoftStretch(src, &srcrect2, tmp2, NULL, SDL_SCALEMODE_LINEAR);
|
||||||
|
|
||||||
SDL_SetSurfaceColorMod(tmp2, r, g, b);
|
SDL_SetSurfaceColorMod(tmp2, r, g, b);
|
||||||
SDL_SetSurfaceAlphaMod(tmp2, alpha);
|
SDL_SetSurfaceAlphaMod(tmp2, alpha);
|
||||||
|
@ -1048,7 +1048,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
ret = SDL_BlitSurfaceUnchecked(tmp2, &tmprect, dst, dstrect);
|
ret = SDL_BlitSurfaceUnchecked(tmp2, &tmprect, dst, dstrect);
|
||||||
SDL_DestroySurface(tmp2);
|
SDL_DestroySurface(tmp2);
|
||||||
} else {
|
} else {
|
||||||
ret = SDL_SoftStretchLinear(src, &srcrect2, dst, dstrect);
|
ret = SDL_SoftStretch(src, &srcrect2, dst, dstrect, SDL_SCALEMODE_LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroySurface(tmp1);
|
SDL_DestroySurface(tmp1);
|
||||||
|
|
Loading…
Reference in New Issue