[Scummvm-git-logs] scummvm master -> 34f7e04c4f8223213a0adea05c9f560584007995

sev- sev at scummvm.org
Sun May 16 23:55:45 UTC 2021


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

Summary:
4af234930d SLUDGE: Implement Snapshotbox transition
7d5788836d SLUDGE: Implement Crossfade transition
df762ea3df SLUDGE: Cleanup and simplify code
34f7e04c4f SLUDGE: Initial code for bg effects


Commit: 4af234930dee5e79f5f8fb02603edf7331d066c2
    https://github.com/scummvm/scummvm/commit/4af234930dee5e79f5f8fb02603edf7331d066c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T01:55:14+02:00

Commit Message:
SLUDGE: Implement Snapshotbox transition

Changed paths:
    engines/sludge/graphics.h
    engines/sludge/transition.cpp


diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index d0861fd2e5..e2ecf5cea6 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -191,6 +191,7 @@ public:
 	void transitionDisolve();
 	void transitionTV();
 	void transitionBlinds();
+	void transitionSnapshotBox();
 
 private:
 	SludgeEngine *_vm;
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index d25817cb2d..af0c9407e0 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -87,38 +87,19 @@ void transitionCrossFader() {
 #endif
 }
 
-void transitionSnapshotBox() {
-#if 0
-	if (! snapshotTextureName) return;
-
-	//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-	glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
-
-	float xScale = (float) brightnessLevel * winWidth / 510.f;// 510 = 255*2
-	float yScale = (float) brightnessLevel * winHeight / 510.f;
-
-	const GLfloat vertices[] = {
-		xScale, winHeight - yScale, 0,
-		winWidth - xScale, winHeight - yScale, 0,
-		xScale, yScale, 0,
-		winWidth - xScale, yScale, 0
-	};
-
-	const GLfloat texCoords[] = {
-		0.0f, snapTexH,
-		snapTexW, snapTexH,
-		0.0f, 0.0f,
-		snapTexW, 0.0f
-	};
+void GraphicsManager::transitionSnapshotBox() {
+	if (!_snapshotSurface.getPixels())
+		return;
 
-	glUseProgram(shader.texture);
+	if (_brightnessLevel == 255)
+		return;
 
-	setPMVMatrix(shader.texture);
+	uint32 xScale = (255 - _brightnessLevel) * _winWidth / 255;
+	uint32 yScale = (255 - _brightnessLevel) * _winHeight / 255;
 
-	drawQuad(shader.texture, vertices, 1, texCoords);
+	Graphics::Surface *surf = _snapshotSurface.scale(xScale, yScale);
 
-	glUseProgram(0);
-#endif
+	_renderSurface.copyRectToSurface(surf->getPixels(), surf->pitch, (_winWidth - xScale) / 2, (_winHeight - yScale) / 2, xScale, yScale);
 }
 
 //----------------------------------------------------


Commit: 7d5788836d6a78447b0b94527102c1ea5969f00f
    https://github.com/scummvm/scummvm/commit/7d5788836d6a78447b0b94527102c1ea5969f00f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T01:55:20+02:00

Commit Message:
SLUDGE: Implement Crossfade transition

This completes all the transition modes

Changed paths:
    engines/sludge/graphics.h
    engines/sludge/transition.cpp


diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index e2ecf5cea6..918f7d68e5 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -192,6 +192,7 @@ public:
 	void transitionTV();
 	void transitionBlinds();
 	void transitionSnapshotBox();
+	void transitionCrossFader();
 
 private:
 	SludgeEngine *_vm;
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index af0c9407e0..929660285d 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -48,43 +48,12 @@ void GraphicsManager::transitionFader() {
 	blendColor(&_renderSurface, TS_ARGB(br, 255, 255, 255), Graphics::BLEND_MULTIPLY);
 }
 
-void transitionCrossFader() {
-#if 0
-	if (! snapshotTextureName) return;
-
-	glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
-
-	glEnable(GL_BLEND);
-
-	const GLfloat vertices[] = {
-		0.f, (GLfloat)winHeight, 0.f,
-		(GLfloat)winWidth, (GLfloat)winHeight, 0.f,
-		0.f, 0.f, 0.f,
-		(GLfloat)winWidth, 0.f, 0.f
-	};
-
-	const GLfloat texCoords[] = {
-		0.0f, snapTexH,
-		snapTexW, snapTexH,
-		0.0f, 0.0f,
-		snapTexW, 0.0f
-	};
-
-	glUseProgram(shader.texture);
-
-	setPMVMatrix(shader.texture);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 1);
-
-	setPrimaryColor(1.0f, 1.0f, 1.0f, 1.0f - brightnessLevel / 255.f);
-
-	drawQuad(shader.texture, vertices, 1, texCoords);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 0);
-	glUseProgram(0);
+void GraphicsManager::transitionCrossFader() {
+	if (!_snapshotSurface.getPixels())
+		return;
 
-	glDisable(GL_BLEND);
-#endif
+	Graphics::TransparentSurface tmp(_snapshotSurface, false);
+	tmp.blit(_renderSurface, 0, 0, Graphics::FLIP_NONE, nullptr, TS_ARGB(255 - _brightnessLevel, 0xff, 0xff, 0xff));
 }
 
 void GraphicsManager::transitionSnapshotBox() {


Commit: df762ea3df3b82df50e7c8304edfbffaa44ce0cc
    https://github.com/scummvm/scummvm/commit/df762ea3df3b82df50e7c8304edfbffaa44ce0cc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T01:55:20+02:00

Commit Message:
SLUDGE: Cleanup and simplify code

Changed paths:
    engines/sludge/transition.cpp


diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 929660285d..d0b88fcca4 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -28,12 +28,7 @@ namespace Sludge {
 extern float snapTexW, snapTexH;
 
 void GraphicsManager::setBrightnessLevel(int brightnessLevel) {
-	if (brightnessLevel < 0)
-		_brightnessLevel = 0;
-	else if (brightnessLevel > 255)
-		_brightnessLevel = 255;
-	else
-		_brightnessLevel = brightnessLevel;
+	_brightnessLevel = CLIP(brightnessLevel, 0, 255);
 }
 
 //----------------------------------------------------
@@ -43,15 +38,16 @@ void GraphicsManager::setBrightnessLevel(int brightnessLevel) {
 unsigned lastFrom, lastTo;
 
 void GraphicsManager::transitionFader() {
-	uint br = MIN<uint>(255, _brightnessLevel);
-
-	blendColor(&_renderSurface, TS_ARGB(br, 255, 255, 255), Graphics::BLEND_MULTIPLY);
+	blendColor(&_renderSurface, TS_ARGB(_brightnessLevel, 255, 255, 255), Graphics::BLEND_MULTIPLY);
 }
 
 void GraphicsManager::transitionCrossFader() {
 	if (!_snapshotSurface.getPixels())
 		return;
 
+	if (_brightnessLevel == 255)
+		return;
+
 	Graphics::TransparentSurface tmp(_snapshotSurface, false);
 	tmp.blit(_renderSurface, 0, 0, Graphics::FLIP_NONE, nullptr, TS_ARGB(255 - _brightnessLevel, 0xff, 0xff, 0xff));
 }
@@ -132,11 +128,9 @@ void GraphicsManager::transitionDisolve() {
 	} while (toScreen < end);
 
 	// The original stretched the texture, we just tile it
-	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
-		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
+	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h)
+		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w)
 			_transitionTexture->blit(_renderSurface, x, y);
-		}
-	}
 }
 
 void GraphicsManager::transitionTV() {
@@ -171,11 +165,9 @@ void GraphicsManager::transitionTV() {
 	} while (toScreen < end);
 
 	// The original stretched the texture, we just tile it
-	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
-		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
+	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h)
+		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w)
 			_transitionTexture->blit(_renderSurface, x, y);
