[Scummvm-git-logs] scummvm master -> 4307156e1c384c4dd4f3c237f252be398061cb4d

csnover csnover at users.noreply.github.com
Mon Oct 16 07:28:30 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4307156e1c SDL: Fix 32bpp cursor scaling in SDL1


Commit: 4307156e1c384c4dd4f3c237f252be398061cb4d
    https://github.com/scummvm/scummvm/commit/4307156e1c384c4dd4f3c237f252be398061cb4d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-10-16T00:27:34-05:00

Commit Message:
SDL: Fix 32bpp cursor scaling in SDL1

The SDL1 loop is not very optimal. Unfortunately all our existing
scalers only work in 16bpp and I don't have time to fix that right
now, so this is fine.

Changed paths:
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index bfc3f0f..56579de 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -1968,8 +1968,50 @@ void SurfaceSdlGraphicsManager::blitCursor() {
 		sizeChanged = true;
 	}
 
-	// 32bpp always blits directly, so no need to do any more work here
 	if (_cursorFormat.bytesPerPixel == 4) {
+		if (_mouseSurface != _mouseOrigSurface) {
+			SDL_FreeSurface(_mouseSurface);
+		}
+
+		if (cursorScale == 1) {
+			_mouseSurface = _mouseOrigSurface;
+			return;
+		}
+
+		SDL_PixelFormat *format = _mouseOrigSurface->format;
+		_mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA,
+											 rW, rH,
+											 format->BitsPerPixel,
+											 format->Rmask,
+											 format->Gmask,
+											 format->Bmask,
+											 format->Amask);
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+		SDL_BlitScaled(_mouseOrigSurface, nullptr, _mouseSurface, nullptr);
+#else
+		SDL_LockSurface(_mouseOrigSurface);
+		SDL_LockSurface(_mouseSurface);
+
+		const byte *src = (const byte *)_mouseOrigSurface->pixels;
+		byte *dst = (byte *)_mouseSurface->pixels;
+		for (int y = 0; y < _mouseOrigSurface->h; ++y) {
+			uint32 *rowDst = (uint32 *)dst;
+			for (int scaleY = 0; scaleY < cursorScale; ++scaleY) {
+				const uint32 *rowSrc = (const uint32 *)src;
+				for (int x = 0; x < _mouseOrigSurface->w; ++x) {
+					for (int scaleX = 0; scaleX < cursorScale; ++scaleX) {
+						*rowDst++ = *rowSrc;
+					}
+					++rowSrc;
+				}
+				dst += _mouseSurface->pitch;
+			}
+			src += _mouseOrigSurface->pitch;
+		}
+
+		SDL_UnlockSurface(_mouseSurface);
+		SDL_UnlockSurface(_mouseOrigSurface);
+#endif
 		return;
 	}
 
@@ -2159,13 +2201,8 @@ void SurfaceSdlGraphicsManager::drawMouse() {
 	// Note that SDL_BlitSurface() and addDirtyRect() will both perform any
 	// clipping necessary
 
-	if (_cursorFormat.bytesPerPixel == 4 && scale != 1) {
-		if (SDL_BlitScaled(_mouseSurface, nullptr, _hwScreen, &dst) != 0)
-			error("SDL_BlitScaled failed: %s", SDL_GetError());
-	} else {
-		if (SDL_BlitSurface(_mouseSurface, nullptr, _hwScreen, &dst) != 0)
-			error("SDL_BlitSurface failed: %s", SDL_GetError());
-	}
+	if (SDL_BlitSurface(_mouseSurface, nullptr, _hwScreen, &dst) != 0)
+		error("SDL_BlitSurface failed: %s", SDL_GetError());
 
 	// The screen will be updated using real surface coordinates, i.e.
 	// they will not be scaled or aspect-ratio corrected.





More information about the Scummvm-git-logs mailing list