SDL: surface: Add a private SDL_ReadSurfacePixel

From f5745c3a678fb90c3a9e2bb90a9e882aeb974952 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Mon, 2 Oct 2023 19:45:49 +0100
Subject: [PATCH] surface: Add a private SDL_ReadSurfacePixel

This shares its implementation with SDLTest_ReadSurfacePixel: the same
code is compiled twice, to get it into the static test library and also
the public shared library.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 src/video/SDL_surface.c | 7 +++++++
 src/video/SDL_video_c.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index 4a5d29853a0c..fe43b2f26f32 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -23,6 +23,7 @@
 #include "SDL_sysvideo.h"
 #include "SDL_blit.h"
 #include "SDL_RLEaccel_c.h"
+#include "SDL_surface_pixel_impl.h"
 #include "SDL_pixels_c.h"
 #include "SDL_yuv_c.h"
 #include "../render/SDL_sysrender.h"
@@ -34,6 +35,12 @@ SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
 
 SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32);
 
+int
+SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
+{
+    return SDL_ReadSurfacePixel_impl(surface, x, y, r, g, b, a);
+}
+
 /* Public routines */
 
 /*
diff --git a/src/video/SDL_video_c.h b/src/video/SDL_video_c.h
index 6282e770e453..78f3a3abe992 100644
--- a/src/video/SDL_video_c.h
+++ b/src/video/SDL_video_c.h
@@ -57,4 +57,6 @@ extern void SDL_VideoQuit(void);
 
 extern int SDL_SetWindowTextureVSync(SDL_Window *window, int vsync);
 
+extern int SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
+
 #endif /* SDL_video_c_h_ */