[Scummvm-git-logs] scummvm master -> 0565b342a3f6e5529e410e15fbfdb5fb2057e268
ysj1173886760
42030331+ysj1173886760 at users.noreply.github.com
Mon Jul 12 07:25:25 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a2b9aa11f8 DIRECTOR: amend b_fplay
0565b342a3 DIRECTOR: support scaling matte ink bitmap castmember
Commit: a2b9aa11f8c1eef95eb2d4a2e69a7c65c1eaac4c
https://github.com/scummvm/scummvm/commit/a2b9aa11f8c1eef95eb2d4a2e69a7c65c1eaac4c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-12T14:38:23+08:00
Commit Message:
DIRECTOR: amend b_fplay
Changed paths:
engines/director/lingo/xlibs/fplayxobj.cpp
diff --git a/engines/director/lingo/xlibs/fplayxobj.cpp b/engines/director/lingo/xlibs/fplayxobj.cpp
index 224bb60882..c360883378 100644
--- a/engines/director/lingo/xlibs/fplayxobj.cpp
+++ b/engines/director/lingo/xlibs/fplayxobj.cpp
@@ -91,7 +91,7 @@ void FPlayXObj::b_fplay(int nargs) {
}
uint32 tag = MKTAG('s', 'n', 'd', ' ');
- uint id;
+ uint id = 0xFFFF;
Archive *archive = nullptr;
// iterate opened ResFiles
Commit: 0565b342a3f6e5529e410e15fbfdb5fb2057e268
https://github.com/scummvm/scummvm/commit/0565b342a3f6e5529e410e15fbfdb5fb2057e268
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-12T15:24:32+08:00
Commit Message:
DIRECTOR: support scaling matte ink bitmap castmember
Changed paths:
engines/director/castmember.cpp
engines/director/castmember.h
engines/director/channel.cpp
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 9b559e037e..4e7b581f69 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -184,7 +184,7 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
Graphics::MacWidget *widget = new Graphics::MacWidget(g_director->getCurrentWindow(), bbox.left, bbox.top, bbox.width(), bbox.height(), g_director->_wm, false);
// scale for drawing a different size sprite
- if (bbox.width() < _initialRect.width() || bbox.height() < _initialRect.height()) {
+ if (bbox.width() != _initialRect.width() || bbox.height() != _initialRect.height()) {
int scaleX = SCALE_THRESHOLD * _initialRect.width() / bbox.width();
int scaleY = SCALE_THRESHOLD * _initialRect.height() / bbox.height();
@@ -210,12 +210,33 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
return widget;
}
-void BitmapCastMember::createMatte() {
+void BitmapCastMember::createMatte(Common::Rect &bbox) {
// Like background trans, but all white pixels NOT ENCLOSED by coloured pixels
// are transparent
Graphics::Surface tmp;
- tmp.create(_initialRect.width(), _initialRect.height(), g_director->_pixelformat);
- tmp.copyFrom(*_img->getSurface());
+ tmp.create(bbox.width(), bbox.height(), g_director->_pixelformat);
+
+ if (bbox.width() != _initialRect.width() || bbox.height() != _initialRect.height()) {
+
+ int scaleX = SCALE_THRESHOLD * _initialRect.width() / bbox.width();
+ int scaleY = SCALE_THRESHOLD * _initialRect.height() / bbox.height();
+
+ for (int y = 0, scaleYCtr = 0; y < bbox.height(); y++, scaleYCtr += scaleY) {
+ if (g_director->_wm->_pixelformat.bytesPerPixel == 1) {
+ for (int x = 0, scaleXCtr = 0; x < bbox.width(); x++, scaleXCtr += scaleX) {
+ const byte *src = (const byte *)_img->getSurface()->getBasePtr(scaleXCtr / SCALE_THRESHOLD, scaleYCtr / SCALE_THRESHOLD);
+ *(byte *)tmp.getBasePtr(x, y) = *src;
+ }
+ } else {
+ for (int x = 0, scaleXCtr = 0; x < bbox.width(); x++, scaleXCtr += scaleX) {
+ const int *src = (const int *)_img->getSurface()->getBasePtr(scaleXCtr / SCALE_THRESHOLD, scaleYCtr / SCALE_THRESHOLD);
+ *(int *)tmp.getBasePtr(x, y) = *src;
+ }
+ }
+ }
+ } else {
+ tmp.copyFrom(*_img->getSurface());
+ }
_noMatte = true;
@@ -266,10 +287,16 @@ void BitmapCastMember::createMatte() {
tmp.free();
}
-Graphics::Surface *BitmapCastMember::getMatte() {
+Graphics::Surface *BitmapCastMember::getMatte(Common::Rect &bbox) {
// Lazy loading of mattes
if (!_matte && !_noMatte) {
- createMatte();
+ createMatte(bbox);
+ }
+
+ // check for the scale matte
+ Graphics::Surface *surface = _matte ? _matte->getMask() : nullptr;
+ if (surface && (surface->w != bbox.width() || surface->h != bbox.height())) {
+ createMatte(bbox);
}
return _matte ? _matte->getMask() : nullptr;
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index e2e7245865..56e43c3327 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -116,8 +116,8 @@ public:
~BitmapCastMember();
virtual Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel) override;
- void createMatte();
- Graphics::Surface *getMatte();
+ void createMatte(Common::Rect &bbox);
+ Graphics::Surface *getMatte(Common::Rect &bbox);
bool hasField(int field) override;
Datum getField(int field) override;
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index c4d05d13d3..8bed6669b3 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -105,12 +105,14 @@ const Graphics::Surface *Channel::getMask(bool forceMatte) {
_sprite->_ink == kInkTypeNotGhost ||
_sprite->_blend > 0;
+ Common::Rect bbox(getBbox());
+
if (needsMatte || forceMatte) {
// Mattes are only supported in bitmaps for now. Shapes don't need mattes,
// as they already have all non-enclosed white pixels transparent.
// Matte on text has a trivial enough effect to not worry about implementing.
if (_sprite->_cast->_type == kCastBitmap) {
- return ((BitmapCastMember *)_sprite->_cast)->getMatte();
+ return ((BitmapCastMember *)_sprite->_cast)->getMatte(bbox);
} else {
return nullptr;
}
@@ -119,7 +121,6 @@ const Graphics::Surface *Channel::getMask(bool forceMatte) {
CastMember *member = g_director->getCurrentMovie()->getCastMember(maskID);
if (member && member->_initialRect == _sprite->_cast->_initialRect) {
- Common::Rect bbox(getBbox());
Graphics::MacWidget *widget = member->createWidget(bbox, this);
if (_mask)
delete _mask;
@@ -197,7 +198,7 @@ bool Channel::isMouseIn(const Common::Point &pos) {
if (_sprite->_ink == kInkTypeMatte) {
if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap) {
- Graphics::Surface *matte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+ Graphics::Surface *matte = ((BitmapCastMember *)_sprite->_cast)->getMatte(bbox);
return matte ? !(*(byte *)(matte->getBasePtr(pos.x - bbox.left, pos.y - bbox.top))) : true;
}
}
@@ -216,9 +217,9 @@ bool Channel::isMatteIntersect(Channel *channel) {
Graphics::Surface *yourMatte = nullptr;
if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap)
- myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+ myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte(myBbox);
if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
- yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+ yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte(yourBbox);
if (myMatte && yourMatte) {
for (int i = intersectRect.top; i < intersectRect.bottom; i++) {
@@ -246,9 +247,9 @@ bool Channel::isMatteWithin(Channel *channel) {
Graphics::Surface *yourMatte = nullptr;
if (_sprite->_cast && _sprite->_cast->_type == kCastBitmap)
- myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+ myMatte = ((BitmapCastMember *)_sprite->_cast)->getMatte(myBbox);
if (channel->_sprite->_cast && channel->_sprite->_cast->_type == kCastBitmap)
- yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte();
+ yourMatte = ((BitmapCastMember *)channel->_sprite->_cast)->getMatte(yourBbox);
if (myMatte && yourMatte) {
for (int i = intersectRect.top; i < intersectRect.bottom; i++) {
More information about the Scummvm-git-logs
mailing list