shithub: cstory

Download patch

ref: 2b86db32a04b9f214566b09944bc0f84fd5e1ddd
parent: 64f2a78279e01e4178e7af4700e0240406c51221
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Aug 10 15:31:45 EDT 2019

Backend_Blit always uses a colour key

--- a/src/Backends/Rendering.h
+++ b/src/Backends/Rendering.h
@@ -22,7 +22,7 @@
 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, BOOL colour_key);
+void Backend_Blit(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_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -565,9 +565,9 @@
 	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, BOOL colour_key)
+void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
-	BlitCommon(source_surface, rect, destination_surface, x, y, colour_key);
+	BlitCommon(source_surface, rect, destination_surface, x, y, TRUE);
 }
 
 void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -109,7 +109,7 @@
 	(void)surface;
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
+static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
 {
 	if (source_surface == NULL || destination_surface == NULL)
 		return;
@@ -128,9 +128,14 @@
 	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)
+{
+	BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
+}
+
 void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
 {
-	Backend_Blit(source_surface, rect, &framebuffer, x, y, colour_key);
+	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)
@@ -151,7 +156,7 @@
 
 void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect)
 {
-	Backend_Blit(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
+	BlitCommon(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
 }
 
 BOOL Backend_SupportsSubpixelGlyph(void)
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -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, BOOL colour_key)
+void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
 {
 	if (source_surface == NULL || destination_surface == NULL)
 		return;
@@ -210,11 +210,11 @@
 	SDL_Rect destination_rect = {(int)x, (int)y, source_rect.w, source_rect.h};
 
 	// Blit the surface
-	SDL_SetSurfaceBlendMode(source_surface->sdl_surface, colour_key ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE);
+	SDL_SetSurfaceBlendMode(source_surface->sdl_surface, SDL_BLENDMODE_BLEND);
 	SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect);
 
 	// Now blit the texture
-	SDL_SetTextureBlendMode(source_surface->texture, colour_key ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE);
+	SDL_SetTextureBlendMode(source_surface->texture, SDL_BLENDMODE_BLEND);
 	SDL_SetRenderTarget(renderer, destination_surface->texture);
 	SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect);
 	SDL_SetRenderTarget(renderer, screen_texture);
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -115,7 +115,7 @@
 	(void)surface;
 }
 
-void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
+static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
 {
 	if (source_surface == NULL || destination_surface == NULL)
 		return;
@@ -198,9 +198,14 @@
 	}
 }
 
+void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
+{
+	BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
+}
+
 void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
 {
-	Backend_Blit(source_surface, rect, &framebuffer, x, y, colour_key);
+	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)
@@ -268,7 +273,7 @@
 
 void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect)
 {
-	Backend_Blit(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
+	BlitCommon(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
 }
 
 BOOL Backend_SupportsSubpixelGlyph(void)
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -421,7 +421,7 @@
 	RECT frameRect;
 	ScaleRect(rect, &frameRect);
 
-	Backend_Blit(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification, TRUE);
+	Backend_Blit(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification);
 }
 
 unsigned long GetCortBoxColor(unsigned long col)