[Scummvm-git-logs] scummvm master -> ac803c670ff947b8e5fd4981683633ae06aa1e13
bluegr
noreply at scummvm.org
Sat Aug 5 06:51:55 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:
ac803c670f BURIED: Make use of Graphics::keyBlit()
Commit: ac803c670ff947b8e5fd4981683633ae06aa1e13
https://github.com/scummvm/scummvm/commit/ac803c670ff947b8e5fd4981683633ae06aa1e13
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-08-05T09:51:52+03:00
Commit Message:
BURIED: Make use of Graphics::keyBlit()
Changed paths:
engines/buried/biochip_view.cpp
engines/buried/graphics.cpp
engines/buried/graphics.h
engines/buried/inventory_info.cpp
engines/buried/inventory_window.cpp
engines/buried/scene_view.cpp
engines/buried/sprtdata.h
diff --git a/engines/buried/biochip_view.cpp b/engines/buried/biochip_view.cpp
index 4af9a6ab42a..46aaffc8df2 100644
--- a/engines/buried/biochip_view.cpp
+++ b/engines/buried/biochip_view.cpp
@@ -475,7 +475,7 @@ bool EvidenceBioChipViewWindow::rebuildMainPrebuffer() {
if (frame) {
byte transparentColor = _vm->isTrueColor() ? 255 : 248;
- _vm->_gfx->opaqueTransparentBlit(&_preBuffer, _evidence[i].left, _evidence[i].top, 203, 34, frame, 2, 2, 0, transparentColor, transparentColor, transparentColor);
+ _vm->_gfx->keyBlit(&_preBuffer, _evidence[i].left, _evidence[i].top, 203, 34, frame, 2, 2, transparentColor, transparentColor, transparentColor);
}
}
}
@@ -562,11 +562,11 @@ void InterfaceBioChipViewWindow::onPaint() {
if (_caret) {
if (_vm->isDemo()) {
- _vm->_gfx->opaqueTransparentBlit(_vm->_gfx->getScreen(), absoluteRect.left + _transLocation + 12, absoluteRect.top + 112, 20, 35, _caret, 0, 0, 0, 255, 255, 255);
+ _vm->_gfx->keyBlit(_vm->_gfx->getScreen(), absoluteRect.left + _transLocation + 12, absoluteRect.top + 112, 20, 35, _caret, 0, 0, 255, 255, 255);
} else {
// For whatever reason, the Spanish version has to be different.
int dy = (_vm->getLanguage() == Common::ES_ESP) ? 115 : 97;
- _vm->_gfx->opaqueTransparentBlit(_vm->_gfx->getScreen(), absoluteRect.left + _transLocation + 14, absoluteRect.top + dy, 15, 30, _caret, 0, 0, 0, 248, _vm->isTrueColor() ? 252 : 248, 248);
+ _vm->_gfx->keyBlit(_vm->_gfx->getScreen(), absoluteRect.left + _transLocation + 14, absoluteRect.top + dy, 15, 30, _caret, 0, 0, 248, _vm->isTrueColor() ? 252 : 248, 248);
}
}
}
diff --git a/engines/buried/graphics.cpp b/engines/buried/graphics.cpp
index 53ffdcdc7eb..f655fb231d1 100644
--- a/engines/buried/graphics.cpp
+++ b/engines/buried/graphics.cpp
@@ -309,7 +309,39 @@ void GraphicsManager::fillRect(const Common::Rect &rect, uint32 color) {
_screen->fillRect(rect, color);
}
-void GraphicsManager::opaqueTransparentBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, int xSrc, int ySrc, int opacityValue, byte rTrans, byte gTrans, byte bTrans) {
+void GraphicsManager::keyBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, uint32 transColor) {
+ assert(dst->format.bytesPerPixel == src->format.bytesPerPixel);
+
+ w = MIN<int>(src->w, w);
+ h = MIN<int>(src->h, h);
+
+ Common::Rect srcRect(xSrc, ySrc, xSrc + w, ySrc + h);
+ Common::Rect dstRect(xDst, yDst, xDst + w, yDst + h);
+
+ dst->clip(srcRect, dstRect);
+ dst->copyRectToSurfaceWithKey(*src, xDst, yDst, srcRect, transColor);
+}
+
+void GraphicsManager::keyBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, byte rTrans, byte gTrans, byte bTrans) {
+ if (_vm->isTrueColor()) {
+ keyBlit(dst, xDst, yDst, w, h, src, xSrc, ySrc, getColor(rTrans, gTrans, bTrans));
+ } else {
+ // Find the palette index of the color
+ int paletteIndex = -1;
+ for (int i = 0; i < 256; i++) {
+ if (_palette[i * 3] == rTrans && _palette[i * 3 + 1] == gTrans && _palette[i * 3 + 2] == bTrans) {
+ paletteIndex = i;
+ break;
+ }
+ }
+
+ assert(paletteIndex >= 0);
+
+ keyBlit(dst, xDst, yDst, w, h, src, xSrc, ySrc, paletteIndex);
+ }
+}
+
+void GraphicsManager::opaqueTransparentBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, int opacityValue, byte rTrans, byte gTrans, byte bTrans) {
if (_vm->isTrueColor()) {
uint32 transColor = getColor(rTrans, gTrans, bTrans);
@@ -369,31 +401,7 @@ void GraphicsManager::opaqueTransparentBlit(Graphics::Surface *dst, int xDst, in
}
}
} else {
- // Find the palette index of the color
- int paletteIndex = -1;
- for (int i = 0; i < 256; i++) {
- if (_palette[i * 3] == rTrans && _palette[i * 3 + 1] == gTrans && _palette[i * 3 + 2] == bTrans) {
- paletteIndex = i;
- break;
- }
- }
-
- assert(paletteIndex >= 0);
-
- for (int y = 0; y < h; y++) {
- if (y + yDst < dst->h && y + yDst >= 0) {
- for (int x = 0; x < w; x++) {
- if (x + xDst < dst->w && x + xDst >= 0) {
- byte color = *((const byte *)src->getBasePtr(x + xSrc, y + ySrc));
-
- if (color == paletteIndex)
- continue;
-
- *((byte *)dst->getBasePtr(x + xDst, y + yDst)) = color;
- }
- }
- }
- }
+ keyBlit(dst, xDst, yDst, w, h, src, xSrc, ySrc, rTrans, gTrans, bTrans);
}
}
@@ -546,7 +554,7 @@ int GraphicsManager::computeVPushOffset(int speed) {
return 189;
}
-void GraphicsManager::crossBlit(Graphics::Surface *dst, int xDst, int yDst, uint w, uint h, const Graphics::Surface *src, int xSrc, int ySrc) {
+void GraphicsManager::crossBlit(Graphics::Surface *dst, int xDst, int yDst, uint w, uint h, const Graphics::Surface *src, uint xSrc, uint ySrc) {
assert(dst->format.bytesPerPixel == src->format.bytesPerPixel);
for (uint y = 0; y < h; y++)
diff --git a/engines/buried/graphics.h b/engines/buried/graphics.h
index ccd7bba51bd..96ec573304c 100644
--- a/engines/buried/graphics.h
+++ b/engines/buried/graphics.h
@@ -98,9 +98,11 @@ public:
void blit(const Graphics::Surface *surface, int x, int y, uint width, uint height);
void blit(const Graphics::Surface *surface, const Common::Rect &srcRect, const Common::Rect &dstRect);
void fillRect(const Common::Rect &rect, uint32 color);
- void opaqueTransparentBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, int xSrc, int ySrc, int opacityValue, byte r, byte g, byte b);
+ void keyBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, uint32 transColor);
+ void keyBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, byte rTrans, byte gTrans, byte bTrans);
+ void opaqueTransparentBlit(Graphics::Surface *dst, int xDst, int yDst, int w, int h, const Graphics::Surface *src, uint xSrc, uint ySrc, int opacityValue, byte r, byte g, byte b);
bool checkPointAgainstMaskedBitmap(const Graphics::Surface *bitmap, int x, int y, const Common::Point &point, byte rTrans, byte gTrans, byte bTrans);
- void crossBlit(Graphics::Surface *dst, int xDst, int yDst, uint w, uint h, const Graphics::Surface *src, int xSrc, int ySrc);
+ void crossBlit(Graphics::Surface *dst, int xDst, int yDst, uint w, uint h, const Graphics::Surface *src, uint xSrc, uint ySrc);
void renderText(Graphics::Surface *dst, Graphics::Font *font, const Common::String &text, int x, int y, int w, int h, uint32 color, int lineHeight, TextAlign textAlign = kTextAlignLeft, bool centerVertically = false);
void renderText(Graphics::Surface *dst, Graphics::Font *font, const Common::U32String &text, int x, int y, int w, int h, uint32 color, int lineHeight, TextAlign textAlign = kTextAlignLeft, bool centerVertically = false);
void drawEllipse(const Common::Rect &rect, uint32 color);
diff --git a/engines/buried/inventory_info.cpp b/engines/buried/inventory_info.cpp
index b071a036f09..9cd1695d0ea 100644
--- a/engines/buried/inventory_info.cpp
+++ b/engines/buried/inventory_info.cpp
@@ -179,7 +179,7 @@ void BurnedLetterViewWindow::onPaint() {
}
Common::Rect absoluteRect = getAbsoluteRect();
- _vm->_gfx->opaqueTransparentBlit(_vm->_gfx->getScreen(), absoluteRect.left, absoluteRect.top, absoluteRect.width(), absoluteRect.height(), _preBuffer, 0, 0, 0, 0, 0, 0);
+ _vm->_gfx->keyBlit(_vm->_gfx->getScreen(), absoluteRect.left, absoluteRect.top, absoluteRect.width(), absoluteRect.height(), _preBuffer, 0, 0, 0, 0, 0);
if (_curLineIndex >= 0 && ((SceneViewWindow *)_parent)->getGlobalFlags().bcTranslateEnabled == 1) {
int numLines = _viewLineCount[_curView];
diff --git a/engines/buried/inventory_window.cpp b/engines/buried/inventory_window.cpp
index c897956d068..dbc735a74a7 100644
--- a/engines/buried/inventory_window.cpp
+++ b/engines/buried/inventory_window.cpp
@@ -251,14 +251,9 @@ bool InventoryWindow::startDraggingNewItem(int itemID, const Common::Point &poin
_draggingItemSpriteData.height = _draggingItemSpriteData.image->h;
if (_vm->isTrueColor()) {
- _draggingItemSpriteData.redTrans = 255;
- _draggingItemSpriteData.greenTrans = 255;
- _draggingItemSpriteData.blueTrans = 255;
+ _draggingItemSpriteData.transColor = _vm->_gfx->getColor(255, 255, 255);
} else {
- byte firstPixel = *((byte *)_draggingItemSpriteData.image->getBasePtr(0, 0));
- _draggingItemSpriteData.redTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3];
- _draggingItemSpriteData.greenTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 1];
- _draggingItemSpriteData.blueTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 2];
+ _draggingItemSpriteData.transColor = _draggingItemSpriteData.image->getPixel(0, 0);
}
setCapture();
@@ -433,14 +428,9 @@ void InventoryWindow::onLButtonDown(const Common::Point &point, uint flags) {
_draggingItemSpriteData.height = _draggingItemSpriteData.image->h;
if (_vm->isTrueColor()) {
- _draggingItemSpriteData.redTrans = 255;
- _draggingItemSpriteData.greenTrans = 255;
- _draggingItemSpriteData.blueTrans = 255;
+ _draggingItemSpriteData.transColor = _vm->_gfx->getColor(255, 255, 255);
} else {
- byte firstPixel = *((byte *)_draggingItemSpriteData.image->getBasePtr(0, 0));
- _draggingItemSpriteData.redTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3];
- _draggingItemSpriteData.greenTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 1];
- _draggingItemSpriteData.blueTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 2];
+ _draggingItemSpriteData.transColor = _draggingItemSpriteData.image->getPixel(0, 0);
}
setCapture();
@@ -673,14 +663,9 @@ void InventoryWindow::onMouseMove(const Common::Point &point, uint flags) {
_draggingIconIndex = newIcon;
if (_vm->isTrueColor()) {
- _draggingItemSpriteData.redTrans = 255;
- _draggingItemSpriteData.greenTrans = 255;
- _draggingItemSpriteData.blueTrans = 255;
+ _draggingItemSpriteData.transColor = _vm->_gfx->getColor(255, 255, 255);
} else {
- byte firstPixel = *((byte *)_draggingItemSpriteData.image->getBasePtr(0, 0));
- _draggingItemSpriteData.redTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3];
- _draggingItemSpriteData.greenTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 1];
- _draggingItemSpriteData.blueTrans = _vm->_gfx->getDefaultPalette()[firstPixel * 3 + 2];
+ _draggingItemSpriteData.transColor = _draggingItemSpriteData.image->getPixel(0, 0);
}
}
}
diff --git a/engines/buried/scene_view.cpp b/engines/buried/scene_view.cpp
index 43813583a24..abc40d9a7ec 100644
--- a/engines/buried/scene_view.cpp
+++ b/engines/buried/scene_view.cpp
@@ -2352,7 +2352,7 @@ void SceneViewWindow::onPaint() {
// If we have a sprite, update the prebuffer with it now
if (_currentSprite.image && _useSprite)
- _vm->_gfx->opaqueTransparentBlit(_preBuffer, _currentSprite.xPos, _currentSprite.yPos, _currentSprite.width, _currentSprite.height, _currentSprite.image, 0, 0, 0, _currentSprite.redTrans, _currentSprite.greenTrans, _currentSprite.blueTrans);
+ _vm->_gfx->keyBlit(_preBuffer, _currentSprite.xPos, _currentSprite.yPos, _currentSprite.width, _currentSprite.height, _currentSprite.image, 0, 0, _currentSprite.transColor);
// Update the screen
_vm->_gfx->blit(_preBuffer, _rect.left, _rect.top);
diff --git a/engines/buried/sprtdata.h b/engines/buried/sprtdata.h
index 9b088b2622b..e798570fbb9 100644
--- a/engines/buried/sprtdata.h
+++ b/engines/buried/sprtdata.h
@@ -39,9 +39,7 @@ struct Sprite {
int16 yPos;
int16 width;
int16 height;
- byte redTrans;
- byte greenTrans;
- byte blueTrans;
+ uint32 transColor;
};
} // End of namespace Buried
More information about the Scummvm-git-logs
mailing list