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

aquadran noreply at scummvm.org
Thu Jun 12 05:01:38 UTC 2025


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

Summary:
8c92429d7e WINTERMUTE: Cleanup in 2D renderer


Commit: 8c92429d7e3fb96e44a959a88ffb0c2e6adb1136
    https://github.com/scummvm/scummvm/commit/8c92429d7e3fb96e44a959a88ffb0c2e6adb1136
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-06-12T07:01:33+02:00

Commit Message:
WINTERMUTE: Cleanup in 2D renderer

Changed paths:
    engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
    engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
    engines/wintermute/base/gfx/osystem/base_surface_osystem.h
    engines/wintermute/base/gfx/osystem/render_ticket.cpp


diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index bbf61904d7e..ce616b87d9a 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -198,7 +198,7 @@ bool BaseRenderOSystem::flip() {
 		if (_disableDirtyRects || screenChanged) {
 			g_system->copyRectToScreen(_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
 		}
-		//  g_system->copyRectToScreen(_renderSurface->getPixels(), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height());
+		// g_system->copyRectToScreen(_renderSurface->getPixels(), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height());
 		delete _dirtyRect;
 		_dirtyRect = nullptr;
 		_needsFlip = false;
@@ -230,8 +230,8 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) {
 		return STATUS_OK;
 	}
 	if (!rect) {
-// TODO: This should speed things up, but for some reason it misses the size by quite a bit.
-/*		if (r == 0 && g == 0 && b == 0) {
+		// TODO: This should speed things up, but for some reason it misses the size by quite a bit.
+		/*if (r == 0 && g == 0 && b == 0) {
 			// Simply memcpy from the buffered black-surface, way faster than Surface::fillRect.
 			memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h);
 			return STATUS_OK;
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 083de50e0a8..485874e94a7 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -75,9 +75,7 @@ BaseSurfaceOSystem::~BaseSurfaceOSystem() {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
-	/*  BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); */
 	_filename = filename;
-//	const Graphics::Surface *surface = image->getSurface();
 
 	if (defaultCK) {
 		ckRed   = 255;
@@ -166,7 +164,7 @@ bool BaseSurfaceOSystem::finishLoad() {
 	// In original WME it wasn't seen because sprites were downscaled
 	// Let's set alpha to 0 if it is smaller then some treshold
 	if (BaseEngine::instance().getGameId() == "rosemary" && _filename.hasPrefix("actors") &&
-            _alphaType == Graphics::ALPHA_FULL && _surface->format.aBits() > 4) {
+	    _alphaType == Graphics::ALPHA_FULL && _surface->format.aBits() > 4) {
 		uint32 mask = _surface->format.ARGBToColor(255, 0, 0, 0);
 		uint32 treshold = _surface->format.ARGBToColor(16, 0, 0, 0);
 		uint32 blank = _surface->format.ARGBToColor(0, 0, 0, 0);
@@ -186,53 +184,6 @@ bool BaseSurfaceOSystem::finishLoad() {
 	return true;
 }
 
-//////////////////////////////////////////////////////////////////////////
-void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) {
-	warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet");
-	return;
-	// TODO: Reimplement this
-	delete[] _alphaMask;
-	_alphaMask = nullptr;
-	if (!surface) {
-		return;
-	}
-
-	bool hasColorKey;
-	/* uint32 colorKey; */
-	uint8 ckRed, ckGreen, ckBlue;
-	/*  if (SDL_GetColorKey(surface, &colorKey) == 0) {
-	        hasColorKey = true;
-	        SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue);
-	    } else hasColorKey = false;
-	*/
-	_alphaMask = new byte[surface->w * surface->h];
-
-	bool hasTransparency = false;
-	for (int y = 0; y < surface->h; y++) {
-		for (int x = 0; x < surface->w; x++) {
-			uint32 pixel = surface->getPixel(x, y);
-
-			uint8 r, g, b, a;
-			surface->format.colorToARGB(pixel, a, r, g, b);
-			//SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a);
-
-			if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) {
-				a = 0;
-			}
-
-			_alphaMask[y * surface->w + x] = a;
-			if (a < 255) {
-				hasTransparency = true;
-			}
-		}
-	}
-
-	if (!hasTransparency) {
-		delete[] _alphaMask;
-		_alphaMask = nullptr;
-	}
-}
-
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::create(int width, int height) {
 	_width = width;
@@ -268,7 +219,6 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::startPixelOp() {
-	//SDL_LockTexture(_texture, nullptr, &_lockPixels, &_lockPitch);
 	// Any pixel-op makes the caching useless:
 	BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
 	renderer->invalidateTicketsFromSurface(this);
@@ -277,7 +227,6 @@ bool BaseSurfaceOSystem::startPixelOp() {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::endPixelOp() {
-	//SDL_UnlockTexture(_texture);
 	return STATUS_OK;
 }
 
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 83e1eecd7c8..b2b1725cdc3 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -57,9 +57,6 @@ public:
 	bool display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
 	bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) override;
 	bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
-	/*  static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
-	    static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin);
-	    static long DLL_CALLCONV TellProc(fi_handle handle);*/
 	int getWidth() override {
 		if (!_loaded) {
 			finishLoad();
@@ -96,7 +93,6 @@ private:
 	bool _loaded;
 	bool finishLoad();
 	bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transformStruct);
-	void genAlphaMask(Graphics::Surface *surface);
 
 	float _rotation;
 	Graphics::AlphaType _alphaType;
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index d9d73812073..03641d9f89f 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -61,8 +61,8 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
 		if (_transform._angle != Graphics::kDefaultAngle) {
 			_surface = temp.rotoscale(transform, owner->_gameRef->getBilinearFiltering());
 		} else if ((dstRect->width() != srcRect->width() ||
-					dstRect->height() != srcRect->height()) &&
-					_transform._numTimesX * _transform._numTimesY == 1) {
+			    dstRect->height() != srcRect->height()) &&
+			    _transform._numTimesX * _transform._numTimesY == 1) {
 			_surface = temp.scale(dstRect->width(), dstRect->height(), owner->_gameRef->getBilinearFiltering());
 		} else {
 			_surface = new Graphics::Surface();
@@ -120,7 +120,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
 		int x = _dstRect.left;
 		for (int rx = 0; rx < _transform._numTimesX; ++rx) {
 			src.blendBlitTo(*_targetSurface, x, y, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height(),
-				Graphics::BLEND_NORMAL, alphaMode);
+			                Graphics::BLEND_NORMAL, alphaMode);
 			x += w;
 		}
 		y += h;
@@ -152,12 +152,9 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
 	}
 
 	if (_transform._numTimesX * _transform._numTimesY == 1) {
-
 		src.blendBlitTo(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(),
 			clipRect->height(), _transform._blendMode, alphaMode);
-
 	} else {
-
 		// clipRect is a subrect of the full numTimesX*numTimesY rect
 		Common::Rect subRect;
 
@@ -173,7 +170,6 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
 		for (int ry = 0; ry < _transform._numTimesY; ++ry) {
 			int x = 0;
 			for (int rx = 0; rx < _transform._numTimesX; ++rx) {
-
 				subRect.left = x;
 				subRect.top = y;
 				subRect.setWidth(w);
@@ -184,7 +180,6 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
 					subRect.translate(-x, -y);
 					src.blendBlitTo(*_targetSurface, basex + x + subRect.left, basey + y + subRect.top, _transform._flip, &subRect,
 						_transform._rgbaMod, subRect.width(), subRect.height(), _transform._blendMode, alphaMode);
-
 				}
 
 				x += w;




More information about the Scummvm-git-logs mailing list