mirror of https://github.com/libsdl-org/SDL
Added SDL_SetSurfaceScaleMode() and SDL_GetSurfaceScaleMode() to control scale mode using SDL_BlitSurfaceScaled()
This commit is contained in:
parent
4d5949dcf6
commit
84a0d5f623
|
@ -30,3 +30,4 @@ General:
|
||||||
* Added SDL_PlayAudioDevice() to start audio playback
|
* Added SDL_PlayAudioDevice() to start audio playback
|
||||||
* Added SDL_ConvertAudioSamples() to convert audio samples from one format to another
|
* Added SDL_ConvertAudioSamples() to convert audio samples from one format to another
|
||||||
* Added the hint SDL_HINT_ANDROID_ALLOW_RECREATE_ACTIVITY to control re-creation of Android SDL activity.
|
* Added the hint SDL_HINT_ANDROID_ALLOW_RECREATE_ACTIVITY to control re-creation of Android SDL activity.
|
||||||
|
* Added SDL_SetSurfaceScaleMode() and SDL_GetSurfaceScaleMode() to control scale mode using SDL_BlitSurfaceScaled()
|
||||||
|
|
|
@ -95,16 +95,6 @@ typedef struct SDL_Vertex
|
||||||
SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
|
SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
|
||||||
} SDL_Vertex;
|
} SDL_Vertex;
|
||||||
|
|
||||||
/**
|
|
||||||
* The scaling mode for a texture.
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
|
|
||||||
SDL_SCALEMODE_LINEAR, /**< linear filtering */
|
|
||||||
SDL_SCALEMODE_BEST /**< anisotropic filtering */
|
|
||||||
} SDL_ScaleMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The access pattern allowed for a texture.
|
* The access pattern allowed for a texture.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -64,6 +64,17 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
|
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The scaling mode
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
|
||||||
|
SDL_SCALEMODE_LINEAR, /**< linear filtering */
|
||||||
|
SDL_SCALEMODE_BEST /**< anisotropic filtering */
|
||||||
|
} SDL_ScaleMode;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of pixels used in software blitting.
|
* A collection of pixels used in software blitting.
|
||||||
*
|
*
|
||||||
|
@ -104,6 +115,8 @@ typedef struct SDL_Surface
|
||||||
/** clipping information */
|
/** clipping information */
|
||||||
SDL_Rect clip_rect; /**< Read-only */
|
SDL_Rect clip_rect; /**< Read-only */
|
||||||
|
|
||||||
|
SDL_ScaleMode scaleMode; /**< The scale mode */
|
||||||
|
|
||||||
/** info for fast blit mapping to other surfaces */
|
/** info for fast blit mapping to other surfaces */
|
||||||
SDL_BlitMap *map; /**< Private */
|
SDL_BlitMap *map; /**< Private */
|
||||||
|
|
||||||
|
@ -903,6 +916,7 @@ extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface *src,
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_BlitSurface
|
* \sa SDL_BlitSurface
|
||||||
|
* \sa SDL_SetSurfaceScaleMode
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled
|
extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled
|
||||||
(SDL_Surface *src, const SDL_Rect *srcrect,
|
(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
|
@ -926,11 +940,42 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_BlitSurfaceScaled
|
* \sa SDL_BlitSurfaceScaled
|
||||||
|
* \sa SDL_SetSurfaceScaleMode
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled
|
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled
|
||||||
(SDL_Surface *src, const SDL_Rect *srcrect,
|
(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect);
|
SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scale mode used for surface scale operations.
|
||||||
|
*
|
||||||
|
* \param surface the surface to update.
|
||||||
|
* \param scaleMode the SDL_ScaleMode to use for scaling.
|
||||||
|
* \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_GetSurfaceScaleMode
|
||||||
|
* \sa SDL_BlitSurfaceScaled
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface *surface, SDL_ScaleMode scaleMode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scale mode used for surface scale operations.
|
||||||
|
*
|
||||||
|
* \param surface the surface to query.
|
||||||
|
* \param scaleMode a pointer filled in with the current scale mode.
|
||||||
|
* \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_SetSurfaceScaleMode
|
||||||
|
* \sa SDL_BlitSurfaceScaled
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface *surface, SDL_ScaleMode *scaleMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the YUV conversion mode
|
* Set the YUV conversion mode
|
||||||
*
|
*
|
||||||
|
|
|
@ -963,6 +963,8 @@ SDL3_0.0.0 {
|
||||||
SDL_strnstr;
|
SDL_strnstr;
|
||||||
SDL_wcsnstr;
|
SDL_wcsnstr;
|
||||||
SDL_SyncWindow;
|
SDL_SyncWindow;
|
||||||
|
SDL_SetSurfaceScaleMode;
|
||||||
|
SDL_GetSurfaceScaleMode;
|
||||||
# extra symbols go here (don't modify this line)
|
# extra symbols go here (don't modify this line)
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|
|
@ -988,3 +988,5 @@
|
||||||
#define SDL_strnstr SDL_strnstr_REAL
|
#define SDL_strnstr SDL_strnstr_REAL
|
||||||
#define SDL_wcsnstr SDL_wcsnstr_REAL
|
#define SDL_wcsnstr SDL_wcsnstr_REAL
|
||||||
#define SDL_SyncWindow SDL_SyncWindow_REAL
|
#define SDL_SyncWindow SDL_SyncWindow_REAL
|
||||||
|
#define SDL_SetSurfaceScaleMode SDL_SetSurfaceScaleMode_REAL
|
||||||
|
#define SDL_GetSurfaceScaleMode SDL_GetSurfaceScaleMode_REAL
|
||||||
|
|
|
@ -1013,3 +1013,5 @@ SDL_DYNAPI_PROC(const char*,SDL_GetTouchDeviceName,(SDL_TouchID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(char*,SDL_strnstr,(const char *a, const char *b, size_t c),(a,b,c),return)
|
SDL_DYNAPI_PROC(char*,SDL_strnstr,(const char *a, const char *b, size_t c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
|
SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return)
|
||||||
|
SDL_DYNAPI_PROC(int,SDL_SetSurfaceScaleMode,(SDL_Surface *a, SDL_ScaleMode b),(a,b),return)
|
||||||
|
SDL_DYNAPI_PROC(int,SDL_GetSurfaceScaleMode,(SDL_Surface *a, SDL_ScaleMode *b),(a,b),return)
|
||||||
|
|
|
@ -776,7 +776,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
int SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst, SDL_Rect *dstrect)
|
SDL_Surface *dst, SDL_Rect *dstrect)
|
||||||
{
|
{
|
||||||
return SDL_PrivateBlitSurfaceScaled(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST);
|
return SDL_PrivateBlitSurfaceScaled(src, srcrect, dst, dstrect, src->scaleMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
|
@ -944,7 +944,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
SDL_Surface *dst, const SDL_Rect *dstrect)
|
SDL_Surface *dst, const SDL_Rect *dstrect)
|
||||||
{
|
{
|
||||||
return SDL_PrivateBlitSurfaceUncheckedScaled(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST);
|
return SDL_PrivateBlitSurfaceUncheckedScaled(src, srcrect, dst, dstrect, src->scaleMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_PrivateBlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
int SDL_PrivateBlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||||
|
@ -1051,6 +1051,38 @@ int SDL_PrivateBlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SDL_SetSurfaceScaleMode(SDL_Surface *surface, SDL_ScaleMode scaleMode)
|
||||||
|
{
|
||||||
|
if (!surface) {
|
||||||
|
return SDL_InvalidParamError("surface");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scaleMode != SDL_SCALEMODE_NEAREST && scaleMode != SDL_SCALEMODE_LINEAR && scaleMode != SDL_SCALEMODE_BEST) {
|
||||||
|
return SDL_InvalidParamError("scaleMode");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scaleMode == SDL_SCALEMODE_NEAREST) {
|
||||||
|
surface->scaleMode = SDL_SCALEMODE_NEAREST;
|
||||||
|
} else {
|
||||||
|
surface->scaleMode = SDL_SCALEMODE_LINEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDL_GetSurfaceScaleMode(SDL_Surface *surface, SDL_ScaleMode *scaleMode)
|
||||||
|
{
|
||||||
|
if (!surface) {
|
||||||
|
return SDL_InvalidParamError("surface");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scaleMode) {
|
||||||
|
*scaleMode = surface->scaleMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock a surface to directly access the pixels
|
* Lock a surface to directly access the pixels
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue