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

sev- noreply at scummvm.org
Tue Oct 24 16:31:34 UTC 2023


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

Summary:
b292e202ce SLUDGE: Replace TransparentSurfaces with ManagedSurfaces


Commit: b292e202cedaa49452a067fdfd659842391afb2e
    https://github.com/scummvm/scummvm/commit/b292e202cedaa49452a067fdfd659842391afb2e
Author: polyesterswing (kurianjojo2004 at gmail.com)
Date: 2023-10-24T18:31:31+02:00

Commit Message:
SLUDGE: Replace TransparentSurfaces with ManagedSurfaces

Changed paths:
    engines/sludge/backdrop.cpp
    engines/sludge/graphics.h
    engines/sludge/sprites.cpp
    engines/sludge/thumbnail.cpp
    engines/sludge/transition.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index eb01e8bff03..4bf665476ad 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -113,10 +113,11 @@ void GraphicsManager::drawParallax() {
 
 		debugC(1, kSludgeDebugGraphics, "drawParallax(): camX: %d camY: %d dims: %d x %d sceneDims: %d x %d winDims: %d x %d surf: %d x %d", p->cameraX, p->cameraY, w, h, _sceneWidth, _sceneHeight, _winWidth, _winHeight, p->surface.w, p->surface.h);
 
-		Graphics::TransparentSurface tmp(p->surface, false);
+		Graphics::ManagedSurface tmp(&(p->surface), DisposeAfterUse::NO);
+
 		for (uint y = 0; y < _sceneHeight; y += p->surface.h) {
 			for (uint x = 0; x < _sceneWidth; x += p->surface.w) {
-				tmp.blit(_renderSurface, x - p->cameraX, y - p->cameraY);
+				tmp.blendBlitTo(_renderSurface, x - p->cameraX, y - p->cameraY);
 				debugC(3, kSludgeDebugGraphics, "drawParallax(): blit to: %d, %d", x - p->cameraX, y - p->cameraY);
 			}
 		}
@@ -322,8 +323,8 @@ void GraphicsManager::drawHorizontalLine(uint x1, uint y, uint x2) {
 }
 
 void GraphicsManager::darkScreen() {
-	Graphics::TransparentSurface tmp(_backdropSurface, false);
-	tmp.blit(_backdropSurface, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 >> 1, 0, 0, 0));
+	Graphics::ManagedSurface tmp(&_backdropSurface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_backdropSurface, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 >> 1, 0, 0, 0));
 
 	// reset zBuffer
 	if (_zBuffer->originalNum >= 0) {
@@ -338,8 +339,8 @@ void GraphicsManager::drawBackDrop() {
 	if (!_backdropExists)
 		return;
 	// draw backdrop
-	Graphics::TransparentSurface tmp(_backdropSurface, false);
-	tmp.blit(_renderSurface, -_cameraX, -_cameraY);
+	Graphics::ManagedSurface tmp(&_backdropSurface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_renderSurface, -_cameraX, -_cameraY);
 }
 
 bool GraphicsManager::loadLightMap(int v) {
@@ -351,16 +352,16 @@ bool GraphicsManager::loadLightMap(int v) {
 	_lightMapNumber = v;
 	_lightMap.create(_sceneWidth, _sceneWidth, *_vm->getScreenPixelFormat());
 
-	Graphics::TransparentSurface tmp;
+	Graphics::ManagedSurface tmp;
 
-	if (!ImgLoader::loadImage(v, "lightmap", g_sludge->_resMan->getData(), &tmp))
+	if (!ImgLoader::loadImage(v, "lightmap", g_sludge->_resMan->getData(), tmp.surfacePtr()))
 		return false;
 
 	if (tmp.w != (int16)_sceneWidth || tmp.h != (int16)_sceneHeight) {
 		if (_lightMapMode == LIGHTMAPMODE_HOTSPOT) {
 			return fatal("Light map width and height don't match scene width and height. That is required for lightmaps in HOTSPOT mode.");
 		} else if (_lightMapMode == LIGHTMAPMODE_PIXEL) {
-			tmp.blit(_lightMap, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), (int)_sceneWidth, (int)_sceneHeight);
+			tmp.blendBlitTo(_lightMap, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), (int)_sceneWidth, (int)_sceneHeight);
 		} else {
 			_lightMap.copyFrom(tmp);
 		}
@@ -434,8 +435,8 @@ bool GraphicsManager::loadHSI(int num, Common::SeekableReadStream *stream, int x
 		_backdropSurface.fillRect(Common::Rect(x, y, x + tmp.w, y + tmp.h), _renderSurface.format.ARGBToColor(0, 0, 0, 0));
 
 	// copy surface loaded to backdrop
-	Graphics::TransparentSurface tmp_trans(tmp, false);
-	tmp_trans.blit(_backdropSurface, x, y);
+	Graphics::ManagedSurface tmp_trans(&tmp, DisposeAfterUse::NO);
+	tmp_trans.blendBlitTo(_backdropSurface, x, y);
 	tmp.free();
 
 	_origBackdropSurface.copyFrom(_backdropSurface);
@@ -460,8 +461,8 @@ bool GraphicsManager::mixHSI(int num, Common::SeekableReadStream *stream, int x,
 	if (x < 0 || x + realPicWidth > _sceneWidth || y < 0 || y + realPicHeight > _sceneHeight)
 		return false;
 
-	Graphics::TransparentSurface tmp(mixSurface, false);
-	tmp.blit(_backdropSurface, x, y, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 >> 1, 255, 255, 255));
+	Graphics::ManagedSurface tmp(&mixSurface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_backdropSurface, x, y, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 >> 1, 255, 255, 255));
 	mixSurface.free();
 
 	return true;
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 7d3acaa15d0..de510b6ba19 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -263,7 +263,7 @@ private:
 
 	uint32 _randbuffer[RANDKK][2];
 	int _randp1, _randp2;
-	Graphics::TransparentSurface *_transitionTexture;
+	Graphics::ManagedSurface *_transitionTexture;
 
 	// Parallax
 	ParallaxLayers *_parallaxLayers;
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index a073d629e1d..42e43ae24f6 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -279,9 +279,10 @@ void GraphicsManager::pasteSpriteToBackDrop(int x1, int y1, Sprite &single, cons
 
 	x1 -= single.xhot;
 	y1 -= single.yhot;
-	Graphics::TransparentSurface tmp(single.surface, false);
-	tmp.blit(_backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr,
-			MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
+
+	Graphics::ManagedSurface tmp(&single.surface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr, MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
+
 }
 
 // burnSpriteToBackDrop adds text in the colour specified by setBurnColour
@@ -301,8 +302,9 @@ void GraphicsManager::burnSpriteToBackDrop(int x1, int y1, Sprite &single, const
 
 	x1 -= single.xhot;
 	y1 -= single.yhot - 1;
-	Graphics::TransparentSurface tmp(single.burnSurface, false);
-	tmp.blit(_backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr,
+
+	Graphics::ManagedSurface tmp(&single.surface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_backdropSurface, x1, y1, Graphics::FLIP_NONE, nullptr,
 			MS_RGB(_currentBurnR, _currentBurnG, _currentBurnB));
 }
 
@@ -315,13 +317,13 @@ void GraphicsManager::fontSprite(bool flip, int x, int y, Sprite &single, const
 	float x1 = (float)x - (float)single.xhot / _cameraZoom;
 	float y1 = (float)y - (float)single.yhot / _cameraZoom;
 
-	// Use Transparent surface to scale and blit
-	Graphics::TransparentSurface tmp(single.surface, false);
-	tmp.blit(_renderSurface, x1, y1, (flip ? Graphics::FLIP_H : Graphics::FLIP_NONE), 0, MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
+	// Use Managed surface to scale and blit
+	Graphics::ManagedSurface tmp(&single.surface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_renderSurface, x1, y1, (flip ? Graphics::FLIP_H : Graphics::FLIP_NONE), 0, MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
 
 	if (single.burnSurface.getPixels() != nullptr) {
-		Graphics::TransparentSurface tmp2(single.burnSurface, false);
-		tmp2.blit(_renderSurface, x1, y1, (flip ? Graphics::FLIP_H : Graphics::FLIP_NONE), 0, MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
+		Graphics::ManagedSurface tmp2(&single.burnSurface, DisposeAfterUse::NO);
+		tmp2.blendBlitTo(_renderSurface, x1, y1, (flip ? Graphics::FLIP_H : Graphics::FLIP_NONE), 0, MS_RGB(fontPal.originalRed, fontPal.originalGreen, fontPal.originalBlue));
 
 	}
 }
@@ -341,10 +343,9 @@ Graphics::Surface *GraphicsManager::duplicateSurface(Graphics::Surface *surface)
 }
 
 void GraphicsManager::blendColor(Graphics::Surface *blitted, uint32 color, Graphics::TSpriteBlendMode mode) {
-	Graphics::TransparentSurface tmp;
-	tmp.create(blitted->w, blitted->h, blitted->format);
+	Graphics::ManagedSurface tmp(blitted->w, blitted->h, blitted->format);
 	tmp.fillRect(Common::Rect(0, 0, tmp.w, tmp.h), color);
-	tmp.blit(*blitted, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), (int)blitted->w, (int)blitted->h, mode);
+	tmp.blendBlitTo(*blitted, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), (int)blitted->w, (int)blitted->h, mode);
 	tmp.free();
 }
 
@@ -374,14 +375,15 @@ Graphics::Surface *GraphicsManager::applyLightmapToSprite(Graphics::Surface *&bl
 			toDetele = blitted = duplicateSurface(blitted);
 
 			// apply light map texture
-			Graphics::TransparentSurface tmp(_lightMap, false);
-			Common::Rect rect_none(x1, y1, x1 + diffX, y1 + diffY);
+			Graphics::ManagedSurface tmp(&_lightMap, DisposeAfterUse::NO);
 			Common::Rect rect_h(_sceneWidth - x1 - diffX, y1, _sceneWidth - x1, y1 + diffY);
-			tmp.blit(*blitted, 0, 0,
+			Common::Rect rect_none(x1, y1, x1 + diffX, y1 + diffY);
+			tmp.blendBlitTo(*blitted, 0, 0,
 					(mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE),
 					(mirror ? &rect_h : &rect_none),
 					MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255),
 					(int)blitted->w, (int)blitted->h, Graphics::BLEND_MULTIPLY);
+
 		} else {
 			curLight[0] = curLight[1] = curLight[2] = 255;
 		}
@@ -463,10 +465,11 @@ bool GraphicsManager::scaleSprite(Sprite &single, const SpritePalette &fontPal,
 	Graphics::Surface *blitted = &single.surface;
 	Graphics::Surface *ptr = applyLightmapToSprite(blitted, thisPerson, mirror, x, y, x1, y1, diffX, diffY);
 
-	// Use Transparent surface to scale and blit
+	// Use Managed surface to scale and blit
 	if (!_zBuffer->numPanels) {
-		Graphics::TransparentSurface tmp(*blitted, false);
-		tmp.blit(_renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, MS_ARGB(255 - thisPerson->transparency, 255, 255, 255), diffX, diffY);
+		Graphics::ManagedSurface tmp(&single.surface, DisposeAfterUse::NO);
+		tmp.blendBlitTo(_renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, MS_ARGB(255 - thisPerson->transparency, 255, 255, 255), diffX, diffY);
+
 		if (ptr) {
 			ptr->free();
 			delete ptr;
@@ -526,8 +529,8 @@ void GraphicsManager::displaySpriteLayers() {
 		debugC(3, kSludgeDebugGraphics, "Display layer %i with %i sprites", i, _spriteLayers->layer[i].size());
 		SpriteLayer::iterator it;
 		for (it = _spriteLayers->layer[i].begin(); it != _spriteLayers->layer[i].end(); ++it) {
-			Graphics::TransparentSurface tmp(*(*it)->surface, false);
-			tmp.blit(_renderSurface, (*it)->x, (*it)->y, (*it)->flip, nullptr, MS_ARGB((*it)->transparency, 255, 255, 255), (*it)->width, (*it)->height);
+			Graphics::ManagedSurface tmp((*it)->surface, DisposeAfterUse::NO);
+			tmp.blendBlitTo(_renderSurface, (*it)->x, (*it)->y, (*it)->flip, nullptr, MS_ARGB((*it)->transparency, 255, 255, 255), (*it)->width, (*it)->height);
 		}
 	}
 	killSpriteLayers();
@@ -581,8 +584,9 @@ void GraphicsManager::fixScaleSprite(int x, int y, Sprite &single, const SpriteP
 
 	// draw sprite
 	if (!_zBuffer->numPanels) {
-		Graphics::TransparentSurface tmp(single.surface, false);
-		tmp.blit(_renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), diffX, diffY);
+		Graphics::ManagedSurface tmp(&single.surface, DisposeAfterUse::NO);
+		tmp.blendBlitTo(_renderSurface, x1, y1, (mirror ? Graphics::FLIP_H : Graphics::FLIP_NONE), nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), diffX, diffY);
+
 		if (ptr) {
 			ptr->free();
 			delete ptr;
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index 56234bc2868..030c9d5df7c 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -94,8 +94,8 @@ void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int
 		int fileWidth = fp->readUint32LE();
 		int fileHeight = fp->readUint32LE();
 
-		Graphics::TransparentSurface thumbnail;
-		if (!ImgLoader::loadPNGImage(fp, &thumbnail))
+		Graphics::ManagedSurface thumbnail;
+		if (!ImgLoader::loadPNGImage(fp, thumbnail.surfacePtr()))
 			return;
 
 		delete fp;
@@ -115,7 +115,7 @@ void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int
 		if (fileHeight + atY > (int)_sceneHeight)
 			fileHeight = _sceneHeight - atY;
 
-		thumbnail.blit(_backdropSurface, atX, atY, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), fileWidth, fileHeight);
+		thumbnail.blendBlitTo(_backdropSurface, atX, atY, Graphics::FLIP_NONE, nullptr, MS_ARGB((uint)255, (uint)255, (uint)255, (uint)255), fileWidth, fileHeight);
 		thumbnail.free();
 	}
 }
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 00b6f074b1f..30cf894f914 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -47,8 +47,8 @@ void GraphicsManager::transitionCrossFader() {
 	if (_brightnessLevel == 255)
 		return;
 
-	Graphics::TransparentSurface tmp(_snapshotSurface, false);
-	tmp.blit(_renderSurface, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 - _brightnessLevel, 0xff, 0xff, 0xff));
+	Graphics::ManagedSurface tmp(&_snapshotSurface, DisposeAfterUse::NO);
+	tmp.blendBlitTo(_renderSurface, 0, 0, Graphics::FLIP_NONE, nullptr, MS_ARGB(255 - _brightnessLevel, 0xff, 0xff, 0xff));
 }
 
 void GraphicsManager::transitionSnapshotBox() {
@@ -85,9 +85,9 @@ void GraphicsManager::resetRandW() {
 }
 
 void GraphicsManager::reserveTransitionTexture() {
-	_transitionTexture = new Graphics::TransparentSurface;
+	_transitionTexture = new Graphics::ManagedSurface;
 
-	_transitionTexture->create(256, 256, _transitionTexture->getSupportedPixelFormat());
+	_transitionTexture->create(256, 256);
 }
 
 void GraphicsManager::transitionDisolve() {
@@ -129,7 +129,7 @@ void GraphicsManager::transitionDisolve() {
 	// 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);
+			_transitionTexture->blendBlitTo(_renderSurface, x, y);
 }
 
 void GraphicsManager::transitionTV() {
@@ -166,7 +166,7 @@ void GraphicsManager::transitionTV() {
 	// 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);
+			_transitionTexture->blendBlitTo(_renderSurface, x, y);
 }
 
 void GraphicsManager::transitionBlinds() {
@@ -195,7 +195,7 @@ 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);
+			_transitionTexture->blendBlitTo(_renderSurface, x, y);
 }
 
 //----------------------------------------------------




More information about the Scummvm-git-logs mailing list