-		}
-	}
 }
 
 void GraphicsManager::transitionBlinds() {
@@ -199,14 +191,12 @@ void GraphicsManager::transitionBlinds() {
 				}
 			}
 		}
-
-		// The original stretched the texture, we just tile it
-		for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
-			for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
-				_transitionTexture->blit(_renderSurface, x, y);
-			}
-		}
 	}
+
+	// The original stretched the texture, we just tile it
+	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h)
+		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w)
+			_transitionTexture->blit(_renderSurface, x, y);
 }
 
 //----------------------------------------------------


Commit: 34f7e04c4f8223213a0adea05c9f560584007995
    https://github.com/scummvm/scummvm/commit/34f7e04c4f8223213a0adea05c9f560584007995
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T01:55:21+02:00

Commit Message:
SLUDGE: Initial code for bg effects

Changed paths:
  R engines/sludge/bg_effects.h
    engines/sludge/bg_effects.cpp
    engines/sludge/builtin.cpp
    engines/sludge/graphics.h
    engines/sludge/saveload.cpp


diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp
index 1c359ed3f5..3e431278ea 100644
--- a/engines/sludge/bg_effects.cpp
+++ b/engines/sludge/bg_effects.cpp
@@ -23,6 +23,7 @@
 #include "common/debug.h"
 #include "common/file.h"
 
+#include "sludge/graphics.h"
 #include "sludge/newfatal.h"
 #include "sludge/variable.h"
 
