[Scummvm-git-logs] scummvm master -> f55227752027cfa54b8b960b80e850121be45779

fracturehill noreply at scummvm.org
Mon Nov 20 23:09:27 UTC 2023


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

Summary:
76132f19e3 NANCY: Reduce calls to replaceCursor()
e26b8a50a4 NANCY: Fix mouse warping in TVD during conversations
f552277520 NANCY: Slightly optimize drawing


Commit: 76132f19e30f21262d93e6b8c464148286da7828
    https://github.com/scummvm/scummvm/commit/76132f19e30f21262d93e6b8c464148286da7828
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-11-21T01:05:48+02:00

Commit Message:
NANCY: Reduce calls to replaceCursor()

The game cursor was previously being replaced on every
frame; now, we only replace it when a new one is needed.

Changed paths:
    engines/nancy/cursor.cpp
    engines/nancy/cursor.h


diff --git a/engines/nancy/cursor.cpp b/engines/nancy/cursor.cpp
index c9999200b03..2032ba604ed 100644
--- a/engines/nancy/cursor.cpp
+++ b/engines/nancy/cursor.cpp
@@ -35,6 +35,7 @@ CursorManager::CursorManager()  :
 	_curItemID(-1),
 	_curCursorType(kNormal),
 	_curCursorID(0),
+	_lastCursorID(0),
 	_hasItem(false),
 	_numCursorTypes(0),
 	_puzzleExitCursor((g_nancy->getGameType() >= kGameTypeNancy4) ? kMoveBackward : kExit),
