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

bluegr noreply at scummvm.org
Wed Jun 18 20:07:08 UTC 2025


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

Summary:
9512b04067 WINTERMUTE: Require startPixelOp and endPixelOp for all surface reads
1a7511b4b9 WINTERMUTE: Explicitly create surfaces used for TrueType fonts
ed966ccc16 WINTERMUTE: Support invalidating surfaces with the 2D renderer


Commit: 9512b040670deed2dd41e7804d0cb56844fce11c
    https://github.com/scummvm/scummvm/commit/9512b040670deed2dd41e7804d0cb56844fce11c
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-18T23:07:04+03:00

Commit Message:
WINTERMUTE: Require startPixelOp and endPixelOp for all surface reads

Changed paths:
    engines/wintermute/base/base_sub_frame.cpp
    engines/wintermute/base/gfx/base_surface.cpp
    engines/wintermute/base/gfx/base_surface.h
    engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
    engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h
    engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
    engines/wintermute/base/gfx/osystem/base_surface_osystem.h
    engines/wintermute/ext/wme_vlink.cpp
    engines/wintermute/video/video_theora_player.cpp


diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index b6f1b884422..e27f0623d0f 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -463,9 +463,14 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS
 		int x = stack->pop()->getInt();
 		int y = stack->pop()->getInt();
 		byte r, g, b, a;