@@ -106,7 +107,7 @@ static int *s_matrixEffectData = NULL;
 static int s_matrixEffectBase = 0;
 #endif
 
-void blur_saveSettings(Common::WriteStream *stream) {
+void GraphicsManager::blur_saveSettings(Common::WriteStream *stream) {
 	if (s_matrixEffectData) {
 		stream->writeUint32LE(s_matrixEffectDivide);
 		stream->writeUint32LE(s_matrixEffectWidth);
@@ -132,7 +133,7 @@ static int *blur_allocateMemoryForEffect() {
 	return s_matrixEffectData;
 }
 
-void blur_loadSettings(Common::SeekableReadStream *stream) {
+void GraphicsManager::blur_loadSettings(Common::SeekableReadStream *stream) {
 	s_matrixEffectDivide = stream->readUint32LE();
 	s_matrixEffectWidth = stream->readUint32LE();
 	s_matrixEffectHeight = stream->readUint32LE();
@@ -148,7 +149,7 @@ void blur_loadSettings(Common::SeekableReadStream *stream) {
 	}
 }
 
-bool blur_createSettings(int numParams, VariableStack *&stack) {
+bool GraphicsManager::blur_createSettings(int numParams, VariableStack *&stack) {
 	bool createNullThing = true;
 	Common::String error = "";
 
@@ -242,14 +243,6 @@ bool blur_createSettings(int numParams, VariableStack *&stack) {
 	return !createNullThing;
 }
 
-// FIXME - Disabled until blurScreen() is internally implemented where these are used...
-//         although these may be replaced by common/util.h, CLIP() function to replace clampi
-//         and various methods of Graphics::Surface.
-#if 0
-static inline int clampi(int i, int min, int max) {
-	return (i >= max) ? max : ((i <= min) ? min : i);
-}
-
 static inline void blur_createSourceLine(byte *createLine, byte *fromLine, int overlapOnLeft, int width) {
 	int miniX;
 	memcpy(createLine + overlapOnLeft * 4, fromLine, width * 4);
@@ -266,10 +259,8 @@ static inline void blur_createSourceLine(byte *createLine, byte *fromLine, int o
 		createLine[miniX * 4 + 2] = fromLine[width * 4 - 2];
 	}
 }
-#endif
 
-bool blurScreen() {
-#if 0
+bool GraphicsManager::blurScreen() {
 	if (s_matrixEffectWidth && s_matrixEffectHeight && s_matrixEffectDivide && s_matrixEffectData) {
 		byte *thisLine;
 		int y, x;
@@ -281,31 +272,20 @@ bool blurScreen() {
 		if (!checkNew(sourceLine))
 			return false;
 
-		int picWidth = sceneWidth;
-		int picHeight = sceneHeight;
-
-		if (!NPOT_textures) {
-			picWidth = getNextPOT(sceneWidth);
-			picHeight = getNextPOT(sceneHeight);
-		}
-
-		// Retrieve the texture
-		saveTexture(backdropTextureName, backdropTexture);
-
 		for (y = 0; y < s_matrixEffectHeight; y++) {
-			sourceLine[y] = new byte[(s_matrixEffectWidth - 1 + picWidth) * 4];
+			sourceLine[y] = new byte[(s_matrixEffectWidth - 1 + _sceneWidth) * 4];
 			ok &= (sourceLine[y] != NULL);
 		}
 
 		if (ok) {
 			for (y = 0; y < s_matrixEffectHeight; y++) {
-				int miniY = clampi(y - overlapAbove - 1, 0, sceneHeight - 1);
+				int miniY = CLIP<int>(y - overlapAbove - 1, 0, _sceneHeight - 1);
 
-				blur_createSourceLine(sourceLine[y], backdropTexture + miniY * picWidth * 4, overlapOnLeft, picWidth);
+				blur_createSourceLine(sourceLine[y], (byte *)_origBackdropSurface.getBasePtr(0, miniY), overlapOnLeft, _sceneWidth);
 			}
 
-			for (y = 0; y < sceneHeight; y++) {
-				thisLine = backdropTexture + y * picWidth * 4;
+			for (y = 0; y < _sceneHeight; y++) {
+				thisLine = (byte *)_origBackdropSurface.getBasePtr(0, y);
 
 				//-------------------------
 				// Scroll source lines
@@ -317,11 +297,11 @@ bool blurScreen() {
 				sourceLine[s_matrixEffectHeight - 1] = tempLine;
 				{
 					int h = s_matrixEffectHeight - 1;
-					int miniY = clampi(y + (s_matrixEffectHeight - overlapAbove - 1), 0, sceneHeight - 1);
+					int miniY = CLIP<int>(y + (s_matrixEffectHeight - overlapAbove - 1), 0, _sceneHeight - 1);
 
-					blur_createSourceLine(sourceLine[h], backdropTexture + miniY * picWidth * 4, overlapOnLeft, picWidth);
+					blur_createSourceLine(sourceLine[h], (byte *)_origBackdropSurface.getBasePtr(0, miniY), overlapOnLeft, _sceneWidth);
 				}
-				for (x = 0; x < sceneWidth; x++) {
+				for (x = 0; x < _sceneWidth; x++) {
 					int totalRed = 0;
 					int totalGreen = 0;
 					int totalBlue = 0;
@@ -361,13 +341,11 @@ bool blurScreen() {
 		for (y = 0; y < s_matrixEffectHeight; y++) {
 			delete sourceLine[y];
 		}
-		delete sourceLine;
+		delete[] sourceLine;
 		sourceLine = NULL;
 
-		texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, backdropTextureName);
 		return true;
 	}
-#endif
 	return false;
 }
 
diff --git a/engines/sludge/bg_effects.h b/engines/sludge/bg_effects.h
deleted file mode 100644
index e62565d9d8..0000000000
--- a/engines/sludge/bg_effects.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef SLUDGE_BG_EFFECTS_H
-#define SLUDGE_BG_EFFECTS_H
-
-namespace Sludge {
-
-struct VariableStack;
-
-bool blurScreen();
-void blur_saveSettings(Common::WriteStream *stream);
-void blur_loadSettings(Common::SeekableReadStream *stream);
-bool blur_createSettings(int numParams, VariableStack *&stack);
-
-} // End of namespace Sludge
-
-#endif
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index cd969c0220..ae51b11605 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -25,7 +25,6 @@
 #include "common/savefile.h"
 #include "common/system.h"
 
-#include "sludge/bg_effects.h"
 #include "sludge/builtin.h"
 #include "sludge/cursors.h"
 #include "sludge/event.h"
@@ -2524,14 +2523,14 @@ builtIn(_rem_setMaximumAA) {
 
 builtIn(setBackgroundEffect) {
 	UNUSEDALL
-	bool done = blur_createSettings(numParams, fun->stack);
+	bool done = g_sludge->_gfxMan->blur_createSettings(numParams, fun->stack);
 	fun->reg.setVariable(SVT_INT, done ? 1 : 0);
 	return BR_CONTINUE;
 }
 
 builtIn(doBackgroundEffect) {
 	UNUSEDALL
-	bool done = blurScreen();
+	bool done = g_sludge->_gfxMan->blurScreen();
 	fun->reg.setVariable(SVT_INT, done ? 1 : 0);
 	return BR_CONTINUE;
 }
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 918f7d68e5..c51d40f767 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -43,6 +43,7 @@ struct OnScreenPerson;
 struct SpriteBank;
 struct Sprite;
 struct SpriteLayers;
+struct VariableStack;
 struct ZBufferData;
 
 enum ELightMapMode {
@@ -194,6 +195,12 @@ public:
 	void transitionSnapshotBox();
 	void transitionCrossFader();
 
+	// BG effects
+	bool blurScreen();
+	void blur_saveSettings(Common::WriteStream *stream);
+	void blur_loadSettings(Common::SeekableReadStream *stream);
+	bool blur_createSettings(int numParams, VariableStack *&stack);
+
 private:
 	SludgeEngine *_vm;
 
diff --git a/engines/sludge/saveload.cpp b/engines/sludge/saveload.cpp
index 12f71cba0e..f5b483dc53 100644
--- a/engines/sludge/saveload.cpp
+++ b/engines/sludge/saveload.cpp
@@ -24,7 +24,6 @@
 
 #include "common/savefile.h"
 
-#include "sludge/bg_effects.h"
 #include "sludge/cursors.h"
 #include "sludge/errors.h"
 #include "sludge/event.h"
@@ -143,7 +142,7 @@ bool saveGame(const Common::String &fname) {
 
 	fp->writeUint16BE(CustomSaveHelper::_saveEncoding);
 
-	blur_saveSettings(fp);
+	g_sludge->_gfxMan->blur_saveSettings(fp);
 
 	g_sludge->_gfxMan->saveColors(fp);
 
@@ -283,7 +282,7 @@ bool loadGame(const Common::String &fname) {
 			fp->readFloatLE();
 		}
 
-		blur_loadSettings(fp);
+		g_sludge->_gfxMan->blur_loadSettings(fp);
 	}
 
 	if (ssgVersion >= VERSION(1, 3)) {




More information about the Scummvm-git-logs mailing list