[Scummvm-git-logs] scummvm master -> d71d4c2d3696b3ec682cf8165b70128d067a3115
sev-
noreply at scummvm.org
Fri Aug 25 23:26:58 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:
d71d4c2d36 SWORD25: Add support for opaque blending modes
Commit: d71d4c2d3696b3ec682cf8165b70128d067a3115
https://github.com/scummvm/scummvm/commit/d71d4c2d3696b3ec682cf8165b70128d067a3115
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-08-26T01:26:55+02:00
Commit Message:
SWORD25: Add support for opaque blending modes
Changed paths:
engines/sword25/gfx/dynamicbitmap.cpp
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/gfx/image/renderedimage.h
diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp
index 4a8ea7ff1dc..96322ad4f8c 100644
--- a/engines/sword25/gfx/dynamicbitmap.cpp
+++ b/engines/sword25/gfx/dynamicbitmap.cpp
@@ -56,7 +56,7 @@ bool DynamicBitmap::createRenderedImage(uint width, uint height) {
_originalWidth = _width = width;
_originalHeight = _height = height;
- _image->setIsTransparent(false);
+ _image->setAlphaType(Graphics::ALPHA_OPAQUE);
_isSolid = true;
return result;
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index c8fe203fd88..b3f9bbdb07f 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -99,7 +99,7 @@ static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSiz
}
RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
- _isTransparent(true) {
+ _alphaType(Graphics::ALPHA_FULL) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
@@ -140,11 +140,7 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
delete[] pFileData;
_doCleanup = true;
-
-#if defined(SCUMM_LITTLE_ENDIAN)
- // Makes sense for LE only at the moment
- checkForTransparency();
-#endif
+ _alphaType = checkForTransparency();
return;
}
@@ -152,7 +148,7 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
// -----------------------------------------------------------------------------
RenderedImage::RenderedImage(uint width, uint height, bool &result) :
- _isTransparent(true) {
+ _alphaType(Graphics::ALPHA_FULL) {
_surface.create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
@@ -164,7 +160,7 @@ RenderedImage::RenderedImage(uint width, uint height, bool &result) :
return;
}
-RenderedImage::RenderedImage() : _isTransparent(true) {
+RenderedImage::RenderedImage() : _alphaType(Graphics::ALPHA_FULL) {
_backSurface = Kernel::getInstance()->getGfx()->getSurface();
_surface.format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
@@ -235,7 +231,7 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe
if (width == -1) width = pPartRect ? pPartRect->width() : _surface.w;
if (height == -1) height = pPartRect ? pPartRect->height() : _surface.h;
- _surface.blendBlitTo(*_backSurface, posX, posY, newFlipping, pPartRect, _surface.format.ARGBToColor(ca, cr, cg, cb), width, height);
+ _surface.blendBlitTo(*_backSurface, posX, posY, newFlipping, pPartRect, _surface.format.ARGBToColor(ca, cr, cg, cb), width, height, Graphics::BLEND_NORMAL, _alphaType);
return true;
}
@@ -264,18 +260,24 @@ void RenderedImage::copyDirectly(int posX, int posY) {
g_system->copyRectToScreen(data, _backSurface->pitch, posX, posY, w, h);
}
-void RenderedImage::checkForTransparency() {
+Graphics::AlphaType RenderedImage::checkForTransparency() const {
// Check if the source bitmap has any transparent pixels at all
- _isTransparent = false;
- byte *data = (byte *)_surface.getPixels();
+ Graphics::AlphaType alphaType = Graphics::ALPHA_OPAQUE;
+ uint32 mask = _surface.format.ARGBToColor(0xff, 0, 0, 0);
+ const uint32 *data = (const uint32 *)_surface.getPixels();
+
for (int i = 0; i < _surface.h; i++) {
for (int j = 0; j < _surface.w; j++) {
- _isTransparent = data[3] != 0xff;
- if (_isTransparent)
- return;
- data += 4;
+ if ((*data & mask) != mask) {
+ if ((*data & mask) != 0)
+ return Graphics::ALPHA_FULL;
+ else
+ alphaType = Graphics::ALPHA_BINARY;
+ }
+ data++;
}
}
+ return alphaType;
}
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/renderedimage.h b/engines/sword25/gfx/image/renderedimage.h
index 480b55c2e26..719645071fe 100644
--- a/engines/sword25/gfx/image/renderedimage.h
+++ b/engines/sword25/gfx/image/renderedimage.h
@@ -104,17 +104,17 @@ public:
return true;
}
- void setIsTransparent(bool isTransparent) { _isTransparent = isTransparent; }
- bool isSolid() const override { return !_isTransparent; }
+ void setAlphaType(Graphics::AlphaType alphaType) { _alphaType = alphaType; }
+ bool isSolid() const override { return _alphaType == Graphics::ALPHA_OPAQUE; }
private:
Graphics::ManagedSurface _surface;
+ Graphics::AlphaType _alphaType;
bool _doCleanup;
- bool _isTransparent;
Graphics::ManagedSurface *_backSurface;
- void checkForTransparency();
+ Graphics::AlphaType checkForTransparency() const;
};
} // End of namespace Sword25
More information about the Scummvm-git-logs
mailing list