SDL: SDL API renaming: SDL_rect.h

From 58aecf0a5409a7c85300197631d5292ade2d253d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Dec 2022 11:01:11 -0800
Subject: [PATCH] SDL API renaming: SDL_rect.h

Fixes https://github.com/libsdl-org/SDL/issues/6887
---
 docs/README-migration.md                |  20 ++
 include/SDL3/SDL_oldnames.h             |  36 +++
 include/SDL3/SDL_rect.h                 |  80 ++---
 src/dynapi/SDL_dynapi.sym               |  20 +-
 src/dynapi/SDL_dynapi_overrides.h       |  20 +-
 src/dynapi/SDL_dynapi_procs.h           |  20 +-
 src/events/SDL_mouse.c                  |   2 +-
 src/render/SDL_render.c                 |  16 +-
 src/render/metal/SDL_render_metal.m     |   2 +-
 src/render/software/SDL_blendfillrect.c |   4 +-
 src/render/software/SDL_blendline.c     |   4 +-
 src/render/software/SDL_drawline.c      |   4 +-
 src/render/software/SDL_render_sw.c     |   2 +-
 src/render/software/SDL_triangle.c      |   8 +-
 src/test/SDL_test_common.c              |   4 +-
 src/video/SDL_blit.c                    |   2 +-
 src/video/SDL_fillrect.c                |   4 +-
 src/video/SDL_rect.c                    |  24 +-
 src/video/SDL_surface.c                 |   6 +-
 src/video/SDL_video.c                   |   4 +-
 src/video/cocoa/SDL_cocoamouse.m        |   2 +-
 src/video/cocoa/SDL_cocoawindow.m       |   8 +-
 src/video/wayland/SDL_waylandevents.c   |   4 +-
 src/video/wayland/SDL_waylandkeyboard.c |   4 +-
 src/video/wayland/SDL_waylandwindow.c   |   4 +-
 src/video/x11/SDL_x11modes.c            |   2 +-
 src/video/x11/SDL_x11xfixes.c           |   2 +-
 test/testautomation_rect.c              | 382 ++++++++++++------------
 test/testgamepad.c                      |   4 +-
 test/testhittesting.c                   |   2 +-
 test/testintersections.c                |   4 +-
 test/testwm2.c                          |   2 +-
 32 files changed, 379 insertions(+), 323 deletions(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index 309d4a8e6990..e72c90011735 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -379,6 +379,26 @@ The following functions have been renamed:
 
 The preprocessor symbol __MACOSX__ has been renamed __MACOS__, and __IPHONEOS__ has been renamed __IOS__
 
+## SDL_rect.h
+
+The following functions have been renamed:
+* SDL_EncloseFPoints => SDL_GetRectEnclosingPointsF
+* SDL_EnclosePoints => SDL_GetRectEnclosingPoints
+* SDL_FRectEmpty => SDL_IsRectEmptyF
+* SDL_FRectEqualsEpsilon => SDL_AreRectsEqualF
+* SDL_HasIntersection => SDL_HasRectIntersection
+* SDL_HasIntersectionF => SDL_HasRectIntersectionF
+* SDL_IntersectFRect => SDL_GetRectIntersectionF
+* SDL_IntersectFRectAndLine => SDL_GetRectAndLineIntersectionF
+* SDL_IntersectRect => SDL_GetRectIntersection
+* SDL_IntersectRectAndLine => SDL_GetRectAndLineIntersection
+* SDL_PointInFRect => SDL_IsPointInRectF
+* SDL_PointInRect => SDL_IsPointInRect
+* SDL_RectEmpty => SDL_IsRectEmpty
+* SDL_RectEquals => SDL_AreRectsEqual
+* SDL_UnionFRect => SDL_GetRectUnionF
+* SDL_UnionRect => SDL_GetRectUnion
+
 ## SDL_render.h
 
 SDL_GetRenderDriverInfo() has been removed, since most of the information it reported were
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index e5ebadfef1cc..5adc146eff9e 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -269,6 +269,24 @@
 #define __MACOSX__ __MACOS__
 #endif
 
+/* ##SDL_rect.h */
+#define SDL_EncloseFPoints SDL_GetRectEnclosingPointsF
+#define SDL_EnclosePoints SDL_GetRectEnclosingPoints
+#define SDL_FRectEmpty SDL_IsRectEmptyF
+#define SDL_FRectEqualsEpsilon SDL_AreRectsEqualF
+#define SDL_HasIntersection SDL_HasRectIntersection
+#define SDL_HasIntersectionF SDL_HasRectIntersectionF
+#define SDL_IntersectFRect SDL_GetRectIntersectionF
+#define SDL_IntersectFRectAndLine SDL_GetRectAndLineIntersectionF
+#define SDL_IntersectRect SDL_GetRectIntersection
+#define SDL_IntersectRectAndLine SDL_GetRectAndLineIntersection
+#define SDL_PointInFRect SDL_IsPointInRectF
+#define SDL_PointInRect SDL_IsPointInRect
+#define SDL_RectEmpty SDL_IsRectEmpty
+#define SDL_RectEquals SDL_AreRectsEqual
+#define SDL_UnionFRect SDL_GetRectUnionF
+#define SDL_UnionRect SDL_GetRectUnion
+
 /* ##SDL_render.h */
 #define SDL_RenderCopy SDL_RenderTexture
 #define SDL_RenderCopyEx SDL_RenderTextureRotated
@@ -575,6 +593,24 @@
 #define __MACOSX__ __MACOSX___renamed___MACOS__
 #endif
 
+/* ##SDL_rect.h */
+#define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsF
+#define SDL_EnclosePoints SDL_EnclosePoints_renamed_SDL_GetRectEnclosingPoints
+#define SDL_FRectEmpty SDL_FRectEmpty_renamed_SDL_IsRectEmptyF
+#define SDL_FRectEqualsEpsilon SDL_FRectEqualsEpsilon_renamed_SDL_AreRectsEqualF
+#define SDL_HasIntersection SDL_HasIntersection_renamed_SDL_HasRectIntersection
+#define SDL_HasIntersectionF SDL_HasIntersectionF_renamed_SDL_HasRectIntersectionF
+#define SDL_IntersectFRect SDL_IntersectFRect_renamed_SDL_GetRectIntersectionF
+#define SDL_IntersectFRectAndLine SDL_IntersectFRectAndLine_renamed_SDL_GetRectAndLineIntersectionF
+#define SDL_IntersectRect SDL_IntersectRect_renamed_SDL_GetRectIntersection
+#define SDL_IntersectRectAndLine SDL_IntersectRectAndLine_renamed_SDL_GetRectAndLineIntersection
+#define SDL_PointInFRect SDL_PointInFRect_renamed_SDL_IsPointInRectF
+#define SDL_PointInRect SDL_PointInRect_renamed_SDL_IsPointInRect
+#define SDL_RectEmpty SDL_RectEmpty_renamed_SDL_IsRectEmpty
+#define SDL_RectEquals SDL_RectEquals_renamed_SDL_AreRectsEqual
+#define SDL_UnionFRect SDL_UnionFRect_renamed_SDL_GetRectUnionF
+#define SDL_UnionRect SDL_UnionRect_renamed_SDL_GetRectUnion
+
 /* ##SDL_render.h */
 #define SDL_RenderCopy SDL_RenderCopy_renamed_SDL_RenderTexture
 #define SDL_RenderCopyEx SDL_RenderCopyEx_renamed_SDL_RenderTextureRotated
diff --git a/include/SDL3/SDL_rect.h b/include/SDL3/SDL_rect.h
index 2a95d1b83bf4..b66b5dc9ee03 100644
--- a/include/SDL3/SDL_rect.h
+++ b/include/SDL3/SDL_rect.h
@@ -42,8 +42,8 @@ extern "C" {
 /**
  * The structure that defines a point (integer)
  *
- * \sa SDL_EnclosePoints
- * \sa SDL_PointInRect
+ * \sa SDL_GetRectEnclosingPoints
+ * \sa SDL_IsPointInRect
  */
 typedef struct SDL_Point
 {
@@ -54,8 +54,8 @@ typedef struct SDL_Point
 /**
  * The structure that defines a point (floating point)
  *
- * \sa SDL_EncloseFPoints
- * \sa SDL_PointInFRect
+ * \sa SDL_GetRectEnclosingPointsF
+ * \sa SDL_IsPointInRectF
  */
 typedef struct SDL_FPoint
 {
@@ -67,13 +67,13 @@ typedef struct SDL_FPoint
 /**
  * A rectangle, with the origin at the upper left (integer).
  *
- * \sa SDL_RectEmpty
- * \sa SDL_RectEquals
- * \sa SDL_HasIntersection
- * \sa SDL_IntersectRect
- * \sa SDL_IntersectRectAndLine
- * \sa SDL_UnionRect
- * \sa SDL_EnclosePoints
+ * \sa SDL_IsRectEmpty
+ * \sa SDL_AreRectsEqual
+ * \sa SDL_HasRectIntersection
+ * \sa SDL_GetRectIntersection
+ * \sa SDL_GetRectAndLineIntersection
+ * \sa SDL_GetRectUnion
+ * \sa SDL_GetRectEnclosingPoints
  */
 typedef struct SDL_Rect
 {
@@ -85,15 +85,15 @@ typedef struct SDL_Rect
 /**
  * A rectangle, with the origin at the upper left (floating point).
  *
- * \sa SDL_FRectEmpty
+ * \sa SDL_IsRectEmptyF
  * \sa SDL_FRectEquals
- * \sa SDL_FRectEqualsEpsilon
- * \sa SDL_HasIntersectionF
- * \sa SDL_IntersectFRect
- * \sa SDL_IntersectFRectAndLine
- * \sa SDL_UnionFRect
- * \sa SDL_EncloseFPoints
- * \sa SDL_PointInFRect
+ * \sa SDL_AreRectsEqualF
+ * \sa SDL_HasRectIntersectionF
+ * \sa SDL_GetRectIntersectionF
+ * \sa SDL_GetRectAndLineIntersectionF
+ * \sa SDL_GetRectUnionF
+ * \sa SDL_GetRectEnclosingPointsF
+ * \sa SDL_IsPointInRectF
  */
 typedef struct SDL_FRect
 {
@@ -107,7 +107,7 @@ typedef struct SDL_FRect
 /**
  * Returns true if point resides inside a rectangle.
  */
-SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
+SDL_FORCE_INLINE SDL_bool SDL_IsPointInRect(const SDL_Point *p, const SDL_Rect *r)
 {
     return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
              (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
@@ -116,7 +116,7 @@ SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
 /**
  * Returns true if the rectangle has no area.
  */
-SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
+SDL_FORCE_INLINE SDL_bool SDL_IsRectEmpty(const SDL_Rect *r)
 {
     return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
 }
@@ -124,7 +124,7 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
 /**
  * Returns true if the two rectangles are equal.
  */
-SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
+SDL_FORCE_INLINE SDL_bool SDL_AreRectsEqual(const SDL_Rect *a, const SDL_Rect *b)
 {
     return (a && b && (a->x == b->x) && (a->y == b->y) &&
             (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
@@ -141,9 +141,9 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_IntersectRect
+ * \sa SDL_GetRectIntersection
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
+extern DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersection(const SDL_Rect * A,
                                                      const SDL_Rect * B);
 
 /**
@@ -159,9 +159,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_HasIntersection
+ * \sa SDL_HasRectIntersection
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersection(const SDL_Rect * A,
                                                    const SDL_Rect * B,
                                                    SDL_Rect * result);
 
@@ -175,7 +175,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
+extern DECLSPEC void SDLCALL SDL_GetRectUnion(const SDL_Rect * A,
                                            const SDL_Rect * B,
                                            SDL_Rect * result);
 
@@ -196,7 +196,7 @@ extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point * points,
                                                    int count,
                                                    const SDL_Rect * clip,
                                                    SDL_Rect * result);
@@ -219,7 +219,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *
                                                           rect, int *X1,
                                                           int *Y1, int *X2,
                                                           int *Y2);
@@ -230,7 +230,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
 /**
  * Returns true if point resides inside a rectangle.
  */
-SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect *r)
+SDL_FORCE_INLINE SDL_bool SDL_IsPointInRectF(const SDL_FPoint *p, const SDL_FRect *r)
 {
     return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
              (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
@@ -239,7 +239,7 @@ SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect
 /**
  * Returns true if the rectangle has no area.
  */
-SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
+SDL_FORCE_INLINE SDL_bool SDL_IsRectEmptyF(const SDL_FRect *r)
 {
     return ((!r) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? SDL_TRUE : SDL_FALSE;
 }
@@ -249,7 +249,7 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
  *
  * \since This function is available since SDL 2.0.22.
  */
-SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
+SDL_FORCE_INLINE SDL_bool SDL_AreRectsEqualF(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
 {
     return (a && b && ((a == b) ||
             ((SDL_fabsf(a->x - b->x) <= epsilon) &&
@@ -266,7 +266,7 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_F
  */
 SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b)
 {
-    return SDL_FRectEqualsEpsilon(a, b, SDL_FLT_EPSILON);
+    return SDL_AreRectsEqualF(a, b, SDL_FLT_EPSILON);
 }
 
 /**
@@ -280,9 +280,9 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_IntersectRect
+ * \sa SDL_GetRectIntersection
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF(const SDL_FRect * A,
+extern DECLSPEC SDL_bool SDLCALL SDL_HasRectIntersectionF(const SDL_FRect * A,
                                                       const SDL_FRect * B);
 
 /**
@@ -298,9 +298,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF(const SDL_FRect * A,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_HasIntersectionF
+ * \sa SDL_HasRectIntersectionF
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect(const SDL_FRect * A,
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectIntersectionF(const SDL_FRect * A,
                                                     const SDL_FRect * B,
                                                     SDL_FRect * result);
 
@@ -314,7 +314,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect(const SDL_FRect * A,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC void SDLCALL SDL_UnionFRect(const SDL_FRect * A,
+extern DECLSPEC void SDLCALL SDL_GetRectUnionF(const SDL_FRect * A,
                                             const SDL_FRect * B,
                                             SDL_FRect * result);
 
@@ -336,7 +336,7 @@ extern DECLSPEC void SDLCALL SDL_UnionFRect(const SDL_FRect * A,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints(const SDL_FPoint * points,
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectEnclosingPointsF(const SDL_FPoint * points,
                                                     int count,
                                                     const SDL_FRect * clip,
                                                     SDL_FRect * result);
@@ -360,7 +360,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints(const SDL_FPoint * points,
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRectAndLine(const SDL_FRect *
+extern DECLSPEC SDL_bool SDLCALL SDL_GetRectAndLineIntersectionF(const SDL_FRect *
                                                            rect, float *X1,
                                                            float *Y1, float *X2,
                                                            float *Y2);
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 4401a2e8f26a..7f58d9cb7146 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -395,16 +395,16 @@ SDL3_0.0.0 {
     SDL_SetYUVConversionMode;
     SDL_GetYUVConversionMode;
     SDL_GetYUVConversionModeForResolution;
-    SDL_HasIntersection;
-    SDL_IntersectRect;
-    SDL_UnionRect;
-    SDL_EnclosePoints;
-    SDL_IntersectRectAndLine;
-    SDL_HasIntersectionF;
-    SDL_IntersectFRect;
-    SDL_UnionFRect;
-    SDL_EncloseFPoints;
-    SDL_IntersectFRectAndLine;
+    SDL_HasRectIntersection;
+    SDL_GetRectIntersection;
+    SDL_GetRectUnion;
+    SDL_GetRectEnclosingPoints;
+    SDL_GetRectAndLineIntersection;
+    SDL_HasRectIntersectionF;
+    SDL_GetRectIntersectionF;
+    SDL_GetRectUnionF;
+    SDL_GetRectEnclosingPointsF;
+    SDL_GetRectAndLineIntersectionF;
     SDL_CreateShapedWindow;
     SDL_IsShapedWindow;
     SDL_SetWindowShape;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index ea08cb0260f2..7de7a2fc078f 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -277,11 +277,11 @@
 #define SDL_GetRGBA SDL_GetRGBA_REAL
 #define SDL_GetPlatform SDL_GetPlatform_REAL
 #define SDL_GetPowerInfo SDL_GetPowerInfo_REAL
-#define SDL_HasIntersection SDL_HasIntersection_REAL
-#define SDL_IntersectRect SDL_IntersectRect_REAL
-#define SDL_UnionRect SDL_UnionRect_REAL
-#define SDL_EnclosePoints SDL_EnclosePoints_REAL
-#define SDL_IntersectRectAndLine SDL_IntersectRectAndLine_REAL
+#define SDL_HasRectIntersection SDL_HasRectIntersection_REAL
+#define SDL_GetRectIntersection SDL_GetRectIntersection_REAL
+#define SDL_GetRectUnion SDL_GetRectUnion_REAL
+#define SDL_GetRectEnclosingPoints SDL_GetRectEnclosingPoints_REAL
+#define SDL_GetRectAndLineIntersection SDL_GetRectAndLineIntersection_REAL
 #define SDL_GetNumRenderDrivers SDL_GetNumRenderDrivers_REAL
 #define SDL_CreateWindowAndRenderer SDL_CreateWindowAndRenderer_REAL
 #define SDL_CreateRenderer SDL_CreateRenderer_REAL
@@ -828,11 +828,11 @@
 #define SDL_GetTouchName SDL_GetTouchName_REAL
 #define SDL_ClearComposition SDL_ClearComposition_REAL
 #define SDL_IsTextInputShown SDL_IsTextInputShown_REAL
-#define SDL_HasIntersectionF SDL_HasIntersectionF_REAL
-#define SDL_IntersectFRect SDL_IntersectFRect_REAL
-#define SDL_UnionFRect SDL_UnionFRect_REAL
-#define SDL_EncloseFPoints SDL_EncloseFPoints_REAL
-#define SDL_IntersectFRectAndLine SDL_IntersectFRectAndLine_REAL
+#define SDL_HasRectIntersectionF SDL_HasRectIntersectionF_REAL
+#define SDL_GetRectIntersectionF SDL_GetRectIntersectionF_REAL
+#define SDL_GetRectUnionF SDL_GetRectUnionF_REAL
+#define SDL_GetRectEnclosingPointsF SDL_GetRectEnclosingPointsF_REAL
+#define SDL_GetRectAndLineIntersectionF SDL_GetRectAndLineIntersectionF_REAL
 #define SDL_GetRenderWindow SDL_GetRenderWindow_REAL
 #define SDL_bsearch SDL_bsearch_REAL
 #define SDL_GetGamepadPathForIndex SDL_GetGamepadPathForIndex_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index dcbfd98b557b..48bf031fd2e8 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -304,11 +304,11 @@ SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, U
 SDL_DYNAPI_PROC(void,SDL_GetRGBA,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e, Uint8 *f),(a,b,c,d,e,f),)
 SDL_DYNAPI_PROC(const char*,SDL_GetPlatform,(void),(),return)
 SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetPowerInfo,(int *a, int *b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_HasIntersection,(const SDL_Rect *a, const SDL_Rect *b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectRect,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
-SDL_DYNAPI_PROC(void,SDL_UnionRect,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),)
-SDL_DYNAPI_PROC(SDL_bool,SDL_EnclosePoints,(const SDL_Point *a, int b, const SDL_Rect *c, SDL_Rect *d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectRectAndLine,(const SDL_Rect *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_HasRectIntersection,(const SDL_Rect *a, const SDL_Rect *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersection,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
+SDL_DYNAPI_PROC(void,SDL_GetRectUnion,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectEnclosingPoints,(const SDL_Point *a, int b, const SDL_Rect *c, SDL_Rect *d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectAndLineIntersection,(const SDL_Rect *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(int,SDL_GetNumRenderDrivers,(void),(),return)
 SDL_DYNAPI_PROC(int,SDL_CreateWindowAndRenderer,(int a, int b, Uint32 c, SDL_Window **d, SDL_Renderer **e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b, Uint32 c),(a,b,c),return)
@@ -895,11 +895,11 @@ SDL_DYNAPI_PROC(int,SDL_AndroidSendMessage,(Uint32 a, int b),(a,b),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetTouchName,(int a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_ClearComposition,(void),(),)
 SDL_DYNAPI_PROC(SDL_bool,SDL_IsTextInputShown,(void),(),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_HasIntersectionF,(const SDL_FRect *a, const SDL_FRect *b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectFRect,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
-SDL_DYNAPI_PROC(void,SDL_UnionFRect,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),)
-SDL_DYNAPI_PROC(SDL_bool,SDL_EncloseFPoints,(const SDL_FPoint *a, int b, const SDL_FRect *c, SDL_FRect *d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectFRectAndLine,(const SDL_FRect *a, float *b, float *c, float *d, float *e),(a,b,c,d,e),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_HasRectIntersectionF,(const SDL_FRect *a, const SDL_FRect *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersectionF,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
+SDL_DYNAPI_PROC(void,SDL_GetRectUnionF,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectEnclosingPointsF,(const SDL_FPoint *a, int b, const SDL_FRect *c, SDL_FRect *d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectAndLineIntersectionF,(const SDL_FRect *a, float *b, float *c, float *d, float *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(SDL_Window*,SDL_GetRenderWindow,(SDL_Renderer *a),(a),return)
 SDL_DYNAPI_PROC(void*,SDL_bsearch,(const void *a, const void *b, size_t c, size_t d, int (SDLCALL *e)(const void *, const void *)),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetGamepadPathForIndex,(int a),(a),return)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 1b69179be5d9..81a70fe4b875 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -567,7 +567,7 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
             window_rect.y = 0;
             window_rect.w = x_max + 1;
             window_rect.h = y_max + 1;
-            if (SDL_IntersectRect(confine, &window_rect, &mouse_rect)) {
+            if (SDL_GetRectIntersection(confine, &window_rect, &mouse_rect)) {
                 x_min = mouse_rect.x;
                 y_min = mouse_rect.y;
                 x_max = x_min + mouse_rect.w - 1;
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index d9619bda64a9..9a674b24a95a 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1729,7 +1729,7 @@ int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect,
     real_rect.w = texture->w;
     real_rect.h = texture->h;
     if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
+        if (!SDL_GetRectIntersection(rect, &real_rect, &real_rect)) {
             return 0;
         }
     }
@@ -1895,7 +1895,7 @@ int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect,
     real_rect.w = texture->w;
     real_rect.h = texture->h;
     if (rect) {
-        SDL_IntersectRect(rect, &real_rect, &real_rect);
+        SDL_GetRectIntersection(rect, &real_rect, &real_rect);
     }
 
     if (real_rect.w == 0 || real_rect.h == 0) {
@@ -1955,7 +1955,7 @@ int SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
     real_rect.w = texture->w;
     real_rect.h = texture->h;
     if (rect) {
-        SDL_IntersectRect(rect, &real_rect, &real_rect);
+        SDL_GetRectIntersection(rect, &real_rect, &real_rect);
     }
 
     if (real_rect.w == 0 || real_rect.h == 0) {
@@ -2057,7 +2057,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
     real_rect.w = texture->w;
     real_rect.h = texture->h;
     if (rect) {
-        SDL_IntersectRect(rect, &real_rect, &real_rect);
+        SDL_GetRectIntersection(rect, &real_rect, &real_rect);
     }
 
     ret = SDL_LockTexture(texture, &real_rect, &pixels, &pitch);
@@ -3382,14 +3382,14 @@ int SDL_RenderTextureF(SDL_Renderer *renderer, SDL_Texture *texture,
     real_srcrect.w = texture->w;
     real_srcrect.h = texture->h;
     if (srcrect) {
-        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
+        if (!SDL_GetRectIntersection(srcrect, &real_srcrect, &real_srcrect)) {
             return 0;
         }
     }
 
     RenderGetViewportSize(renderer, &real_dstrect);
     if (dstrect) {
-        if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
+        if (!SDL_HasRectIntersectionF(dstrect, &real_dstrect)) {
             return 0;
         }
         real_dstrect = *dstrect;
@@ -3522,7 +3522,7 @@ int SDL_RenderTextureRotatedF(SDL_Renderer *renderer, SDL_Texture *texture,
     real_srcrect.w = texture->w;
     real_srcrect.h = texture->h;
     if (srcrect) {
-        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
+        if (!SDL_GetRectIntersection(srcrect, &real_srcrect, &real_srcrect)) {
             return 0;
         }
     }
@@ -4158,7 +4158,7 @@ int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
     real_rect.w = (int)SDL_floor(renderer->viewport.w);
     real_rect.h = (int)SDL_floor(renderer->viewport.h);
     if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
+        if (!SDL_GetRectIntersection(rect, &real_rect, &real_rect)) {
             return 0;
         }
         if (real_rect.y > rect->y) {
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 5da255a30fe2..f09852423d36 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -1252,7 +1252,7 @@ static SDL_bool SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cm
             METAL_GetOutputSize(renderer, &output.w, &output.h);
         }
 
-        if (SDL_IntersectRect(&output, &clip, &clip)) {
+        if (SDL_GetRectIntersection(&output, &clip, &clip)) {
             MTLScissorRect mtlrect;
             mtlrect.x = clip.x;
             mtlrect.y = clip.y;
diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c
index 60a370ec5d11..716ca24da59d 100644
--- a/src/render/software/SDL_blendfillrect.c
+++ b/src/render/software/SDL_blendfillrect.c
@@ -223,7 +223,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
     /* If 'rect' == NULL, then fill the whole surface */
     if (rect) {
         /* Perform clipping */
-        if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
+        if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
             return 0;
         }
         rect = &clipped;
@@ -335,7 +335,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
 
     for (i = 0; i < count; ++i) {
         /* Perform clipping */
-        if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
+        if (!SDL_GetRectIntersection(&rects[i], &dst->clip_rect, &rect)) {
             continue;
         }
         status = func(dst, &rect, blendMode, r, g, b, a);
diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c
index 0114f33b4470..e82c57f09274 100644
--- a/src/render/software/SDL_blendline.c
+++ b/src/render/software/SDL_blendline.c
@@ -809,7 +809,7 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
 
     /* Perform clipping */
     /* FIXME: We don't actually want to clip, as it may change line slope */
-    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+    if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
         return 0;
     }
 
@@ -843,7 +843,7 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
 
         /* Perform clipping */
         /* FIXME: We don't actually want to clip, as it may change line slope */
-        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+        if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
             continue;
         }
 
diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c
index b543db1d71b7..c161e25f15bf 100644
--- a/src/render/software/SDL_drawline.c
+++ b/src/render/software/SDL_drawline.c
@@ -148,7 +148,7 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
 
     /* Perform clipping */
     /* FIXME: We don't actually want to clip, as it may change line slope */
-    if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+    if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
         return 0;
     }
 
@@ -182,7 +182,7 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
 
         /* Perform clipping */
         /* FIXME: We don't actually want to clip, as it may change line slope */
-        if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
+        if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
             continue;
         }
 
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index b9e648c08884..74b984dad567 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -644,7 +644,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
             clip_rect.y = cliprect->y + viewport->y;
             clip_rect.w = cliprect->w;
             clip_rect.h = cliprect->h;
-            SDL_IntersectRect(viewport, &clip_rect, &clip_rect);
+            SDL_GetRectIntersection(viewport, &clip_rect, &clip_rect);
             SDL_SetSurfaceClipRect(surface, &clip_rect);
         } else {
             SDL_SetSurfaceClipRect(surface, drawstate->viewport);
diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c
index 0aee8d9ad742..32eed85df98c 100644
--- a/src/render/software/SDL_triangle.c
+++ b/src/render/software/SDL_triangle.c
@@ -251,14 +251,14 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
         rect.y = 0;
         rect.w = dst->w;
         rect.h = dst->h;
-        SDL_IntersectRect(&dstrect, &rect, &dstrect);
+        SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
     }
 
     {
         /* Clip triangle with surface clip rect */
         SDL_Rect rect;
         SDL_GetSurfaceClipRect(dst, &rect);
-        SDL_IntersectRect(&dstrect, &rect, &dstrect);
+        SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
     }
 
     if (blend != SDL_BLENDMODE_NONE) {
@@ -547,14 +547,14 @@ int SDL_SW_BlitTriangle(
         rect.w = dst->w;
         rect.h = dst->h;
 
-        SDL_IntersectRect(&dstrect, &rect, &dstrect);
+        SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
     }
 
     {
         /* Clip triangle with surface clip rect */
         SDL_Rect rect;
         SDL_GetSurfaceClipRect(dst, &rect);
-        SDL_IntersectRect(&dstrect, &rect, &dstrect);
+        SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
     }
 
     /* Set destination pointer */
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index cffb19400f5d..64ccb4b23

(Patch may be truncated, please check the link at the top of this post.)