-		if (_surface && _surface->getPixel(x, y, &r, &g, &b, &a)) {
-			uint32 pixel = BYTETORGBA(r, g, b, a);
-			stack->pushInt(pixel);
+		if (_surface && _surface->startPixelOp()) {
+			if (_surface->getPixel(x, y, &r, &g, &b, &a)) {
+				uint32 pixel = BYTETORGBA(r, g, b, a);
+				stack->pushInt(pixel);
+			} else {
+				stack->pushNULL();
+			}
+			_surface->endPixelOp();
 		} else {
 			stack->pushNULL();
 		}
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp
index 633faeaca8e..313ba3344a6 100644
--- a/engines/wintermute/base/gfx/base_surface.cpp
+++ b/engines/wintermute/base/gfx/base_surface.cpp
@@ -39,8 +39,6 @@ BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) {
 
 	_filename = "";
 
-	_pixelOpReady = false;
-
 	_ckDefault = true;
 	_ckRed = _ckGreen = _ckBlue = 0;
 	_lifeTime = 0;
@@ -52,9 +50,6 @@ BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) {
 
 //////////////////////////////////////////////////////////////////////
 BaseSurface::~BaseSurface() {
-	if (_pixelOpReady) {
-		endPixelOp();
-	}
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -64,7 +59,13 @@ bool BaseSurface::restore() {
 
 //////////////////////////////////////////////////////////////////////
 bool BaseSurface::isTransparentAt(int x, int y) {
-	return false;
+	if (startPixelOp()) {
+		bool retval = isTransparentAtLite(x, y);
+		endPixelOp();
+		return retval;
+	} else {
+		return false;
+	}
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -77,36 +78,6 @@ bool BaseSurface::create(int width, int height) {
 	return STATUS_FAILED;
 }
 
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::startPixelOp() {
-	return STATUS_FAILED;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::endPixelOp() {
-	return STATUS_FAILED;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) {
-	return STATUS_FAILED;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) {
-	return STATUS_FAILED;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) {
-	return false;
-}
-
-//////////////////////////////////////////////////////////////////////
-bool BaseSurface::isTransparentAtLite(int x, int y) {
-	return false;
-}
-
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurface::invalidate() {
 	return STATUS_FAILED;
diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h
index 1c4ea459534..7413be72b50 100644
--- a/engines/wintermute/base/gfx/base_surface.h
+++ b/engines/wintermute/base/gfx/base_surface.h
@@ -43,7 +43,6 @@ public:
 	bool _valid;
 	int32 _lifeTime;
 
-	bool _pixelOpReady;
 	BaseSurface(BaseGame *inGame);
 	~BaseSurface() override;
 
@@ -63,12 +62,10 @@ public:
 	virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) {
 		return STATUS_FAILED;
 	}
-	virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1);
-	virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = nullptr);
-	virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1);
-	virtual bool startPixelOp();
-	virtual bool endPixelOp();
-	virtual bool isTransparentAtLite(int x, int y);
+	virtual bool startPixelOp() = 0;
+	virtual bool endPixelOp() = 0;
+	virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = nullptr) const = 0;
+	virtual bool isTransparentAtLite(int x, int y) const = 0;
 	void setSize(int width, int height);
 
 	int _referenceCount;
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
index 79b028bd11b..9f04972394e 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
@@ -35,7 +35,7 @@
 namespace Wintermute {
 
 BaseSurfaceOpenGL3D::BaseSurfaceOpenGL3D(BaseGame *game, BaseRenderer3D *renderer)
-	: BaseSurface(game), _tex(0), _renderer(renderer), _imageData(nullptr), _maskData(nullptr), _texWidth(0), _texHeight(0) {
+	: BaseSurface(game), _tex(0), _renderer(renderer), _imageData(nullptr), _maskData(nullptr), _texWidth(0), _texHeight(0), _pixelOpReady(false) {
 }
 
 BaseSurfaceOpenGL3D::~BaseSurfaceOpenGL3D() {
@@ -71,12 +71,6 @@ bool BaseSurfaceOpenGL3D::invalidate() {
 	return true;
 }
 
-bool BaseSurfaceOpenGL3D::isTransparentAt(int x, int y) {
-	prepareToDraw();
-
-	return isTransparentAtLite(x, y);
-}
-
 bool BaseSurfaceOpenGL3D::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
 	prepareToDraw();
 
@@ -275,7 +269,11 @@ bool BaseSurfaceOpenGL3D::putSurface(const Graphics::Surface &surface, bool hasA
 	return true;
 }
 
-bool BaseSurfaceOpenGL3D::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) {
+bool BaseSurfaceOpenGL3D::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) const {
+	if (!_pixelOpReady) {
+		return false;
+	}
+
 	if (x < 0 || y < 0 || x >= _width || y >= _height) {
 		return false;
 	}
@@ -294,15 +292,22 @@ bool BaseSurfaceOpenGL3D::getPixel(int x, int y, byte *r, byte *g, byte *b, byte
 }
 
 bool BaseSurfaceOpenGL3D::startPixelOp() {
-	prepareToDraw();
+	if (!prepareToDraw())
+		return false;
+	_pixelOpReady = true;
 	return true;
 }
 
 bool BaseSurfaceOpenGL3D::endPixelOp() {
+	_pixelOpReady = false;
 	return true;
 }
 
-bool BaseSurfaceOpenGL3D::isTransparentAtLite(int x, int y) {
+bool BaseSurfaceOpenGL3D::isTransparentAtLite(int x, int y) const {
+	if (!_pixelOpReady) {
+		return false;
+	}
+
 	if (x < 0 || y < 0 || x >= _width || y >= _height) {
 		return false;
 	}
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h
index 481c46bcb16..77288062cd7 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.h
@@ -40,7 +40,6 @@ public:
 
 	bool invalidate() override;
 
-	bool isTransparentAt(int x, int y) override;
 	bool displayTransRotate(int x, int y, float rotate, int32 hotspotX, int32 hotspotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
 	bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
 	bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
@@ -50,10 +49,10 @@ public:
 	bool create(int width, int height) override;
 	bool setAlphaImage(const Common::String &filename) override;
 	bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
-	bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = nullptr) override;
+	bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = nullptr) const override;
 	bool startPixelOp() override;
 	bool endPixelOp() override;
-	bool isTransparentAtLite(int x, int y) override;
+	bool isTransparentAtLite(int x, int y) const override;
 
 	void setTexture();
 
@@ -76,6 +75,7 @@ private:
 	Graphics::Surface *_maskData;
 	uint _texWidth;
 	uint _texHeight;
+	bool _pixelOpReady;
 
 	void writeAlpha(Graphics::Surface *surface, const Graphics::Surface *mask);
 };
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index c388ab45f2f..845956547da 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -49,11 +49,10 @@ namespace Wintermute {
 //////////////////////////////////////////////////////////////////////////
 BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) {
 	_surface = new Graphics::Surface();
+	_pixelOpReady = false;
 	_alphaMask = nullptr;
 	_alphaType = Graphics::ALPHA_FULL;
 	_alphaMaskType = Graphics::ALPHA_OPAQUE;
-	_lockPixels = nullptr;
-	_lockPitch = 0;
 	_loaded = false;
 	_rotation = 0;
 }
@@ -210,13 +209,13 @@ bool BaseSurfaceOSystem::create(int width, int height) {
 	return STATUS_OK;
 }
 
-//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::isTransparentAt(int x, int y) {
-	return isTransparentAtLite(x, y);
-}
 
 //////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) {
+bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) const {
+	if (!_pixelOpReady) {
+		return false;
+	}
+
 	if (x < 0 || x >= _surface->w || y < 0 || y >= _surface->h) {
 		return true;
 	}
@@ -233,14 +232,18 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::startPixelOp() {
-	// Any pixel-op makes the caching useless:
-	BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
-	renderer->invalidateTicketsFromSurface(this);
+	if (!_loaded) {
+		if (DID_FAIL(finishLoad())) {
+			return STATUS_FAILED;
+		}
+	}
+	_pixelOpReady = true;
 	return STATUS_OK;
 }
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::endPixelOp() {
+	_pixelOpReady = false;
 	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 dee4ff2fa24..0cab8ba69db 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -47,9 +47,7 @@ public:
 
 	bool setAlphaImage(const Common::String &filename) override;
 
-	bool isTransparentAt(int x, int y) override;
-	bool isTransparentAtLite(int x, int y) override;
-
+	bool isTransparentAtLite(int x, int y) const override;
 	bool startPixelOp() override;
 	bool endPixelOp() override;
 
@@ -77,9 +75,9 @@ public:
 		}
 		return _height;
 	}
-	bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) override {
-		if (!_loaded) {
-			finishLoad();
+	bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) const override {
+		if (!_pixelOpReady) {
+			return STATUS_FAILED;
 		}
 		if (_surface) {
 			uint32 pixel = _surface->getPixel(x, y);
@@ -97,10 +95,9 @@ private:
 	bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transformStruct);
 	void writeAlpha(Graphics::Surface *surface, const Graphics::Surface *mask);
 
+	bool _pixelOpReady;
 	float _rotation;
 	Graphics::AlphaType _alphaType;
-	void *_lockPixels;
-	int _lockPitch;
 	Graphics::Surface *_alphaMask;
 	Graphics::AlphaType _alphaMaskType;
 };
diff --git a/engines/wintermute/ext/wme_vlink.cpp b/engines/wintermute/ext/wme_vlink.cpp
index 5099476bf90..8bcd8902034 100644
--- a/engines/wintermute/ext/wme_vlink.cpp
+++ b/engines/wintermute/ext/wme_vlink.cpp
@@ -127,9 +127,7 @@ bool SXVlink::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
 					if (_updateNeeded) {
 						{
 							Common::StackLock lock(_frameMutex);
-							texture->startPixelOp();
 							texture->putSurface(_surface, false);
-							texture->endPixelOp();
 						}
 						texture->display(0, 0, Rect32(texture->getWidth(), texture->getHeight()));
 						_updateNeeded = false;
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index f7ab965f3f1..2ce3e1621ac 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -346,12 +346,9 @@ bool VideoTheoraPlayer::writeVideo(const Graphics::Surface *decodedFrame) {
 		return STATUS_FAILED;
 	}
 
-	_texture->startPixelOp();
-
 	_texture->putSurface(*decodedFrame, false);
 	//RenderFrame(_texture, &yuv);
 
-	_texture->endPixelOp();
 	_videoFrameReady = true;
 	return STATUS_OK;
 }


Commit: 1a7511b4b9543b3128322e50d25fe757656fa953
    https://github.com/scummvm/scummvm/commit/1a7511b4b9543b3128322e50d25fe757656fa953
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-18T23:07:04+03:00

Commit Message:
WINTERMUTE: Explicitly create surfaces used for TrueType fonts

Changed paths:
    engines/wintermute/base/font/base_font_truetype.cpp


diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp
index 367b00d43d0..ccdc6cb848e 100644
--- a/engines/wintermute/base/font/base_font_truetype.cpp
+++ b/engines/wintermute/base/font/base_font_truetype.cpp
@@ -287,6 +287,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
 	}
 
 	BaseSurface *retSurface = _gameRef->_renderer->createSurface();
+	retSurface->create(surface->w, surface->h);
 	retSurface->putSurface(*surface, true);
 	surface->free();
 	delete surface;


Commit: ed966ccc161cf2228e06a54d6fecdc351dd39b0a
    https://github.com/scummvm/scummvm/commit/ed966ccc161cf2228e06a54d6fecdc351dd39b0a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-18T23:07:04+03:00

Commit Message:
WINTERMUTE: Support invalidating surfaces with the 2D renderer

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


diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 845956547da..1f90bf9f3eb 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -53,13 +53,14 @@ BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) {
 	_alphaMask = nullptr;
 	_alphaType = Graphics::ALPHA_FULL;
 	_alphaMaskType = Graphics::ALPHA_OPAQUE;
-	_loaded = false;
 	_rotation = 0;
 }
 
 //////////////////////////////////////////////////////////////////////////
 BaseSurfaceOSystem::~BaseSurfaceOSystem() {
 	if (_surface) {
+		if (_valid)
+			_gameRef->addMem(-_width * _height * 4);
 		_surface->free();
 		delete _surface;
 		_surface = nullptr;
@@ -71,7 +72,6 @@ BaseSurfaceOSystem::~BaseSurfaceOSystem() {
 		_alphaMask = nullptr;
 	}
 
-	_gameRef->addMem(-_width * _height * 4);
 	BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
 	renderer->invalidateTicketsFromSurface(this);
 }
@@ -110,15 +110,17 @@ bool BaseSurfaceOSystem::finishLoad() {
 		return false;
 	}
 
-	_width = image->getSurface()->w;
-	_height = image->getSurface()->h;
-
 	if (_surface) {
+		if (_valid)
+			_gameRef->addMem(-_width * _height * 4);
 		_surface->free();
 		delete _surface;
 		_surface = nullptr;
 	}
 
+	_width = image->getSurface()->w;
+	_height = image->getSurface()->h;
+
 	bool needsColorKey = false;
 	bool replaceAlpha = true;
 	if (image->getSurface()->format.bytesPerPixel == 1) {
@@ -133,6 +135,8 @@ bool BaseSurfaceOSystem::finishLoad() {
 		_surface->copyFrom(*image->getSurface());
 	}
 
+	_gameRef->addMem(_width * _height * 4);
+
 	if (_filename.matchString("savegame:*g", true)) {
 		uint8 r, g, b, a;
 		for (int x = 0; x < _surface->w; x++) {
@@ -168,8 +172,6 @@ bool BaseSurfaceOSystem::finishLoad() {
 	_alphaType = _surface->detectAlpha();
 	_valid = true;
 
-	_gameRef->addMem(_width * _height * 4);
-
 	delete image;
 
 	// Bug #6572 WME: Rosemary - Sprite flaw on going upwards
@@ -192,16 +194,20 @@ bool BaseSurfaceOSystem::finishLoad() {
 		}
 	}
 
-	_loaded = true;
 
 	return true;
 }
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::create(int width, int height) {
+	if (_valid)
+		_gameRef->addMem(-_width * _height * 4);
+	_surface->free();
+
 	_width = width;
 	_height = height;
 
+	_surface->create(_width, _height, g_system->getScreenFormat());
 	_gameRef->addMem(_width * _height * 4);
 
 	_valid = true;
@@ -209,6 +215,20 @@ bool BaseSurfaceOSystem::create(int width, int height) {
 	return STATUS_OK;
 }
 
+//////////////////////////////////////////////////////////////////////////
+bool BaseSurfaceOSystem::invalidate() {
+	if (_pixelOpReady) {
+		return STATUS_FAILED;
+	}
+
+	if (_valid) {
+		_gameRef->addMem(-_width * _height * 4);
+		_surface->free();
+		_valid = false;
+	}
+
+	return STATUS_OK;
+}
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) const {
@@ -232,7 +252,7 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) const {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::startPixelOp() {
-	if (!_loaded) {
+	if (!_valid) {
 		if (DID_FAIL(finishLoad())) {
 			return STATUS_FAILED;
 		}
@@ -243,6 +263,7 @@ bool BaseSurfaceOSystem::startPixelOp() {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSurfaceOSystem::endPixelOp() {
+	_lastUsedTime = _gameRef->getLiveTimer()->getTime();
 	_pixelOpReady = false;
 	return STATUS_OK;
 }
@@ -295,7 +316,10 @@ bool BaseSurfaceOSystem::displayTiled(int x, int y, Rect32 rect, int numTimesX,
 bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transform) {
 	BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
 
-	if (!_loaded) {
+	_lastUsedTime = _gameRef->getLiveTimer()->getTime();
+
+	// TODO: Skip this check if we can reuse an existing ticket?
+	if (!_valid) {
 		finishLoad();
 	}
 
@@ -350,14 +374,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
 }
 
 bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) {
-	_loaded = true;
-	if (surface.format == _surface->format && surface.w == _surface->w && surface.h == _surface->h) {
-		_surface->copyRectToSurface(surface, 0, 0, Common::Rect(surface.w, surface.h));
-	} else {
-		_surface->free();
-		_surface->copyFrom(surface);
-	}
-
+	_surface->copyRectToSurface(surface, 0, 0, Common::Rect(surface.w, surface.h));
 	writeAlpha(_surface, _alphaMask);
 
 	if (hasAlpha) {
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 0cab8ba69db..4448c5311b9 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -47,6 +47,8 @@ public:
 
 	bool setAlphaImage(const Common::String &filename) override;
 
+	bool invalidate() override;
+
 	bool isTransparentAtLite(int x, int y) const override;
 	bool startPixelOp() override;
 	bool endPixelOp() override;
@@ -58,21 +60,15 @@ public:
 	bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) override;
 	bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
 	int getWidth() override {
-		if (!_loaded) {
+		if (_width == 0) {
 			finishLoad();
 		}
-		if (_surface) {
-			return _surface->w;
-		}
 		return _width;
 	}
 	int getHeight() override {
-		if (!_loaded) {
+		if (_height == 0) {
 			finishLoad();
 		}
-		if (_surface) {
-			return _surface->h;
-		}
 		return _height;
 	}
 	bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) const override {
@@ -90,7 +86,6 @@ public:
 	Graphics::AlphaType getAlphaType() const { return _alphaType; }
 private:
 	Graphics::Surface *_surface;
-	bool _loaded;
 	bool finishLoad();
 	bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transformStruct);
 	void writeAlpha(Graphics::Surface *surface, const Graphics::Surface *mask);




More information about the Scummvm-git-logs mailing list