Fixed bug 5304 - add SDL_HasSurfaceRLE() (Thanks Rene Dudfield and Dan Lawrence)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/include/SDL_surface.h b/include/SDL_surface.h
index 2bffb81..d3f8c81 100644
--- a/include/SDL_surface.h
+++ b/include/SDL_surface.h
@@ -238,6 +238,13 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
int flag);
/**
+ * \brief Returns whether the surface is RLE enabled
+ *
+ * \return SDL_TRUE if the surface is RLE enabled, or SDL_FALSE if the surface is NULL or not RLE enabled
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
+
+/**
* \brief Sets the color key (transparent pixel) in a blittable surface.
*
* \param surface The surface to update
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index cd3c41b..2c7d35f 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -767,3 +767,4 @@
#define SDL_SIMDRealloc SDL_SIMDRealloc_REAL
#define SDL_AndroidRequestPermission SDL_AndroidRequestPermission_REAL
#define SDL_OpenURL SDL_OpenURL_REAL
+#define SDL_HasSurfaceRLE SDL_HasSurfaceRLE_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index df87ad2..4ddd57b 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -828,3 +828,4 @@ SDL_DYNAPI_PROC(void*,SDL_SIMDRealloc,(void *a, const size_t b),(a, b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_AndroidRequestPermission,(const char *a),(a),return)
#endif
SDL_DYNAPI_PROC(int,SDL_OpenURL,(const char *a),(a),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_HasSurfaceRLE,(SDL_Surface *a),(a),return)
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index d6409e8..ade68bf 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -249,6 +249,20 @@ SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
return 0;
}
+SDL_bool
+SDL_HasSurfaceRLE(SDL_Surface * surface)
+{
+ if (!surface) {
+ return SDL_FALSE;
+ }
+
+ if (!(surface->map->info.flags & SDL_COPY_RLE_DESIRED)) {
+ return SDL_FALSE;
+ }
+
+ return SDL_TRUE;
+}
+
int
SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
{