shithub: cstory

Download patch

ref: 85f58d7d39bc0fd1b76d6ac34ab56e2e4bbf7b1f
parent: 2b86db32a04b9f214566b09944bc0f84fd5e1ddd
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Aug 10 15:50:10 EDT 2019

Rendering backend API naming improvements

--- a/src/Backends/Rendering.h
+++ b/src/Backends/Rendering.h
@@ -20,17 +20,17 @@
 void Backend_DrawScreen(void);
 Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
 void Backend_FreeSurface(Backend_Surface *surface);
-unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch);
-void Backend_Unlock(Backend_Surface *surface);
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y);
+unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch);
+void Backend_UnlockSurface(Backend_Surface *surface);
+void Backend_BlitToSurface(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y);
 void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key);
-void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
+void Backend_ColourFillToSurface(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
 void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
 void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect);
 BOOL Backend_SupportsSubpixelGlyph(void);
 Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch, unsigned char pixel_mode);
 void Backend_UnloadGlyph(Backend_Glyph *glyph);
-void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours);
+void Backend_DrawGlyphToSurface(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours);
 void Backend_DrawGlyphToScreen(Backend_Glyph *glyph, long x, long y, const unsigned char *colours);
 void Backend_HandleDeviceLoss(void);
 void Backend_HandleWindowResize(void);
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -463,7 +463,7 @@
 	free(surface);
 }
 
-unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch)
+unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch)
 {
 	if (surface == NULL)
 		return NULL;
@@ -473,7 +473,7 @@
 	return surface->pixels;
 }
 
-void Backend_Unlock(Backend_Surface *surface)
+void Backend_UnlockSurface(Backend_Surface *surface)
 {
 	if (surface == NULL)
 		return;
@@ -565,7 +565,7 @@
 	vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
+void Backend_BlitToSurface(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
 	BlitCommon(source_surface, rect, destination_surface, x, y, TRUE);
 }
@@ -636,7 +636,7 @@
 	vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
 }
 
-void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
+void Backend_ColourFillToSurface(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
 	ColourFillCommon(surface, rect, red, green, blue);
 }
@@ -811,7 +811,7 @@
 	vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
 }
 
-void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
+void Backend_DrawGlyphToSurface(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
 	DrawGlyphCommon(surface, glyph, x, y, colours);
 }
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -95,7 +95,7 @@
 	free(surface);
 }
 
-unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch)
+unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch)
 {
 	if (surface == NULL)
 		return NULL;
@@ -104,7 +104,7 @@
 	return (unsigned char*)surface->sdl_surface->pixels;
 }
 
-void Backend_Unlock(Backend_Surface *surface)
+void Backend_UnlockSurface(Backend_Surface *surface)
 {
 	(void)surface;
 }
@@ -128,7 +128,7 @@
 	SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect);
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
+void Backend_BlitToSurface(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
 	BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
 }
@@ -138,7 +138,7 @@
 	BlitCommon(source_surface, rect, &framebuffer, x, y, colour_key);
 }
 
-void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
+void Backend_ColourFillToSurface(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
 	if (surface == NULL)
 		return;
@@ -230,7 +230,7 @@
 	free(glyph);
 }
 
-void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
+void Backend_DrawGlyphToSurface(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
 	if (glyph == NULL || surface == NULL)
 		return;
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -176,7 +176,7 @@
 	free(surface);
 }
 
-unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch)
+unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch)
 {
 	if (surface == NULL)
 		return NULL;
@@ -185,7 +185,7 @@
 	return (unsigned char*)surface->sdl_surface->pixels;
 }
 
-void Backend_Unlock(Backend_Surface *surface)
+void Backend_UnlockSurface(Backend_Surface *surface)
 {
 	if (surface == NULL)
 		return;
@@ -193,7 +193,7 @@
 	surface->needs_syncing = TRUE;
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
+void Backend_BlitToSurface(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
 	if (source_surface == NULL || destination_surface == NULL)
 		return;
@@ -241,7 +241,7 @@
 	SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect);
 }
 
-void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
+void Backend_ColourFillToSurface(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
 	if (surface == NULL)
 		return;
@@ -334,7 +334,7 @@
 	}
 
 	unsigned int surface_pitch;
