[Scummvm-cvs-logs] SF.net SVN: scummvm: [22913] scummvm/trunk/backends/sdl

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Jun 4 14:38:32 CEST 2006


Revision: 22913
Author:   eriktorbjorn
Date:     2006-06-04 05:38:27 -0700 (Sun, 04 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22913&view=rev

Log Message:
-----------
"They sought it with thimbles, they sought it with care;
 They pursued it with forks and hope;
 They threatened its life with a railway-share;
 They charmed it with smiles and soap."

Maybe this time the elusive cursor hotspot bugs will finally be fixed, once
and for all. The blitCursor() function now calculates both the real and the
virtual dimensions of the cursor, since they may both be different from the
original dimensions.

Modified Paths:
--------------
    scummvm/trunk/backends/sdl/graphics.cpp
    scummvm/trunk/backends/sdl/sdl-common.h
Modified: scummvm/trunk/backends/sdl/graphics.cpp
===================================================================
--- scummvm/trunk/backends/sdl/graphics.cpp	2006-06-04 12:30:29 UTC (rev 22912)
+++ scummvm/trunk/backends/sdl/graphics.cpp	2006-06-04 12:38:27 UTC (rev 22913)
@@ -1371,38 +1371,63 @@
 		dstPtr += _mouseOrigSurface->pitch - w * 2;
   	}
 
-	int hW, hH;
+	int rW, rH;
 
 	if (_cursorTargetScale >= _scaleFactor) {
-		hW = w;
-		hH = h;
-		_mouseCurState.hHotX = _mouseCurState.hotX;
-		_mouseCurState.hHotY = _mouseCurState.hotY;
+		// The cursor target scale is greater or equal to the scale at
+		// which the rest of the screen is drawn. We do not downscale
+		// the cursor image, we draw it at its original size. It will
+		// appear too large on screen.
+
+		rW = w;
+		rH = h;
+		_mouseCurState.rHotX = _mouseCurState.hotX;
+		_mouseCurState.rHotY = _mouseCurState.hotY;
+
+		// The virtual dimensions may be larger than the original.
+
+		_mouseCurState.vW = w * _cursorTargetScale / _scaleFactor;
+		_mouseCurState.vH = h * _cursorTargetScale / _scaleFactor;
+		_mouseCurState.vHotX = _mouseCurState.hotX * _cursorTargetScale /
+			_scaleFactor;
+		_mouseCurState.vHotY = _mouseCurState.hotY * _cursorTargetScale /
+			_scaleFactor;
 	} else {
-		hW = w * _scaleFactor / _cursorTargetScale;
-		hH = h * _scaleFactor / _cursorTargetScale;
-		_mouseCurState.hHotX = _mouseCurState.hotX * _scaleFactor /
+		// The cursor target scale is smaller than the scale at which
+		// the rest of the screen is drawn. We scale up the cursor
+		// image to make it appear correct.
+
+		rW = w * _scaleFactor / _cursorTargetScale;
+		rH = h * _scaleFactor / _cursorTargetScale;
+		_mouseCurState.rHotX = _mouseCurState.hotX * _scaleFactor /
 			_cursorTargetScale;
-		_mouseCurState.hHotY = _mouseCurState.hotY * _scaleFactor /
+		_mouseCurState.rHotY = _mouseCurState.hotY * _scaleFactor /
 			_cursorTargetScale;
+
+		// The virtual dimensions will be the same as the original.
+
+		_mouseCurState.vW = w;
+		_mouseCurState.vH = h;
+		_mouseCurState.vHotX = _mouseCurState.hotX;
+		_mouseCurState.vHotY = _mouseCurState.hotY;
   	}
 
-	int hH1 = hH; // store original to pass to aspect-correction function later
+	int rH1 = rH; // store original to pass to aspect-correction function later
 	if (_adjustAspectRatio && _cursorTargetScale == 1) {
-		hH = real2Aspect(hH - 1) + 1;
-		_mouseCurState.hHotY = real2Aspect(_mouseCurState.hHotY);
+		rH = real2Aspect(rH - 1) + 1;
+		_mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY);
 	}
 
