[Scummvm-git-logs] scummvm master -> 2b3521dc87014f18081615183d33299f368f6457

bluegr noreply at scummvm.org
Sun Jan 7 09:09:43 UTC 2024


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

Summary:
ad6343538f DRASCULA: Use OSystem::copyRectToScreen() where possible
838718ea85 DREAMWEB: Use OSystem::copyRectToScreen() and fillScreen() where possible
c7fbebf1ea GROOVIE: Use OSystem::fillScreen() where possible
bd559de863 KINGDOM: Use OSystem::copyRectToScreen() and fillScreen() where possible
4668faf3c0 M4: Use OSystem::fillScreen() where possible
b91f06d991 MOHAWK: Use OSystem::fillScreen() where possible
eb265d8d34 PLUMBERS: Use OSystem::copyRectToScreen() and fillScreen() where possible
3c80ba8d95 SAGA2: Use OSystem::copyRectToScreen() and fillScreen() where possible
01e7071315 SCI: Use OSystem::fillScreen() where possible
1423cf21cb SCUMM: Use OSystem::fillScreen() where possible
51c3b3a015 STARTREK: Use OSystem::fillScreen() where possible
9515a2a09e SUPERNOVA: Use OSystem::copyRectToScreen() and fillScreen() where possible
9905e32960 TEENAGENT: Use OSystem::fillScreen() where possible
2b3521dc87 TESTBED: Use OSystem::copyRectToScreen() and fillScreen() where possible


Commit: ad6343538f1329484a81fc732d09cfb70ece497f
    https://github.com/scummvm/scummvm/commit/ad6343538f1329484a81fc732d09cfb70ece497f
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
DRASCULA: Use OSystem::copyRectToScreen() where possible

Changed paths:
    engines/drascula/graphics.cpp


diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp
index 3c90ceb9c64..69c1de86e47 100644
--- a/engines/drascula/graphics.cpp
+++ b/engines/drascula/graphics.cpp
@@ -588,16 +588,15 @@ int DrasculaEngine::playFrameSSN(Common::SeekableReadStream *stream) {
 			free(BufferSSN);
 			waitFrameSSN();
 
-			Graphics::Surface *screenSurf = _system->lockScreen();
-			byte *screenBuffer = (byte *)screenSurf->getPixels();
-			uint16 screenPitch = screenSurf->pitch;
-			if (FrameSSN)
+			if (FrameSSN) {
+				Graphics::Surface *screenSurf = _system->lockScreen();
+				byte *screenBuffer = (byte *)screenSurf->getPixels();
+				uint16 screenPitch = screenSurf->pitch;
 				mixVideo(screenBuffer, screenSurface, screenPitch);
-			else
-				for (int y = 0; y < 200; y++)
-					memcpy(screenBuffer+y*screenPitch, screenSurface+y*320, 320);
+				_system->unlockScreen();
+			} else
+				_system->copyRectToScreen(screenSurface, 320, 0, 0, 320, 200);
 
-			_system->unlockScreen();
 			_system->updateScreen();
 			FrameSSN++;
 		} else {
@@ -607,16 +606,15 @@ int DrasculaEngine::playFrameSSN(Common::SeekableReadStream *stream) {
 				decodeOffset(BufferSSN, screenSurface, length);
 				free(BufferSSN);
 				waitFrameSSN();
-				Graphics::Surface *screenSurf = _system->lockScreen();
-				byte *screenBuffer = (byte *)screenSurf->getPixels();
-				uint16 screenPitch = screenSurf->pitch;
-				if (FrameSSN)
+				if (FrameSSN) {
+					Graphics::Surface *screenSurf = _system->lockScreen();
+					byte *screenBuffer = (byte *)screenSurf->getPixels();
+					uint16 screenPitch = screenSurf->pitch;
 					mixVideo(screenBuffer, screenSurface, screenPitch);
-				else
-					for (int y = 0; y < 200; y++)
-						memcpy(screenBuffer+y*screenPitch, screenSurface+y*320, 320);
+					_system->unlockScreen();
+				} else
+					_system->copyRectToScreen(screenSurface, 320, 0, 0, 320, 200);
 
-				_system->unlockScreen();
 				_system->updateScreen();
 				FrameSSN++;
 			}


Commit: 838718ea8547ff2056af7fce03019139356a87dd
    https://github.com/scummvm/scummvm/commit/838718ea8547ff2056af7fce03019139356a87dd
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
DREAMWEB: Use OSystem::copyRectToScreen() and fillScreen() where possible

Changed paths:
    engines/dreamweb/vgagrafx.cpp


diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 9a54359ab07..4735e95f06f 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -176,19 +176,19 @@ void DreamWebEngine::showPCX(const Common::String &suffix) {
 		_mainPal[i] >>= 2;
 	}
 
-	Graphics::Surface *s = g_system->lockScreen();
-	s->fillRect(Common::Rect(s->w, s->h), 0);
 	const Graphics::Surface *pcxSurface = pcx.getSurface();
 	if (pcxSurface->format.bytesPerPixel != 1)
 		error("Invalid bytes per pixel in PCX surface (%d)", pcxSurface->format.bytesPerPixel);
-	if (pcxSurface->w >= s->w * 2)
+
+	g_system->fillScreen(0);
+	if (pcxSurface->w >= g_system->getWidth() * 2) {
+		Graphics::Surface *s = g_system->lockScreen();
 		Graphics::downscaleSurfaceByHalf(s, pcxSurface, _mainPal);
-	else {
-		int limitW = MIN(pcxSurface->w, s->w);
-		for (uint16 y = 0; y < pcxSurface->h; y++)
-			memcpy((byte *)s->getBasePtr(0, y), pcxSurface->getBasePtr(0, y), limitW);
+		g_system->unlockScreen();
+	} else {
+		g_system->copyRectToScreen(pcxSurface->getPixels(), pcxSurface->pitch,
+		                           0, 0, pcxSurface->w, pcxSurface->h);
 	}
-	g_system->unlockScreen();
 }
 
 void DreamWebEngine::frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y) {


Commit: c7fbebf1ea49634e86dc358916db16ad1c19bc00
    https://github.com/scummvm/scummvm/commit/c7fbebf1ea49634e86dc358916db16ad1c19bc00
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
GROOVIE: Use OSystem::fillScreen() where possible

Changed paths:
    engines/groovie/script.cpp


diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index faab6f77544..c6dd0a144b5 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -1827,10 +1827,11 @@ void Script::o_printstring() {
 	stringstorage[counter] = 0;
 
 	Common::Rect topbar(640, 80);
-	Graphics::Surface *gamescreen = _vm->_system->lockScreen();
 
 	// Clear the top bar
-	gamescreen->fillRect(topbar, 0);
+	_vm->_system->fillScreen(topbar, 0);
+
+	Graphics::Surface *gamescreen = _vm->_system->lockScreen();
 
 	// Draw the string
 	printString(gamescreen, stringstorage);
@@ -1870,10 +1871,10 @@ void Script::o_hotspot_slot() {
 			return;
 		}
 
-		Graphics::Surface *gamescreen = _vm->_system->lockScreen();
-
 		// Clear the top bar
-		gamescreen->fillRect(removeText, 0);	// 0 works for both color formats (Groovie V1 and V2)
+		_vm->_system->fillScreen(removeText, 0);	// 0 works for both color formats (Groovie V1 and V2)
+
+		Graphics::Surface *gamescreen = _vm->_system->lockScreen();
 
 		printString(gamescreen, _saveNames[slot].c_str());
 
@@ -1885,12 +1886,7 @@ void Script::o_hotspot_slot() {
 
 	} else {
 		if (_hotspotSlot == slot) {
-			Graphics::Surface *gamescreen;
-			gamescreen = _vm->_system->lockScreen();
-
-			gamescreen->fillRect(removeText, 0);	// 0 works for both color formats (Groovie V1 and V2)
-
-			_vm->_system->unlockScreen();
+			_vm->_system->fillScreen(removeText, 0);	// 0 works for both color formats (Groovie V1 and V2)
 
 			// Removing the slot highlight
 			_hotspotSlot = (uint16)-1;


Commit: bd559de86346ceb6451bfaae81f4da9720edbddf
    https://github.com/scummvm/scummvm/commit/bd559de86346ceb6451bfaae81f4da9720edbddf
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
KINGDOM: Use OSystem::copyRectToScreen() and fillScreen() where possible

Changed paths:
    engines/kingdom/kingdom.cpp


diff --git a/engines/kingdom/kingdom.cpp b/engines/kingdom/kingdom.cpp
index 9f850d62adb..76698c4de7a 100644
--- a/engines/kingdom/kingdom.cpp
+++ b/engines/kingdom/kingdom.cpp
@@ -521,9 +521,7 @@ void KingdomGame::playMovie(int movieNum) {
 			}
 
 			if (frame) {
-				::Graphics::Surface *screen = g_system->lockScreen();
-				screen->copyRectToSurface(*frame, x, y, Common::Rect(frame->w, frame->h));
-				g_system->unlockScreen();
+				g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
 
 				if (decoder->hasDirtyPalette()) {
 					PaletteManager *paletteManager = g_system->getPaletteManager();
@@ -602,15 +600,7 @@ void KingdomGame::restoreAS() {
 
 	g_system->getPaletteManager()->setPalette(palette, 0, 256);
 
-	::Graphics::Surface *screen = g_system->lockScreen();
-	for (uint curX = 0; curX < 224; curX++) {
-		for (uint curY = 0; curY < 146; curY++) {
-			byte *ptr = (byte *)screen->getBasePtr(curX + 4, curY + 15);
-			*ptr = _asPtr[curY * 224 + curX];
-		}
-	}
-
-	g_system->unlockScreen();
+	g_system->copyRectToScreen(_asPtr, 224, 4, 15, 224, 146);
 	g_system->updateScreen();
 	delete[] _asPtr;
 	_asPtr = nullptr;
@@ -648,14 +638,7 @@ void KingdomGame::drawHelpScreen() {
 }
 
 void KingdomGame::drawRect(uint minX, uint minY, uint maxX, uint maxY, int color) {
-	::Graphics::Surface *screen = g_system->lockScreen();
-	for (uint curX = minX; curX < maxX; curX++) {
-		for (uint curY = minY; curY < maxY; curY++) {
-			byte *dst = (byte *)screen->getBasePtr(curX, curY);
-			*dst = color;
-		}
-	}
-	g_system->unlockScreen();
+	g_system->fillScreen(Common::Rect(minX, minY, maxX, maxY), color);
 	g_system->updateScreen();
 }
 


Commit: 4668faf3c04cd17269f727e1830f86ee881093d6
    https://github.com/scummvm/scummvm/commit/4668faf3c04cd17269f727e1830f86ee881093d6
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
M4: Use OSystem::fillScreen() where possible

Changed paths:
    engines/m4/gui/gui_vmng_screen.cpp


diff --git a/engines/m4/gui/gui_vmng_screen.cpp b/engines/m4/gui/gui_vmng_screen.cpp
index a7d6d24bc31..f33bfa07a71 100644
--- a/engines/m4/gui/gui_vmng_screen.cpp
+++ b/engines/m4/gui/gui_vmng_screen.cpp
@@ -212,10 +212,8 @@ bool ResizeScreen(void *scrnContent, int32 newW, int32 newH) {
 }
 
 static void vmng_black_out_video(int32 x1, int32 y1, int32 x2, int32 y2) {
-	Graphics::Surface *screen = g_system->lockScreen();
 	Common::Rect r(x1, y1, x2 + 1, y2 + 1);
-	screen->fillRect(r, 0);
-	g_system->unlockScreen();
+	g_system->fillScreen(r, 0);
 }
 
 bool AddScreenHotkey(void *scrnContent, int32 myKey, HotkeyCB callback) {


Commit: b91f06d9916636e53772faef4cb4463161ac975e
    https://github.com/scummvm/scummvm/commit/b91f06d9916636e53772faef4cb4463161ac975e
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
MOHAWK: Use OSystem::fillScreen() where possible

Changed paths:
    engines/mohawk/riven_inventory.cpp


diff --git a/engines/mohawk/riven_inventory.cpp b/engines/mohawk/riven_inventory.cpp
index bbceac493f2..f3b9b483c18 100644
--- a/engines/mohawk/riven_inventory.cpp
+++ b/engines/mohawk/riven_inventory.cpp
@@ -84,13 +84,8 @@ void RivenInventory::clearArea() {
 	// Clear the inventory area
 	static const Common::Rect inventoryRect = Common::Rect(0, 392, 608, 436);
 
-	// Lock the screen
-	Graphics::Surface *screen = _vm->_system->lockScreen();
-
 	// Fill the inventory area with black
-	screen->fillRect(inventoryRect, screen->format.RGBToColor(0, 0, 0));
-
-	_vm->_system->unlockScreen();
+	_vm->_system->fillScreen(inventoryRect, g_system->getScreenFormat().RGBToColor(0, 0, 0));
 }
 
 void RivenInventory::checkClick(const Common::Point &mousePos) {


Commit: eb265d8d34d83143c67ab8c2e255abaeffc85fcf
    https://github.com/scummvm/scummvm/commit/eb265d8d34d83143c67ab8c2e255abaeffc85fcf
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
PLUMBERS: Use OSystem::copyRectToScreen() and fillScreen() where possible

Changed paths:
    engines/plumbers/3do.cpp
    engines/plumbers/plumbers.cpp
    engines/plumbers/plumbers.h


diff --git a/engines/plumbers/3do.cpp b/engines/plumbers/3do.cpp
index 4f62a452454..ece10d26166 100644
--- a/engines/plumbers/3do.cpp
+++ b/engines/plumbers/3do.cpp
@@ -483,7 +483,7 @@ void PlumbersGame3DO::startGraphics() {
 	initGraphics(_screenW, _screenH, &pf);
 }
 
-void PlumbersGame3DO::blitImage(Graphics::Surface *screen) {
+void PlumbersGame3DO::blitImage() {
 	const Graphics::Surface *surface;
 	bool ctrlHelp = false;
 	if (_leftShoulderPressed && _leftButtonDownFl && _ctrlHelpImage) {
@@ -522,7 +522,7 @@ void PlumbersGame3DO::blitImage(Graphics::Surface *screen) {
 		modded = true;
 	}
 
-	blitImageSurface(screen, modded ? &modSurf : surface);
+	blitImageSurface(modded ? &modSurf : surface);
 }
 
 void PlumbersGame3DO::skipVideo() {
diff --git a/engines/plumbers/plumbers.cpp b/engines/plumbers/plumbers.cpp
index c541c6feef1..bd8d51f8c1f 100644
--- a/engines/plumbers/plumbers.cpp
+++ b/engines/plumbers/plumbers.cpp
@@ -221,18 +221,18 @@ void PlumbersGame::loadImage(const Common::String &name) {
 	_compositeSurface = nullptr;
 }
 
-void PlumbersGame::blitImageSurface(Graphics::Surface *screen, const Graphics::Surface *surface) {
+void PlumbersGame::blitImageSurface(const Graphics::Surface *surface) {
 	int w = CLIP<int>(surface->w, 0, _screenW);
 	int h = CLIP<int>(surface->h, 0, _screenH);
 
 	int x = (_screenW - w) / 2;
 	int y = (_screenH - h) / 2;
 
-	screen->copyRectToSurface(*surface, x, y, Common::Rect(0, 0, w, h));
+	g_system->copyRectToScreen(surface->getPixels(), surface->pitch, x, y, w, h);
 }
 
-void PlumbersGame::blitImage(Graphics::Surface *screen) {
-	blitImageSurface(screen, _compositeSurface ? _compositeSurface : _image->getSurface());
+void PlumbersGame::blitImage() {
+	blitImageSurface(_compositeSurface ? _compositeSurface : _image->getSurface());
 }
 
 void PlumbersGame::drawScreen() {
@@ -245,27 +245,28 @@ void PlumbersGame::drawScreen() {
 			_actions.push(UpdateScene);
 		}
 
-		Graphics::Surface *screen = g_system->lockScreen();
-		screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
+		g_system->fillScreen(0);
 
-		blitImage(screen);
+		blitImage();
 
 		if (_showScoreFl) {
+			Graphics::PixelFormat screenFormat = g_system->getScreenFormat();
 			Common::String score = Common::String::format("Your Score is: %ld", _totScore);
 			const Graphics::Font &font(*FontMan.getFontByUsage(
 						       _screenW >= 640 ? Graphics::FontManager::kBigGUIFont : Graphics::FontManager::kGUIFont));
 			int scoreTop = _screenH - _screenH / 12;
 			int scoreMaxWidth = _screenW >= 640 ? 200 : 150;
-			uint scoreColor = screen->format.bytesPerPixel == 1 ? 0xff : screen->format.RGBToColor(0xff, 0xff, 0xff);
+			uint scoreColor = screenFormat.bytesPerPixel == 1 ? 0xff : screenFormat.RGBToColor(0xff, 0xff, 0xff);
 			Common::Rect rect(10, scoreTop, scoreMaxWidth, scoreTop + font.getFontHeight());
 			if (getPlatform() != Common::kPlatform3DO)
-				screen->fillRect(rect, 0);
+				g_system->fillScreen(rect, 0);
+			Graphics::Surface *screen = g_system->lockScreen();
 			font.drawString(screen, score, rect.left, rect.top, scoreMaxWidth - 10,
 					scoreColor, Graphics::kTextAlignCenter);
+			g_system->unlockScreen();
 			_showScoreFl = false;
 		}
 
-		g_system->unlockScreen();
 		if (_image->getPalette() != nullptr)
 			g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
 		g_system->updateScreen();
diff --git a/engines/plumbers/plumbers.h b/engines/plumbers/plumbers.h
index 787390449ed..9824ec9175e 100644
--- a/engines/plumbers/plumbers.h
+++ b/engines/plumbers/plumbers.h
@@ -93,8 +93,8 @@ protected:
 	virtual bool handlePlatformKeyDown(int button) { return false; }
 	virtual void loadImage(const Common::String &name);
 	virtual void startGraphics() = 0;
-	void blitImageSurface(Graphics::Surface *screen, const Graphics::Surface *surface);
-	virtual void blitImage(Graphics::Surface *screen);
+	void blitImageSurface(const Graphics::Surface *surface);
+	virtual void blitImage();
 	virtual void handleEvent(const Common::Event &event);
 	virtual int getSceneNumb(const Common::String &sName);
 	virtual void preActions() {}
@@ -164,7 +164,7 @@ protected:
 	void postSceneBitmaps() override;
 	void startGraphics() override;
 	void handleEvent(const Common::Event &event) override;
-	void blitImage(Graphics::Surface *screen) override;
+	void blitImage() override;
 	int getSceneNumb(const Common::String &sName) override;
 	void preActions() override;
 


Commit: 3c80ba8d9536a13f639af8de62dd63028091c07f
    https://github.com/scummvm/scummvm/commit/3c80ba8d9536a13f639af8de62dd63028091c07f
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
SAGA2: Use OSystem::copyRectToScreen() and fillScreen() where possible

Changed paths:
    engines/saga2/gfx.cpp
    engines/saga2/vwdraw.cpp


diff --git a/engines/saga2/gfx.cpp b/engines/saga2/gfx.cpp
index 95baa674011..8316c91ac3b 100644
--- a/engines/saga2/gfx.cpp
+++ b/engines/saga2/gfx.cpp
@@ -65,12 +65,9 @@ void Renderer::popSavedBackBuffer(BackBufferSource source) {
 void Renderer::restoreSavedBackBuffer(BackBufferSource source) {
 	if (source >= 0 && source < kMaxBackBufferSources) {
 		if (_savedBackBuffers[source]) {
-			Graphics::Surface *surf = g_system->lockScreen();
-			int size = surf->w * surf->h;
-
-			memcpy(surf->getBasePtr(0, 0), _savedBackBuffers[source], size);
-
-			g_system->unlockScreen();
+			uint w = g_system->getWidth();
+			uint h = g_system->getHeight();
+			g_system->copyRectToScreen(_savedBackBuffers[source], w, 0, 0, w, h);
 		}
 	}
 }
diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp
index 0d118505434..b03205acb1c 100644
--- a/engines/saga2/vwdraw.cpp
+++ b/engines/saga2/vwdraw.cpp
@@ -23,6 +23,7 @@
  *   (c) 1993-1996 The Wyrmkeep Entertainment Co.
  */
 
+#include "common/rect.h"
 #include "graphics/surface.h"
 
 #include "saga2/saga2.h"
@@ -395,11 +396,8 @@ void gDisplayPort::line(int16 x1, int16 y1, int16 x2, int16 y2) {
 }
 
 void vDisplayPage::fillRect(Rect16 r, uint8 color) {
-	Graphics::Surface *surf = g_system->lockScreen();
-
-	_FillRect((byte *)surf->getBasePtr(r.x, r.y), surf->pitch, r.width, r.height, color);
-
-	g_system->unlockScreen();
+	Common::Rect rect(r.x, r.y, r.x + r.width, r.y + r.height);
+	g_system->fillScreen(rect, color);
 }
 
 void vDisplayPage::invertRect(Rect16 r, uint8 color) {


Commit: 01e7071315bffda85b012686e6c0434c26ad99d3
    https://github.com/scummvm/scummvm/commit/01e7071315bffda85b012686e6c0434c26ad99d3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
SCI: Use OSystem::fillScreen() where possible

Changed paths:
    engines/sci/graphics/transitions.cpp


diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp
index a684937d456..c07d03c6c1e 100644
--- a/engines/sci/graphics/transitions.cpp
+++ b/engines/sci/graphics/transitions.cpp
@@ -283,16 +283,14 @@ void GfxTransitions::copyRectToScreen(const Common::Rect rect, bool blackoutFlag
 	if (!blackoutFlag) {
 		_screen->copyRectToScreen(rect);
 	} else {
-		Graphics::Surface *surface = g_system->lockScreen();
 		if (!_screen->getUpscaledHires()) {
-			surface->fillRect(rect, 0);
+			g_system->fillScreen(rect, 0);
 		} else {
 			Common::Rect upscaledRect = rect;
 			_screen->adjustToUpscaledCoordinates(upscaledRect.top, upscaledRect.left);
 			_screen->adjustToUpscaledCoordinates(upscaledRect.bottom, upscaledRect.right);
-			surface->fillRect(upscaledRect, 0);
+			g_system->fillScreen(upscaledRect, 0);
 		}
-		g_system->unlockScreen();
 	}
 }
 


Commit: 1423cf21cbf22f0b8ad02366853b12ea26e74cd5
    https://github.com/scummvm/scummvm/commit/1423cf21cbf22f0b8ad02366853b12ea26e74cd5
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
SCUMM: Use OSystem::fillScreen() where possible

This also avoids calling lockScreen() just to get the width, height and pitch.

Changed paths:
    engines/scumm/gfx.h
    engines/scumm/gfx_towns.cpp


diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h
index 4b139e213c1..6b2995f77cd 100644
--- a/engines/scumm/gfx.h
+++ b/engines/scumm/gfx.h
@@ -616,7 +616,7 @@ private:
 		uint16 *bltTmpPal= nullptr;
 	} _layers[2];
 
-	template<typename dstPixelType, typename srcPixelType, int scaleW, int scaleH, bool col4bit> void transferRect(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
+	template<typename dstPixelType, typename srcPixelType, int scaleW, int scaleH, bool col4bit> void transferRect(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
 	template<typename dstPixelType> void updateScreenBuffer();
 
 #ifdef USE_RGB_COLOR
@@ -626,7 +626,6 @@ private:
 
 	int _height;
 	int _width;
-	int _pitch;
 	bool _semiSmoothScroll;
 	Graphics::PixelFormat _pixelFormat;
 
diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp
index aa99d621205..e9579b24e67 100644
--- a/engines/scumm/gfx_towns.cpp
+++ b/engines/scumm/gfx_towns.cpp
@@ -361,12 +361,9 @@ const uint8 ScummEngine::_townsLayer2Mask[] = {
 	0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-TownsScreen::TownsScreen(OSystem *system) :	_system(system), _width(0), _height(0), _pitch(0), _pixelFormat(system->getScreenFormat()), _numDirtyRects(0) {
-	Graphics::Surface *s = _system->lockScreen();
-	_width = s->w;
-	_height = s->h;
-	_pitch = s->pitch;
-	_system->unlockScreen();
+TownsScreen::TownsScreen(OSystem *system) :	_system(system), _width(0), _height(0), _pixelFormat(system->getScreenFormat()), _numDirtyRects(0) {
+	_width = _system->getWidth();
+	_height = _system->getHeight();
 
 	_semiSmoothScroll = ConfMan.getBool("semi_smooth_scroll");
 
@@ -544,10 +541,7 @@ void TownsScreen::toggleLayers(int flags) {
 	_dirtyRects.push_back(Common::Rect(_width - 1, _height - 1));
 	_numDirtyRects = kFullRedraw;
 
-	Graphics::Surface *s = _system->lockScreen();
-	assert(s);
-	memset(s->getPixels(), 0, _pitch * _height);
-	_system->unlockScreen();
+	_system->fillScreen(0);
 	update();
 
 	_system->updateScreen();
@@ -615,10 +609,10 @@ uint16 TownsScreen::calc16BitColor(const uint8 *palEntry) {
 }
 #endif
 
-template<typename dstPixelType, typename srcPixelType, int scaleW, int scaleH, bool srcCol4bit> void TownsScreen::transferRect(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h) {
-	uint8 *dst10 = dst + y * _pitch * scaleH + x * sizeof(dstPixelType) * scaleW;
-	uint8 *dst20 = (scaleH == 2) ? dst10 + _pitch : nullptr;
-	int pitch = _pitch * scaleH;
+template<typename dstPixelType, typename srcPixelType, int scaleW, int scaleH, bool srcCol4bit> void TownsScreen::transferRect(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h) {
+	uint8 *dst10 = dst + y * pitch * scaleH + x * sizeof(dstPixelType) * scaleW;
+	uint8 *dst20 = (scaleH == 2) ? dst10 + pitch : nullptr;
+	pitch *= scaleH;
 
 	int x0 = (x + l->hScroll) % l->width;
 	const uint8 *in0 = l->pixels + y * l->pitch + x0 * sizeof(srcPixelType);
@@ -686,13 +680,13 @@ template<typename dstPixelType, typename srcPixelType, int scaleW, int scaleH, b
 }
 
 #ifdef USE_RGB_COLOR
-template void TownsScreen::transferRect<uint16, uint16, 1, 1, false>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
-template void TownsScreen::transferRect<uint16, uint16, 2, 2, false>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
-template void TownsScreen::transferRect<uint16, uint8, 1, 1, true>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint16, uint16, 1, 1, false>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint16, uint16, 2, 2, false>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint16, uint8, 1, 1, true>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
 #else
-template void TownsScreen::transferRect<uint8, uint8, 2, 2, false>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
-template void TownsScreen::transferRect<uint8, uint8, 1, 1, false>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
-template void TownsScreen::transferRect<uint8, uint8, 1, 1, true>(uint8 *dst, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint8, uint8, 2, 2, false>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint8, uint8, 1, 1, false>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
+template void TownsScreen::transferRect<uint8, uint8, 1, 1, true>(uint8 *dst, int pitch, TownsScreenLayer *l, int x, int y, int w, int h);
 #endif
 
 template<typename dstPixelType> void TownsScreen::updateScreenBuffer() {
@@ -700,6 +694,7 @@ template<typename dstPixelType> void TownsScreen::updateScreenBuffer() {
 	if (!s)
 		error("TownsScreen::updateOutputBuffer(): Failed to allocate screen buffer");
 	uint8 *dst = (uint8*)s->getPixels();
+	int pitch = s->pitch;
 
 	for (int i = 0; i < 2; i++) {
 		TownsScreenLayer *l = &_layers[i];
@@ -709,10 +704,10 @@ template<typename dstPixelType> void TownsScreen::updateScreenBuffer() {
 		if (l->bpp == 2) {
 			if (l->scaleH == 2 && l->scaleW == 2) {
 				for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r)
-					transferRect<dstPixelType, uint16, 2, 2, false>(dst, l, r->left >> 1, r->top >> 1, (r->right - r->left) >> 1, (r->bottom - r->top) >> 1);
+					transferRect<dstPixelType, uint16, 2, 2, false>(dst, pitch, l, r->left >> 1, r->top >> 1, (r->right - r->left) >> 1, (r->bottom - r->top) >> 1);
 			} else if (l->scaleH == 1 && l->scaleW == 1) {
 				for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r)
-					transferRect<dstPixelType, uint16, 1, 1, false>(dst, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
+					transferRect<dstPixelType, uint16, 1, 1, false>(dst, pitch, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
 			} else {
 				error("TownsScreen::updateOutputBuffer(): Unsupported scale mode");
 			}
@@ -722,7 +717,7 @@ template<typename dstPixelType> void TownsScreen::updateScreenBuffer() {
 #endif
 				if (l->scaleH == 1 && l->scaleW == 1) {
 					for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r)
-						transferRect<dstPixelType, uint8, 1, 1, true>(dst, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
+						transferRect<dstPixelType, uint8, 1, 1, true>(dst, pitch, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
 				} else {
 					error("TownsScreen::updateOutputBuffer(): Unsupported scale mode");
 				}
@@ -730,10 +725,10 @@ template<typename dstPixelType> void TownsScreen::updateScreenBuffer() {
 			} else {
 				if (l->scaleH == 2 && l->scaleW == 2) {
 					for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r)
-						transferRect<dstPixelType, uint8, 2, 2, false>(dst, l, r->left >> 1, r->top >> 1, (r->right - r->left) >> 1, (r->bottom - r->top) >> 1);
+						transferRect<dstPixelType, uint8, 2, 2, false>(dst, pitch, l, r->left >> 1, r->top >> 1, (r->right - r->left) >> 1, (r->bottom - r->top) >> 1);
 				} else if (l->scaleH == 1 && l->scaleW == 1) {
 					for (Common::List<Common::Rect>::iterator r = _dirtyRects.begin(); r != _dirtyRects.end(); ++r)
-						transferRect<dstPixelType, uint8, 1, 1, false>(dst, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
+						transferRect<dstPixelType, uint8, 1, 1, false>(dst, pitch, l, r->left, r->top, r->right - r->left, r->bottom - r->top);
 				}
 			}
 #else


Commit: 51c3b3a015e9444f89770fc247e9b40b8707c31f
    https://github.com/scummvm/scummvm/commit/51c3b3a015e9444f89770fc247e9b40b8707c31f
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
STARTREK: Use OSystem::fillScreen() where possible

Changed paths:
    engines/startrek/graphics.cpp


diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index e2782e44134..3db56188b57 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -120,9 +120,7 @@ void Graphics::unlockScreenPixels() {
 void Graphics::clearScreenAndPriBuffer() {
 	Common::fill(_priData, _priData + sizeof(_priData), 0);
 
-	::Graphics::Surface *surface = _vm->_system->lockScreen();
-	surface->fillRect(_screenRect, 0);
-	_vm->_system->unlockScreen();
+	_vm->_system->fillScreen(_screenRect, 0);
 	_vm->_system->updateScreen();
 	_vm->_system->delayMillis(10);
 }


Commit: 9515a2a09e7a775297759f228699c656a340de33
    https://github.com/scummvm/scummvm/commit/9515a2a09e7a775297759f228699c656a340de33
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
SUPERNOVA: Use OSystem::copyRectToScreen() and fillScreen() where possible

Changed paths:
    engines/supernova/screen.cpp


diff --git a/engines/supernova/screen.cpp b/engines/supernova/screen.cpp
index 30253a52d91..b4699e2e866 100644
--- a/engines/supernova/screen.cpp
+++ b/engines/supernova/screen.cpp
@@ -95,9 +95,8 @@ void ScreenBufferStack::restore() {
 		return;
 
 	--_last;
-	g_system->lockScreen()->copyRectToSurface(_last->_pixels, _last->_width, _last->_x,
-											  _last->_y, _last->_width, _last->_height);
-	g_system->unlockScreen();
+	g_system->copyRectToScreen(_last->_pixels, _last->_width, _last->_x,
+	                           _last->_y, _last->_width, _last->_height);
 
 	delete[] _last->_pixels;
 }
@@ -618,9 +617,7 @@ void Screen::removeMessage() {
 }
 
 void Screen::renderBox(int x, int y, int width, int height, byte color) {
-	Graphics::Surface *screen = _vm->_system->lockScreen();
-	screen->fillRect(Common::Rect(x, y, x + width, y + height), color);
-	_vm->_system->unlockScreen();
+	_vm->_system->fillScreen(Common::Rect(x, y, x + width, y + height), color);
 }
 
 void Screen::renderBox(const GuiElement &guiElement) {


Commit: 9905e32960c12b2a255347f10eebe7af80ce9c91
    https://github.com/scummvm/scummvm/commit/9905e32960c12b2a255347f10eebe7af80ce9c91
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
TEENAGENT: Use OSystem::fillScreen() where possible

Changed paths:
    engines/teenagent/teenagent.cpp


diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index a76172b5d5b..0c6e7896ed6 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -464,11 +464,11 @@ bool TeenAgentEngine::showMetropolis() {
 			}
 		}
 
-		Graphics::Surface *surface = _system->lockScreen();
 		if (logo_y > 0) {
-			surface->fillRect(Common::Rect(0, 0, kScreenWidth, logo_y), 0);
+			g_system->fillScreen(Common::Rect(0, 0, kScreenWidth, logo_y), 0);
 		}
 
+		Graphics::Surface *surface = _system->lockScreen();
 		{
 			//generate colors matrix
 			memmove(colors + 320, colors + 480, 8480);


Commit: 2b3521dc87014f18081615183d33299f368f6457
    https://github.com/scummvm/scummvm/commit/2b3521dc87014f18081615183d33299f368f6457
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-01-07T11:09:34+02:00

Commit Message:
TESTBED: Use OSystem::copyRectToScreen() and fillScreen() where possible

Also fixed invalid use of screen surface after unlocking

Changed paths:
    engines/testbed/events.cpp
    engines/testbed/graphics.cpp
    engines/testbed/testsuite.cpp


diff --git a/engines/testbed/events.cpp b/engines/testbed/events.cpp
index df9bba4848c..57093a6e04b 100644
--- a/engines/testbed/events.cpp
+++ b/engines/testbed/events.cpp
@@ -112,17 +112,17 @@ char EventTests::keystrokeToChar() {
 }
 
 Common::Rect EventTests::drawFinishZone() {
-	Graphics::Surface *screen = g_system->lockScreen();
 	const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont));
 	int width = 35;
 	int height = 20;
 	int right = g_system->getWidth();
 	Common::Rect rect(0, 0, right, height);
 	Common::Rect rect2(0, 0, right - width, height);
-	screen->fillRect(rect, kColorSpecial);
-	screen->fillRect(rect2, kColorBlack);
-	g_system->unlockScreen();
+	g_system->fillScreen(rect, kColorSpecial);
+	g_system->fillScreen(rect2, kColorBlack);
+	Graphics::Surface *screen = g_system->lockScreen();
 	font.drawString(screen, "Close", rect.left, rect.top, screen->w, kColorBlack, Graphics::kTextAlignRight);
+	g_system->unlockScreen();
 	g_system->updateScreen();
 	return Common::Rect(right - width, 0, right, height);
 }
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index fc626d488c8..a4d25e747d3 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -335,10 +335,8 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName
 			// Move estimated rect to (20, 20)
 			estimatedCursorRect.moveTo(20, 20);
 
-			Graphics::Surface *screen = g_system->lockScreen();
 			GFXTestSuite::setCustomColor(255, 0, 0);
-			screen->fillRect(estimatedCursorRect, 2);
-			g_system->unlockScreen();
+			g_system->fillScreen(estimatedCursorRect, 2);
 			g_system->updateScreen();
 		}
 
@@ -1040,11 +1038,9 @@ TestExitStatus GFXtests::mouseMovements() {
 	}
 
 	// Draw Rectangle
-	Graphics::Surface *screen = g_system->lockScreen();
 	// Ensure that 2 represents red in current palette
 	GFXTestSuite::setCustomColor(255, 0, 0);
-	screen->fillRect(Common::Rect::center(106, 106, 14, 14), 2);
-	g_system->unlockScreen();
+	g_system->fillScreen(Common::Rect::center(106, 106, 14, 14), 2);
 
 	// Testing Mouse Movements now!
 	Common::Point pt(0, 10);
@@ -1364,7 +1360,6 @@ TestExitStatus GFXtests::focusRectangle() {
 
 	const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont));
 
-	Graphics::Surface *screen = g_system->lockScreen();
 	int screenHeight = g_system->getHeight();
 	int screenWidth = g_system->getWidth();
 
@@ -1372,11 +1367,13 @@ TestExitStatus GFXtests::focusRectangle() {
 	int width = screenWidth / 2;
 
 	Common::Rect rectLeft(0, 0, width, height * 2);
-	screen->fillRect(rectLeft, kColorWhite);
-	font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft);
+	g_system->fillScreen(rectLeft, kColorWhite);
 
 	Common::Rect rectRight(screenWidth - width, screenHeight - height * 2 , screenWidth, screenHeight);
-	screen->fillRect(rectRight, kColorWhite);
+	g_system->fillScreen(rectRight, kColorWhite);
+
+	Graphics::Surface *screen = g_system->lockScreen();
+	font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft);
 	font.drawString(screen, "Focus 2", rectRight.left, rectRight.top, width, kColorBlack, Graphics::kTextAlignRight);
 	g_system->unlockScreen();
 	g_system->updateScreen();
@@ -1732,6 +1729,7 @@ void GFXtests::showPixelFormat(const Graphics::PixelFormat &pf, uint aLoss) {
 	Graphics::Surface *screen = g_system->lockScreen();
 	Graphics::ManagedSurface dstSurface(screen->w, screen->h, screen->format);
 	dstSurface.blitFrom(*screen);
+	g_system->unlockScreen();
 
 
 	// Init palette, if we are demonstating a CLUT8 preview
@@ -1838,7 +1836,6 @@ void GFXtests::showPixelFormat(const Graphics::PixelFormat &pf, uint aLoss) {
 
 	g_system->copyRectToScreen(dstSurface.getPixels(), dstSurface.pitch, 0, 0,
 	                           dstSurface.w, dstSurface.h);
-	g_system->unlockScreen();
 	g_system->updateScreen();
 }
 
diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp
index 6b8cb0e27a9..eb2f24d108e 100644
--- a/engines/testbed/testsuite.cpp
+++ b/engines/testbed/testsuite.cpp
@@ -126,10 +126,8 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
 	uint fillColor = kColorBlack;
 	uint textColor = kColorWhite;
 
-	Graphics::Surface *screen = g_system->lockScreen();
-
 	int height = font.getFontHeight();
-	int width = screen->w;
+	int width = g_system->getWidth();
 
 	Common::Rect rect(pt.x, pt.y, pt.x + width, pt.y + height);
 
@@ -139,9 +137,10 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
 		textColor = pf.RGBToColor(255, 255, 255);
 	}
 
-	screen->fillRect(rect, fillColor);
-	font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
+	g_system->fillScreen(rect, fillColor);
 
+	Graphics::Surface *screen = g_system->lockScreen();
+	font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
 	g_system->unlockScreen();
 	g_system->updateScreen();
 
@@ -149,11 +148,7 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
 }
 
 void Testsuite::clearScreen(const Common::Rect &rect) {
-	Graphics::Surface *screen = g_system->lockScreen();
-
-	screen->fillRect(rect, kColorBlack);
-
-	g_system->unlockScreen();
+	g_system->fillScreen(rect, kColorBlack);
 	g_system->updateScreen();
 }
 
@@ -170,16 +165,13 @@ void Testsuite::clearScreen() {
 }
 
 void Testsuite::clearScreen(bool flag) {
-	Graphics::Surface *screen = g_system->lockScreen();
 	uint fillColor = kColorBlack;
 
 	if (flag) {
 		fillColor = g_system->getScreenFormat().RGBToColor(0, 0, 0);
 	}
 
-	screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), fillColor);
-
-	g_system->unlockScreen();
+	g_system->fillScreen(fillColor);
 	g_system->updateScreen();
 }
 




More information about the Scummvm-git-logs mailing list