shithub: cstory

Download patch

ref: 611afe7417d63d716531f2ba9f6ae4a2d570a6b8
parent: 27b3980a564dde9beb3d77442acf35cc7d80f651
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Sep 14 19:55:39 EDT 2020

Remove those annoying renderer sanity checks

Duplicate junk. If they're that important, they can go in the game,
not the backends.

--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -671,9 +671,6 @@
 
 void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
 {
-	if (surface == NULL)
-		return;
-
 	// Flush the vertex buffer if we're about to destroy its texture
 	if (surface->texture_id == last_source_texture)
 	{
@@ -720,9 +717,6 @@
 
 void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
 {
-	if (source_surface == NULL || destination_surface == NULL)
-		return;
-
 	const RenderMode render_mode = (colour_key ? MODE_DRAW_SURFACE_WITH_TRANSPARENCY : MODE_DRAW_SURFACE);
 
 	// Flush vertex data if a context-change is needed
@@ -800,9 +794,6 @@
 	static unsigned char last_green;
 	static unsigned char last_blue;
 
-	if (surface == NULL)
-		return;
-
 	// Flush vertex data if a context-change is needed
 	if (last_render_mode != MODE_COLOUR_FILL || last_destination_texture != surface->texture_id || last_red != red || last_green != green || last_blue != blue)
 	{
@@ -918,9 +909,6 @@
 	static unsigned char last_green;
 	static unsigned char last_blue;
 
-	if (destination_surface == NULL)
-		return;
-
 	glyph_destination_surface = destination_surface;
 
 	// Flush vertex data if a context-change is needed
@@ -953,9 +941,6 @@
 
 void RenderBackend_DrawGlyph(RenderBackend_GlyphAtlas *atlas, long x, long y, size_t glyph_x, size_t glyph_y, size_t glyph_width, size_t glyph_height)
 {
-	if (glyph_destination_surface == NULL)
-		return;
-
 	// Add data to the vertex queue
 	VertexBufferSlot *vertex_buffer_slot = GetVertexBufferSlot(1);
 
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -122,9 +122,6 @@
 
 void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
 {
-	if (surface == NULL)
-		return;
-
 	SDL_FreeSurface(surface->sdlsurface);
 	free(surface);
 }
@@ -154,9 +151,6 @@
 
 void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
 {
-	if (source_surface == NULL || destination_surface == NULL)
-		return;
-
 	SDL_Rect source_rect;
 	RectToSDLRect(rect, &source_rect);
 
@@ -176,9 +170,6 @@
 
 void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
-	if (surface == NULL)
-		return;
-
 	SDL_Rect destination_rect;
 	RectToSDLRect(rect, &destination_rect);
 
@@ -239,9 +230,6 @@
 
 void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
 {
-	if (destination_surface == NULL)
-		return;
-
 	glyph_destination_sdlsurface = destination_surface->sdlsurface;
 
 	if (SDL_SetSurfaceColorMod(atlas->sdlsurface, red, green, blue) < 0)
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -201,9 +201,6 @@
 
 void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
 {
-	if (surface == NULL)
-		return;
-
 	// Remove from linked list
 	if (surface->next != NULL)
 		surface->next->prev = surface->prev;
@@ -269,9 +266,6 @@
 
 void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
 {
-	if (source_surface == NULL || destination_surface == NULL)
-		return;
-
 	SDL_Rect source_rect;
 	RectToSDLRect(rect, &source_rect);
 
@@ -290,9 +284,6 @@
 
 void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
-	if (surface == NULL)
-		return;
-
 	SDL_Rect sdl_rect;
 	RectToSDLRect(rect, &sdl_rect);
 
@@ -381,9 +372,6 @@
 void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
 {
 	(void)atlas;
-
-	if (destination_surface == NULL)
-		return;
 
 	if (SDL_SetRenderTarget(renderer, destination_surface->texture) < 0)
 		Backend_PrintError("Couldn't set texture as current rendering target: %s", SDL_GetError());
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -88,9 +88,6 @@
 
 void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
 {
-	if (surface == NULL)
-		return;
-
 	free(surface->pixels);
 	free(surface);
 }
@@ -115,9 +112,6 @@
 
 ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
 {
-	if (source_surface == NULL || source_surface->pixels == NULL || destination_surface == NULL || destination_surface->pixels == NULL)
-		return;
-
 	RenderBackend_Rect rect_clamped;
 
 	rect_clamped.left = rect->left;
@@ -197,9 +191,6 @@
 
 ATTRIBUTE_HOT void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
 {
-	if (surface == NULL || surface->pixels == NULL)
-		return;
-
 	RenderBackend_Rect rect_clamped;
 
 	rect_clamped.left = rect->left;
@@ -282,9 +273,6 @@
 void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
 {
 	(void)atlas;
-
-	if (destination_surface == NULL)
-		return;
 
 	glyph_destination_surface = destination_surface;
 
--- a/src/Backends/Rendering/WiiU.cpp
+++ b/src/Backends/Rendering/WiiU.cpp
@@ -515,27 +515,24 @@
 
 void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
 {
-	if (surface != NULL)
+	// Flush the vertex buffer if we're about to destroy its texture
+	if (&surface->texture == last_source_texture)
 	{
-		// Flush the vertex buffer if we're about to destroy its texture
-		if (&surface->texture == last_source_texture)
-		{
-			FlushVertexBuffer();
-			last_source_texture = NULL;
-		}
+		FlushVertexBuffer();
+		last_source_texture = NULL;
+	}
 
-		if (&surface->texture == last_destination_texture)
-		{
-			FlushVertexBuffer();
-			last_destination_texture = NULL;
-		}
+	if (&surface->texture == last_destination_texture)
+	{
+		FlushVertexBuffer();
+		last_destination_texture = NULL;
+	}
 
-		if (surface->render_target)
-			GX2RDestroySurfaceEx(&surface->colour_buffer.surface, (GX2RResourceFlags)0);
+	if (surface->render_target)
+		GX2RDestroySurfaceEx(&surface->colour_buffer.surface, (GX2RResourceFlags)0);
 
-		GX2RDestroySurfaceEx(&surface->texture.surface, (GX2RResourceFlags)0);
-		free(surface);
-	}
+	GX2RDestroySurfaceEx(&surface->texture.surface, (GX2RResourceFlags)0);
+	free(surface);
 }
 
 bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
@@ -582,9 +579,6 @@
 
 void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
 {
-	if (source_surface == NULL || destination_surface == NULL)
-		return;
-
 	const RenderMode render_mode = (colour_key ? MODE_DRAW_SURFACE_WITH_TRANSPARENCY : MODE_DRAW_SURFACE);
 
 	// Flush vertex data if a context-change is needed
@@ -661,9 +655,6 @@
 	static unsigned char last_green;
 	static unsigned char last_blue;
 
-	if (surface == NULL)
-		return;
-
 	// Flush vertex data if a context-change is needed
 	if (last_render_mode != MODE_COLOUR_FILL || last_destination_texture != &surface->texture || last_red != red || last_green != green || last_blue != blue)
 	{
@@ -788,9 +779,6 @@
 	static unsigned char last_red;
 	static unsigned char last_green;
 	static unsigned char last_blue;
-
-	if (destination_surface == NULL)
-		return;
 
 	glyph_destination_surface = destination_surface;