-	if (_mouseCurState.hW != hW || _mouseCurState.hH != hH) {
-		_mouseCurState.hW = hW;
-		_mouseCurState.hH = hH;
+	if (_mouseCurState.rW != rW || _mouseCurState.rH != rH) {
+		_mouseCurState.rW = rW;
+		_mouseCurState.rH = rH;
 
 		if (_mouseSurface)
 			SDL_FreeSurface(_mouseSurface);
 
 		_mouseSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
-						_mouseCurState.hW,
-						_mouseCurState.hH,
+						_mouseCurState.rW,
+						_mouseCurState.rH,
 						16,
 						_hwscreen->format->Rmask,
 						_hwscreen->format->Gmask,
@@ -1434,7 +1459,7 @@
 
 #ifndef DISABLE_SCALERS
 	if (_adjustAspectRatio && _cursorTargetScale == 1)
-		cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, hW, hH1, 0, 0, 0);
+		cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0);
 #endif
 
 	SDL_UnlockSurface(_mouseSurface);
@@ -1493,30 +1518,34 @@
 	SDL_Rect dst;
 	int scale;
 	int width, height;
+	int hotX, hotY;
 
+	dst.x = _mouseCurState.x;
+	dst.y = _mouseCurState.y;
+
 	if (!_overlayVisible) {
 		scale = _scaleFactor;
 		width = _screenWidth;
 		height = _screenHeight;
-		dst.x = _mouseCurState.x - _mouseCurState.hotX;
-		dst.y = _mouseCurState.y - _mouseCurState.hotY;
-		dst.w = _mouseCurState.w;
-		dst.h = _mouseCurState.h;
+		dst.w = _mouseCurState.vW;
+		dst.h = _mouseCurState.vH;
+		hotX = _mouseCurState.vHotX;
+		hotY = _mouseCurState.vHotY;
 	} else {
 		scale = 1;
 		width = _overlayWidth;
 		height = _overlayHeight;
-		dst.x = _mouseCurState.x - _mouseCurState.hHotX;
-		dst.y = _mouseCurState.y - _mouseCurState.hHotY;
-		dst.w = _mouseCurState.hW;
-		dst.h = _mouseCurState.hH;
+		dst.w = _mouseCurState.rW;
+		dst.h = _mouseCurState.rH;
+		hotX = _mouseCurState.rHotX;
+		hotY = _mouseCurState.rHotY;
 	}
 
 	// The mouse is undrawn using virtual coordinates, i.e. they may be
 	// scaled and aspect-ratio corrected.
 
-	_mouseBackup.x = dst.x;
-	_mouseBackup.y = dst.y;
+	_mouseBackup.x = dst.x - hotX;
+	_mouseBackup.y = dst.y - hotY;
 	_mouseBackup.w = dst.w;
 	_mouseBackup.h = dst.h;
 
@@ -1530,10 +1559,10 @@
 	if (_adjustAspectRatio && !_overlayVisible)
 		dst.y = real2Aspect(dst.y);
   
-	dst.x *= scale;
-	dst.y *= scale;
-	dst.w = _mouseCurState.hW;
-	dst.h = _mouseCurState.hH;
+	dst.x = scale * dst.x - _mouseCurState.rHotX;
+	dst.y = scale * dst.y - _mouseCurState.rHotY;
+	dst.w = _mouseCurState.rW;
+	dst.h = _mouseCurState.rH;
 
 	// Note that SDL_BlitSurface() and addDirtyRect() will both perform any
 	// clipping necessary

Modified: scummvm/trunk/backends/sdl/sdl-common.h
===================================================================
--- scummvm/trunk/backends/sdl/sdl-common.h	2006-06-04 12:30:29 UTC (rev 22912)
+++ scummvm/trunk/backends/sdl/sdl-common.h	2006-06-04 12:38:27 UTC (rev 22913)
@@ -293,9 +293,27 @@
 	};
 
 	struct MousePos {
-		int16 x, y, w, h, hotX, hotY, hW, hH, hHotX, hHotY;
+		// The mouse position, using either virtual (game) or real
+		// (overlay) coordinates.
+		int16 x, y;
+
+		// The size and hotspot of the original cursor image.
+	    	int16 w, h;
+		int16 hotX, hotY;
+
+		// The size and hotspot of the pre-scaled cursor image, in real
+		// coordinates.
+		int16 rW, rH;
+		int16 rHotX, rHotY;
+
+		// The size and hotspot of the pre-scaled cursor image, in game
+		// coordinates.
+		int16 vW, vH;
+		int16 vHotX, vHotY;
+
 		MousePos() : x(0), y(0), w(0), h(0), hotX(0), hotY(0),
-		             hW(0), hH(0), hHotX(0), hHotY(0)
+		             rW(0), rH(0), rHotX(0), rHotY(0), vW(0), vH(0),
+		             vHotX(0), vHotY(0)
 			{ }
 	};
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list