[Scummvm-git-logs] scummvm master -> 8adcc29df9c5cc6fa58b7771cbe3e3014199cb49

ccawley2011 noreply at scummvm.org
Sun Feb 19 21:27:49 UTC 2023


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

Summary:
971148c9bd SURFACESDL: Allow vsync support to be implemented in subclasses with SDL 1.2
8adcc29df9 RISCOS: Use double buffering in full screen mode when V-sync is enabled


Commit: 971148c9bd20b6482070f11af6f79471301b0663
    https://github.com/scummvm/scummvm/commit/971148c9bd20b6482070f11af6f79471301b0663
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-19T21:27:45Z

Commit Message:
SURFACESDL: Allow vsync support to be implemented in subclasses with SDL 1.2

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


diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 7d51aa11f3b..8f4d90be67f 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -179,8 +179,8 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
 	_videoMode.filtering = ConfMan.getBool("filtering");
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 	_videoMode.stretchMode = STRETCH_FIT;
-	_videoMode.vsync = ConfMan.getBool("vsync");
 #endif
+	_videoMode.vsync = ConfMan.getBool("vsync");
 
 	_videoMode.scalerIndex = getDefaultScaler();
 	_videoMode.scaleFactor = getDefaultScaleFactor();
@@ -236,11 +236,9 @@ void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable)
 	case OSystem::kFeatureFilteringMode:
 		setFilteringMode(enable);
 		break;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 	case OSystem::kFeatureVSync:
 		setVSync(enable);
 		break;
-#endif
 	case OSystem::kFeatureCursorPalette:
 		_cursorPaletteDisabled = !enable;
 		blitCursor();
@@ -267,10 +265,8 @@ bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
 	case OSystem::kFeatureAspectRatioCorrection:
 		return _videoMode.aspectRatioCorrection;
 #endif
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 	case OSystem::kFeatureVSync:
 		return _videoMode.vsync;
-#endif
 	case OSystem::kFeatureFilteringMode:
 		return _videoMode.filtering;
 	case OSystem::kFeatureCursorPalette:
@@ -348,13 +344,13 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
 
 			_videoMode.stretchMode = _oldVideoMode.stretchMode;
 		}
-
+#endif
 		if (_videoMode.vsync != _oldVideoMode.vsync) {
 			errors |= OSystem::kTransactionVSyncFailed;
 
 			_videoMode.vsync = _oldVideoMode.vsync;
 		}
-#endif
+
 		if (_videoMode.filtering != _oldVideoMode.filtering) {
 			errors |= OSystem::kTransactionFilteringFailed;
 
@@ -1527,7 +1523,6 @@ void SurfaceSdlGraphicsManager::setFullscreenMode(bool enable) {
 	}
 }
 
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 void SurfaceSdlGraphicsManager::setVSync(bool enable) {
 	Common::StackLock lock(_graphicsMutex);
 
@@ -1542,7 +1537,6 @@ void SurfaceSdlGraphicsManager::setVSync(bool enable) {
 		_transactionDetails.needHotswap = true;
 	}
 }