-	unsigned char *surface_pixels = Backend_Lock(glyph->surface, &surface_pitch);
+	unsigned char *surface_pixels = Backend_LockSurface(glyph->surface, &surface_pitch);
 
 	switch (pixel_mode)
 	{
@@ -375,7 +375,7 @@
 			break;
 	}
 
-	Backend_Unlock(glyph->surface);
+	Backend_UnlockSurface(glyph->surface);
 
 	return glyph;
 }
@@ -389,7 +389,7 @@
 	free(glyph);
 }
 
-void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
+void Backend_DrawGlyphToSurface(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
 	// The SDL_Texture side of things uses alpha, not a colour-key, so the bug where the font is blended
 	// with the colour key doesn't occur. SDL_Textures don't support colour-keys, so the next best thing
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -101,7 +101,7 @@
 	free(surface);
 }
 
-unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch)
+unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch)
 {
 	if (surface == NULL)
 		return NULL;
@@ -110,7 +110,7 @@
 	return surface->pixels;
 }
 
-void Backend_Unlock(Backend_Surface *surface)
+void Backend_UnlockSurface(Backend_Surface *surface)
 {
 	(void)surface;
 }
@@ -198,7 +198,7 @@
 	}
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
+void Backend_BlitToSurface(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
 	BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
 }
@@ -208,7 +208,7 @@
 	BlitCommon(source_surface, rect, &framebuffer, x, y, colour_key);
 }
 
-void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
+void Backend_ColourFillToSurface(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
 	if (surface == NULL)
 		return;
@@ -268,7 +268,7 @@
 
 void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
-	Backend_ColourFill(&framebuffer, rect, red, green, blue);
+	Backend_ColourFillToSurface(&framebuffer, rect, red, green, blue);
 }
 
 void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect)
@@ -352,7 +352,7 @@
 	free(glyph);
 }
 
-void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
+void Backend_DrawGlyphToSurface(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
 	if (glyph == NULL || surface == NULL)
 		return;
@@ -421,7 +421,7 @@
 
 void Backend_DrawGlyphToScreen(Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
-	Backend_DrawGlyph(&framebuffer, glyph, x, y, colours);
+	Backend_DrawGlyphToSurface(&framebuffer, glyph, x, y, colours);
 }
 
 void Backend_HandleDeviceLoss(void)
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -217,7 +217,7 @@
 					{
 						// IF YOU WANT TO ADD HD SPRITES, THIS IS THE CODE YOU SHOULD EDIT
 						unsigned int pitch;
-						unsigned char *pixels = Backend_Lock(surf[surf_no].backend, &pitch);
+						unsigned char *pixels = Backend_LockSurface(surf[surf_no].backend, &pitch);
 
 						if (magnification == 1)
 						{
@@ -258,7 +258,7 @@
 							}
 						}
 
-						Backend_Unlock(surf[surf_no].backend);
+						Backend_UnlockSurface(surf[surf_no].backend);
 						SDL_FreeSurface(converted_surface);
 						success = TRUE;
 					}
@@ -421,7 +421,7 @@
 	RECT frameRect;
 	ScaleRect(rect, &frameRect);
 
-	Backend_Blit(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification);
+	Backend_BlitToSurface(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification);
 }
 
 unsigned long GetCortBoxColor(unsigned long col)
@@ -456,7 +456,7 @@
 	const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
 	const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
 
-	Backend_ColourFill(surf[surf_no].backend, &destRect, col_red, col_green, col_blue);
+	Backend_ColourFillToSurface(surf[surf_no].backend, &destRect, col_red, col_green, col_blue);
 }
 
 #ifdef WINDOWS
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1156,7 +1156,7 @@
 				if (glyph->backend)
 				{
 					if (surface)
-						Backend_DrawGlyph(surface, glyph->backend, letter_x, letter_y, colours);
+						Backend_DrawGlyphToSurface(surface, glyph->backend, letter_x, letter_y, colours);
 					else
 						Backend_DrawGlyphToScreen(glyph->backend, letter_x, letter_y, colours);
 				}