@@ -275,24 +276,28 @@ void CursorManager::warpCursor(const Common::Point &pos) {
 }
 
 void CursorManager::applyCursor() {
-	Graphics::ManagedSurface *surf;
-	Common::Rect bounds = _cursors[_curCursorID].bounds;
-	Common::Point hotspot = _cursors[_curCursorID].hotspot;
+	if (_curCursorID != _lastCursorID) {
+		Graphics::ManagedSurface *surf;
+		Common::Rect bounds = _cursors[_curCursorID].bounds;
+		Common::Point hotspot = _cursors[_curCursorID].hotspot;
 
-	if (_hasItem) {
-		surf = &_invCursorsSurface;
+		if (_hasItem) {
+			surf = &_invCursorsSurface;
 
-	} else {
-		surf = &g_nancy->_graphicsManager->_object0;
-	}
+		} else {
+			surf = &g_nancy->_graphicsManager->_object0;
+		}
 
-	Graphics::ManagedSurface temp(*surf, bounds);
+		Graphics::ManagedSurface temp(*surf, bounds);
 
-	CursorMan.replaceCursor(temp, hotspot.x, hotspot.y, g_nancy->_graphicsManager->getTransColor(), false);
-	if (g_nancy->getGameType() == kGameTypeVampire) {
-		byte palette[3 * 256];
-		surf->grabPalette(palette, 0, 256);
-		CursorMan.replaceCursorPalette(palette, 0, 256);
+		CursorMan.replaceCursor(temp, hotspot.x, hotspot.y, g_nancy->_graphicsManager->getTransColor(), false);
+		if (g_nancy->getGameType() == kGameTypeVampire) {
+			byte palette[3 * 256];
+			surf->grabPalette(palette, 0, 256);
+			CursorMan.replaceCursorPalette(palette, 0, 256);
+		}
+
+		_lastCursorID = _curCursorID;
 	}
 
 	if (_warpedMousePos.x != -500 && _warpedMousePos.y != -500) {
diff --git a/engines/nancy/cursor.h b/engines/nancy/cursor.h
index 41d31b8c552..1d8205488eb 100644
--- a/engines/nancy/cursor.h
+++ b/engines/nancy/cursor.h
@@ -97,6 +97,7 @@ private:
 	CursorType _curCursorType;
 	int16 _curItemID;
 	uint _curCursorID;
+	uint _lastCursorID;
 	bool _hasItem;
 	bool _isInitialized;
 	int _numCursorTypes;


Commit: e26b8a50a44cb779a417859ae68a4fd8d165fc1d
    https://github.com/scummvm/scummvm/commit/e26b8a50a44cb779a417859ae68a4fd8d165fc1d
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-11-21T01:05:49+02:00

Commit Message:
NANCY: Fix mouse warping in TVD during conversations

Since we don't adjust TVD's cursor hotspot, we need to make
sure that the cursor warping during conversations does
not go above the line at the bottom of the Viewport

Changed paths:
    engines/nancy/state/scene.cpp


diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 668a89c9593..d3eeab0854a 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -1010,9 +1010,20 @@ void Scene::handleInput() {
 	if (_activeConversation != nullptr) {
 		const Common::Rect &inactiveZone = g_nancy->_cursorManager->getPrimaryVideoInactiveZone();
 
-		if (inactiveZone.bottom > input.mousePos.y) {
-			input.mousePos.y = inactiveZone.bottom;
-			g_nancy->_cursorManager->warpCursor(input.mousePos);
+		if (g_nancy->getGameType() == kGameTypeVampire) {
+			const Common::Point cursorHotspot = g_nancy->_cursorManager->getCurrentCursorHotspot();
+			Common::Point adjustedMousePos = input.mousePos;
+			adjustedMousePos.y -= cursorHotspot.y;
+
+			if (inactiveZone.bottom > adjustedMousePos.y) {
+				input.mousePos.y = inactiveZone.bottom + cursorHotspot.y;
+				g_nancy->_cursorManager->warpCursor(input.mousePos);
+			}
+		} else {
+			if (inactiveZone.bottom > input.mousePos.y) {
+				input.mousePos.y = inactiveZone.bottom;
+				g_nancy->_cursorManager->warpCursor(input.mousePos);
+			}
 		}
 	} else {
 		// Check if player has pressed esc


Commit: f55227752027cfa54b8b960b80e850121be45779
    https://github.com/scummvm/scummvm/commit/f55227752027cfa54b8b960b80e850121be45779
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-11-21T01:05:49+02:00

Commit Message:
NANCY: Slightly optimize drawing

Reduced some of the overdraw in GraphicsManager::draw();
testing suggests a speedup of roughly 9%

Changed paths:
    engines/nancy/graphics.cpp


diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index ca9e9334d75..19583d9aa66 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -108,16 +108,46 @@ void GraphicsManager::draw(bool updateScreen) {
 		}
 	}
 
-	// Redraw all dirty rects
-	for (auto it : _objects) {
-		RenderObject &current = *it;
+	// Perform the actual drawing. This checks for cases where something would be fully obscured,
+	// and skips them (e.g. redrawing the Viewport won't also redraw the background)
+	for (Common::Rect rect : _dirtyRects) {
+		for (RenderObject **it = _objects.begin(); it < _objects.end(); ++it) {
+			RenderObject &current = **it;
+
+			if (!current._isVisible || current.getScreenPosition().isEmpty()) {
+				continue;
+			}
 
-		if (!current._isVisible || current.getScreenPosition().isEmpty()) {
-			continue;
-		}
+			bool shouldSkip = false;
+
+			Common::Rect intersection = rect.findIntersectingRect(current.getScreenPosition());
+			if (!intersection.isEmpty()) {
+				// Found an intersecting RenderObject. Loop through the following
+				// RenderObjects, and see if we have another that fully obscures the intersection
+				for (auto it2 = it + 1; it2 < _objects.end(); ++it2) {
+					RenderObject &other = **it2;
+
+					if (!other._isVisible || other.getScreenPosition().isEmpty()) {
+						continue;
+					}
+
+					Common::Rect intersection2 = intersection.findIntersectingRect(other.getScreenPosition());
+					if (intersection == intersection2) {
+						// The entire area that would be drawn is obscured by another RenderObject.
+						// If the obscuring RenderObject is not transparent, we skip drawing current
+
+						if (!other._drawSurface.hasTransparentColor()) {
+							// No transparency, skip current
+							shouldSkip = true;
+							break;
+						}
+					}
+				}
+
+				if (shouldSkip) {
+					continue;
+				}
 
-		for (Common::Rect rect : _dirtyRects) {
-			if (rect.intersects(current.getScreenPosition())) {
 				blitToScreen(current, rect.findIntersectingRect(current.getScreenPosition()));
 			}
 		}




More information about the Scummvm-git-logs mailing list