shithub: cstory

Download patch

ref: 7c4a2b5caa3a74a6aa8b8ebc03a0c9fa428d4b2d
parent: f1a85d4d2c24818a54fed36c93aab6011bd48403
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Sep 8 14:53:06 EDT 2020

Lock SDL_Surfaces

--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -149,6 +149,8 @@
 	if (surface == NULL)
 		return NULL;
 
+	SDL_LockSurface(surface->sdlsurface);
+
 	*pitch = surface->sdlsurface->pitch;
 	return (unsigned char*)surface->sdlsurface->pixels;
 }
@@ -155,9 +157,10 @@
 
 void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height)
 {
-	(void)surface;
 	(void)width;
 	(void)height;
+
+	SDL_UnlockSurface(surface->sdlsurface);
 }
 
 void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
@@ -225,6 +228,8 @@
 
 void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height)
 {
+	SDL_LockSurface(atlas->sdlsurface);
+
 	const unsigned char *source_pointer = pixels;
 
 	for (size_t iy = 0; iy < height; ++iy)
@@ -239,6 +244,8 @@
 			*destination_pointer++ = *source_pointer++;
 		}
 	}
+
+	SDL_UnlockSurface(atlas->sdlsurface);
 }
 
 void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)