-#endif
 
 void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) {
 	Common::StackLock lock(_graphicsMutex);
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 5048238439f..5eb1e6c1f75 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -263,8 +263,8 @@ protected:
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 		int stretchMode;
-		bool vsync;
 #endif
+		bool vsync;
 
 		uint scalerIndex;
 		int scaleFactor;
@@ -285,8 +285,8 @@ protected:
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
 			stretchMode = 0;
-			vsync = false;
 #endif
+			vsync = false;
 
 			scalerIndex = 0;
 			scaleFactor = 0;
@@ -428,9 +428,7 @@ protected:
 
 	virtual void setAspectRatioCorrection(bool enable);
 	void setFilteringMode(bool enable);
-#if SDL_VERSION_ATLEAST(2, 0, 0)
 	void setVSync(bool enable);
-#endif
 
 	bool saveScreenshot(const Common::String &filename) const override;
 	virtual void setGraphicsModeIntern();


Commit: 8adcc29df9c5cc6fa58b7771cbe3e3014199cb49
    https://github.com/scummvm/scummvm/commit/8adcc29df9c5cc6fa58b7771cbe3e3014199cb49
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-19T21:27:45Z

Commit Message:
RISCOS: Use double buffering in full screen mode when V-sync is enabled

Changed paths:
  A backends/graphics/riscossdl/riscossdl-graphics.cpp
  A backends/graphics/riscossdl/riscossdl-graphics.h
    backends/module.mk
    backends/platform/sdl/riscos/riscos.cpp


diff --git a/backends/graphics/riscossdl/riscossdl-graphics.cpp b/backends/graphics/riscossdl/riscossdl-graphics.cpp
new file mode 100644
index 00000000000..16e36c311f2
--- /dev/null
+++ b/backends/graphics/riscossdl/riscossdl-graphics.cpp
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#if defined(RISCOS) && defined(SDL_BACKEND)
+
+#include "backends/graphics/riscossdl/riscossdl-graphics.h"
+
+bool RISCOSSdlGraphicsManager::hasFeature(OSystem::Feature f) const {
+	if (f == OSystem::kFeatureVSync)
+		return true;
+	return SurfaceSdlGraphicsManager::hasFeature(f);
+}
+
+void RISCOSSdlGraphicsManager::initGraphicsSurface() {
+	Uint32 flags = 0;
+
+	if (_videoMode.fullscreen)
+		flags |= SDL_FULLSCREEN;
+
+	if (_videoMode.vsync && _videoMode.fullscreen) {
+		flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+	} else {
+		/* Hardware surfaces and double buffering aren't supported in windowed mode on RISC OS. */
+		flags |= SDL_SWSURFACE;
+	}
+
+	_hwScreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, flags);
+	_isDoubleBuf = flags & SDL_DOUBLEBUF;
+}
+
+#endif
diff --git a/backends/graphics/riscossdl/riscossdl-graphics.h b/backends/graphics/riscossdl/riscossdl-graphics.h
new file mode 100644
index 00000000000..307b17a8a44
--- /dev/null
+++ b/backends/graphics/riscossdl/riscossdl-graphics.h
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef BACKENDS_GRAPHICS_RISCOSSDL_H
+#define BACKENDS_GRAPHICS_RISCOSSDL_H
+
+#include "backends/graphics/surfacesdl/surfacesdl-graphics.h"
+
+class RISCOSSdlGraphicsManager : public SurfaceSdlGraphicsManager {
+public:
+	RISCOSSdlGraphicsManager(SdlEventSource *sdlEventSource, SdlWindow *window) : SurfaceSdlGraphicsManager(sdlEventSource, window) {}
+
+	bool hasFeature(OSystem::Feature f) const override;
+	void initGraphicsSurface() override;
+};
+
+#endif /* BACKENDS_GRAPHICS_RISCOSSDL_H */
diff --git a/backends/module.mk b/backends/module.mk
index 996455f2052..73247a32180 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -290,6 +290,7 @@ endif
 ifdef RISCOS
 MODULE_OBJS += \
 	events/riscossdl/riscossdl-events.o \
+	graphics/riscossdl/riscossdl-graphics.o \
 	fs/riscos/riscos-fs.o \
 	fs/riscos/riscos-fs-factory.o \
 	midi/riscos.o \
diff --git a/backends/platform/sdl/riscos/riscos.cpp b/backends/platform/sdl/riscos/riscos.cpp
index f75fd75ed47..427ce48b0ed 100644
--- a/backends/platform/sdl/riscos/riscos.cpp
+++ b/backends/platform/sdl/riscos/riscos.cpp
@@ -26,6 +26,7 @@
 #include "backends/platform/sdl/riscos/riscos.h"
 #include "backends/saves/default/default-saves.h"
 #include "backends/events/riscossdl/riscossdl-events.h"
+#include "backends/graphics/riscossdl/riscossdl-graphics.h"
 #include "backends/fs/riscos/riscos-fs-factory.h"
 #include "backends/fs/riscos/riscos-fs.h"
 
@@ -57,6 +58,10 @@ void OSystem_RISCOS::initBackend() {
 	if (_eventSource == 0)
 		_eventSource = new RISCOSSdlEventSource();
 
+	// Create the graphics manager
+	if (!_graphicsManager)
+		_graphicsManager = new RISCOSSdlGraphicsManager(_eventSource, _window);
+
 	// Create the savefile manager
 	if (_savefileManager == 0) {
 		Common::String savePath = "/<Choices$Write>/ScummVM/Saves";




More information about the Scummvm-git-logs mailing list