Maelstrom: Fixed bug setting logical scale on a render target

https://github.com/libsdl-org/Maelstrom/commit/042a2aea45271c2f5f9832da7a19d7bc2cb4a56c

From 042a2aea45271c2f5f9832da7a19d7bc2cb4a56c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 12 Oct 2012 02:21:23 -0700
Subject: [PATCH] Fixed bug setting logical scale on a render target

---
 screenlib/SDL_FrameBuf.cpp | 39 +++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 5a5d6ee8..9fa24b8d 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -224,21 +224,34 @@ FrameBuf:: SetLogicalSize(int w, int h)
 void
 FrameBuf:: SetLogicalScale(float scale)
 {
-	logicalScale = scale;
-
 	int w, h;
-	if (Resizable()) {
-		SDL_GetWindowSize(window, &w, &h);
-	} else {
-		w = Width();
-		h = Height();
-	}
-	if (logicalScale > 0.0f) {
-		w = (int)(w/logicalScale);
-		h = (int)(h/logicalScale);
-		SetLogicalSize(w, h);
+	SDL_Texture *target;
+
+	target = SDL_GetRenderTarget(renderer);
+	if (target) {
+		// This is a temporary scale change
+		SDL_QueryTexture(target, NULL, NULL, &w, &h);
+		if (scale > 0.0f) {
+			w = (int)(w/scale);
+			h = (int)(h/scale);
+		}
+		SDL_RenderSetLogicalSize(renderer, w, h);
 	} else {
-		UpdateWindowSize(w, h);
+		logicalScale = scale;
+
+		if (Resizable()) {
+			SDL_GetWindowSize(window, &w, &h);
+		} else {
+			w = Width();
+			h = Height();
+		}
+		if (logicalScale > 0.0f) {
+			w = (int)(w/logicalScale);
+			h = (int)(h/logicalScale);
+			SetLogicalSize(w, h);
+		} else {
+			UpdateWindowSize(w, h);
+		}
 	}
 }