[Scummvm-git-logs] scummvm master -> 857dc9b7f00e83df2259c590c211da8396eb4e1a
aquadran
noreply at scummvm.org
Thu Sep 25 19:45:17 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:
857dc9b7f0 WINTERMUTE: Small sync with original code
Commit: 857dc9b7f00e83df2259c590c211da8396eb4e1a
https://github.com/scummvm/scummvm/commit/857dc9b7f00e83df2259c590c211da8396eb4e1a
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-09-25T21:45:13+02:00
Commit Message:
WINTERMUTE: Small sync with original code
Changed paths:
engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
index d0bcdebfcb2..0a6ea5c2ff5 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
@@ -119,96 +119,103 @@ bool BaseSurfaceOpenGL3D::displayTiled(int x, int y, Common::Rect32 rect, int nu
}
bool BaseSurfaceOpenGL3D::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
- BaseImage img = BaseImage();
- if (!img.loadFile(filename)) {
- return false;
- }
-
- if (img.getSurface()->format.bytesPerPixel == 1 && img.getPalette() == nullptr) {
- return false;
- }
-
- _filename = filename;
-
if (defaultCK) {
ckRed = 255;
ckGreen = 0;
ckBlue = 255;
}
- _ckDefault = defaultCK;
- _ckRed = ckRed;
- _ckGreen = ckGreen;
- _ckBlue = ckBlue;
+ BaseImage img = BaseImage();
- bool needsColorKey = false;
- bool replaceAlpha = true;
+ if (lifeTime != -1 && _lifeTime == 0) {
+ _valid = false;
+ } else {
+ if (!img.loadFile(filename)) {
+ return false;
+ }
+
+ if (img.getSurface()->format.bytesPerPixel == 1 && img.getPalette() == nullptr) {
+ return false;
+ }
+ bool needsColorKey = false;
+ bool replaceAlpha = true;
- if (_imageData) {
- _imageData->free();
- delete _imageData;
- _imageData = nullptr;
- }
- _imageData = img.getSurface()->convertTo(Graphics::PixelFormat::createFormatRGBA32(), img.getPalette(), img.getPaletteCount());
+ if (_imageData) {
+ _imageData->free();
+ delete _imageData;
+ _imageData = nullptr;
+ }
- if (_filename.matchString("savegame:*g", true)) {
- uint8 r, g, b, a;
- for (int x = 0; x < _imageData->w; x++) {
- for (int y = 0; y < _imageData->h; y++) {
- _imageData->format.colorToARGB(_imageData->getPixel(x, y), a, r, g, b);
- uint8 grey = (uint8)((0.2126f * r + 0.7152f * g + 0.0722f * b) + 0.5f);
- _imageData->setPixel(x, y, _imageData->format.ARGBToColor(a, grey, grey, grey));
+ _imageData = img.getSurface()->convertTo(Graphics::PixelFormat::createFormatRGBA32(), img.getPalette(), img.getPaletteCount());
+
+ if (_filename.matchString("savegame:*g", true)) {
+ uint8 r, g, b, a;
+ for (int x = 0; x < _imageData->w; x++) {
+ for (int y = 0; y < _imageData->h; y++) {
+ _imageData->format.colorToARGB(_imageData->getPixel(x, y), a, r, g, b);
+ uint8 grey = (uint8)((0.2126f * r + 0.7152f * g + 0.0722f * b) + 0.5f);
+ _imageData->setPixel(x, y, _imageData->format.ARGBToColor(a, grey, grey, grey));
+ }
}
}
- }
- if (_filename.hasSuffix(".bmp")) {
- // Ignores alpha channel for BMPs
- needsColorKey = true;
- } else if (_filename.hasSuffix(".jpg")) {
- // Ignores alpha channel for JPEGs
- needsColorKey = true;
- } else if (BaseEngine::instance().getTargetExecutable() < WME_LITE) {
- // WME 1.x always use colorkey, even for images with transparency
- needsColorKey = true;
- replaceAlpha = false;
- } else if (BaseEngine::instance().isFoxTail()) {
- // FoxTail does not use colorkey
- needsColorKey = false;
- } else if (img.getSurface()->format.aBits() == 0) {
- // generic WME Lite does not use colorkey for non-BMPs with transparency
- needsColorKey = true;
- }
+ if (_filename.hasSuffix(".bmp")) {
+ // Ignores alpha channel for BMPs
+ needsColorKey = true;
+ } else if (_filename.hasSuffix(".jpg")) {
+ // Ignores alpha channel for JPEGs
+ needsColorKey = true;
+ } else if (BaseEngine::instance().getTargetExecutable() < WME_LITE) {
+ // WME 1.x always use colorkey, even for images with transparency
+ needsColorKey = true;
+ replaceAlpha = false;
+ } else if (BaseEngine::instance().isFoxTail()) {
+ // FoxTail does not use colorkey
+ needsColorKey = false;
+ } else if (img.getSurface()->format.aBits() == 0) {
+ // generic WME Lite does not use colorkey for non-BMPs with transparency
+ needsColorKey = true;
+ }
- if (needsColorKey) {
- // We set the pixel color to transparent black,
- // like D3DX, if it matches the color key.
- _imageData->applyColorKey(ckRed, ckGreen, ckBlue, replaceAlpha, 0, 0, 0);
- }
+ if (needsColorKey) {
+ // We set the pixel color to transparent black,
+ // like D3DX, if it matches the color key.
+ _imageData->applyColorKey(ckRed, ckGreen, ckBlue, replaceAlpha, 0, 0, 0);
+ }
- // Bug #6572 WME: Rosemary - Sprite flaw on going upwards
- // Some Rosemary sprites have non-fully transparent pixels
- // 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") && _imageData->format.bytesPerPixel == 4) {
- uint32 mask = _imageData->format.ARGBToColor(255, 0, 0, 0);
- uint32 treshold = _imageData->format.ARGBToColor(16, 0, 0, 0);
- uint32 blank = _imageData->format.ARGBToColor(0, 0, 0, 0);
-
- for (int x = 0; x < _imageData->w; x++) {
- for (int y = 0; y < _imageData->h; y++) {
- uint32 pixel = _imageData->getPixel(x, y);
- if ((pixel & mask) > blank && (pixel & mask) < treshold) {
- _imageData->setPixel(x, y, blank);
+ // Bug #6572 WME: Rosemary - Sprite flaw on going upwards
+ // Some Rosemary sprites have non-fully transparent pixels
+ // 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") && _imageData->format.bytesPerPixel == 4) {
+ uint32 mask = _imageData->format.ARGBToColor(255, 0, 0, 0);
+ uint32 treshold = _imageData->format.ARGBToColor(16, 0, 0, 0);
+ uint32 blank = _imageData->format.ARGBToColor(0, 0, 0, 0);
+
+ for (int x = 0; x < _imageData->w; x++) {
+ for (int y = 0; y < _imageData->h; y++) {
+ uint32 pixel = _imageData->getPixel(x, y);
+ if ((pixel & mask) > blank && (pixel & mask) < treshold) {
+ _imageData->setPixel(x, y, blank);
+ }
}
}
}
+
+ putSurface(*_imageData);
+
+ /* TODO: Delete _imageData if we no longer need to access the pixel data? */
+
+ _valid = true;
}
- putSurface(*_imageData);
+ _ckDefault = defaultCK;
+ _ckRed = ckRed;
+ _ckGreen = ckGreen;
+ _ckBlue = ckBlue;
- /* TODO: Delete _imageData if we no longer need to access the pixel data? */
+ _filename = filename;
if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) {
_lifeTime = lifeTime;
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 0a5ecfeca5c..e454bf45a71 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -79,19 +79,23 @@ BaseSurfaceOSystem::~BaseSurfaceOSystem() {
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
- _filename = filename;
-
if (defaultCK) {
ckRed = 255;
ckGreen = 0;
ckBlue = 255;
}
+ if (lifeTime != -1 && _lifeTime == 0) {
+ _valid = false;
+ }
+
_ckDefault = defaultCK;
_ckRed = ckRed;
_ckGreen = ckGreen;
_ckBlue = ckBlue;
+ _filename = filename;
+
if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) {
_lifeTime = lifeTime;
}
More information about the Scummvm-git-logs
mailing list