Skip to content

Commit cd52bcb

Browse files
committed
transform.scale: softstretch SDL2/SDL3 compat
1 parent ddc98bd commit cd52bcb

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src_c/_pygame.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474

7575
#define PG_SurfaceHasRLE SDL_SurfaceHasRLE
7676

77+
#define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \
78+
SDL_SoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST)
79+
7780
#else /* ~SDL_VERSION_ATLEAST(3, 0, 0)*/
7881
#define PG_ShowCursor() SDL_ShowCursor(SDL_ENABLE)
7982
#define PG_HideCursor() SDL_ShowCursor(SDL_DISABLE)
@@ -102,6 +105,10 @@
102105
#define PG_ConvertSurface(src, fmt) SDL_ConvertSurface(src, fmt, 0)
103106
#define PG_ConvertSurfaceFormat(src, pixel_format) \
104107
SDL_ConvertSurfaceFormat(src, pixel_format, 0)
108+
109+
#define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \
110+
SDL_SoftStretch(src, srcrect, dst, dstrect)
111+
105112
#if SDL_VERSION_ATLEAST(2, 0, 14)
106113
#define PG_SurfaceHasRLE SDL_HasSurfaceRLE
107114
#else

src_c/transform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ scale_to(pgSurfaceObject *srcobj, pgSurfaceObject *dstobj, int width,
468468
pgSurface_Lock(srcobj);
469469
Py_BEGIN_ALLOW_THREADS;
470470

471-
stretch_result_num = SDL_SoftStretch(src, NULL, modsurf, NULL);
471+
stretch_result_num = PG_SoftStretchNearest(src, NULL, modsurf, NULL);
472472

473473
Py_END_ALLOW_THREADS;
474474
pgSurface_Unlock(srcobj);

0 commit comments

Comments
 (0)