[Scummvm-git-logs] scummvm master -> 279e83fda88d070d539f6de5405634888c051e4c
npjg
nathanael.gentrydb8 at gmail.com
Thu Jun 25 16:05:24 UTC 2020
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:
279e83fda8 DIRECTOR: Clean up rendering parameters
Commit: 279e83fda88d070d539f6de5405634888c051e4c
https://github.com/scummvm/scummvm/commit/279e83fda88d070d539f6de5405634888c051e4c
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-25T12:05:20-04:00
Commit Message:
DIRECTOR: Clean up rendering parameters
Sprite-rendering functionality is split out from frame-rendering, and the frame
can be optionally blitted on a surface other than the main one.
Changed paths:
engines/director/ink.cpp
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-the.cpp
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/ink.cpp b/engines/director/ink.cpp
index 83c396d464..fe47037589 100644
--- a/engines/director/ink.cpp
+++ b/engines/director/ink.cpp
@@ -27,7 +27,7 @@
namespace Director {
-void Score::inkBasedBlit(Graphics::ManagedSurface *maskSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect, uint spriteId) {
+void Score::inkBasedBlit(Graphics::ManagedSurface *destSurface, Graphics::ManagedSurface *maskSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect, uint spriteId) {
byte rSrc, gSrc, bSrc;
byte rDst, gDst, bDst;
@@ -68,17 +68,17 @@ void Score::inkBasedBlit(Graphics::ManagedSurface *maskSurface, const Graphics::
// TODO: Merge these two into the switch logic that is below
if (ink == kInkTypeMatte) {
Common::Rect spriteRect(spriteSurface.w, spriteSurface.h);
- drawMatteSprite(spriteSurface, t);
+ drawMatteSprite(destSurface, spriteSurface, t);
return;
} else if (ink == kInkTypeReverse) {
- drawReverseSprite(spriteSurface, t, spriteId);
+ drawReverseSprite(destSurface, spriteSurface, t, spriteId);
return;
}
for (int ii = 0; ii < drawRect.height(); ii++) {
const byte *msk = (const byte *)_maskSurface->getBasePtr(t.left + maskOrigin.x, t.top + maskOrigin.y + ii);
const byte *src = (const byte *)spriteSurface.getBasePtr(maskOrigin.x, ii + maskOrigin.y);
- byte *dst = (byte *)_surface->getBasePtr(t.left + maskOrigin.x, t.top + maskOrigin.y + ii);
+ byte *dst = (byte *)destSurface->getBasePtr(t.left + maskOrigin.x, t.top + maskOrigin.y + ii);
for (int j = 0; j < drawRect.width(); j++, msk++, src++, dst++) {
if (*msk) {
@@ -160,7 +160,7 @@ void Score::inkBasedBlit(Graphics::ManagedSurface *maskSurface, const Graphics::
}
}
-void Score::drawReverseSprite(const Graphics::Surface &sprite, Common::Rect &drawRect, uint16 spriteId) {
+void Score::drawReverseSprite(Graphics::ManagedSurface *destSurface, const Graphics::Surface &sprite, Common::Rect &drawRect, uint16 spriteId) {
Common::Rect srcRect(sprite.w, sprite.h);
if (!_surface->clip(srcRect, drawRect))
@@ -170,7 +170,7 @@ void Score::drawReverseSprite(const Graphics::Surface &sprite, Common::Rect &dra
for (int ii = 0; ii < drawRect.height(); ii++) {
const byte *msk = (const byte *)_maskSurface->getBasePtr(drawRect.left, drawRect.top + ii);
const byte *src = (const byte *)sprite.getBasePtr(srcRect.left, srcRect.top + ii);
- byte *dst = (byte *)_surface->getBasePtr(drawRect.left, drawRect.top + ii);
+ byte *dst = (byte *)destSurface->getBasePtr(drawRect.left, drawRect.top + ii);
byte srcColor = *src;
for (int j = 0; j < drawRect.width(); j++, msk++, src++, dst++) {
@@ -210,7 +210,7 @@ void Score::drawReverseSprite(const Graphics::Surface &sprite, Common::Rect &dra
}
}
-void Score::drawMatteSprite(const Graphics::Surface &sprite, Common::Rect &drawRect) {
+ void Score::drawMatteSprite(Graphics::ManagedSurface *destSurface, const Graphics::Surface &sprite, Common::Rect &drawRect) {
// Like background trans, but all white pixels NOT ENCLOSED by coloured pixels are transparent
Graphics::Surface tmp;
tmp.copyFrom(sprite);
@@ -241,7 +241,7 @@ void Score::drawMatteSprite(const Graphics::Surface &sprite, Common::Rect &drawR
for (int yy = 0; yy < drawRect.height(); yy++) {
const byte *msk = (const byte *)_maskSurface->getBasePtr(drawRect.left, drawRect.top + yy);
const byte *src = (const byte *)tmp.getBasePtr(srcRect.left, srcRect.top + yy);
- byte *dst = (byte *)_surface->getBasePtr(drawRect.left, drawRect.top + yy);
+ byte *dst = (byte *)destSurface->getBasePtr(drawRect.left, drawRect.top + yy);
for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++, msk++)
if (*msk != 0)
@@ -264,7 +264,7 @@ void Score::drawMatteSprite(const Graphics::Surface &sprite, Common::Rect &drawR
for (int yy = 0; yy < drawRect.height(); yy++) {
const byte *src = (const byte *)tmp.getBasePtr(srcRect.left, srcRect.top + yy);
const byte *mask = (const byte *)ff.getMask()->getBasePtr(srcRect.left, srcRect.top + yy);
- byte *dst = (byte *)_surface->getBasePtr(drawRect.left, drawRect.top + yy);
+ byte *dst = (byte *)destSurface->getBasePtr(drawRect.left, drawRect.top + yy);
for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++, mask++)
if (*mask == 0)
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 519ac0a0c9..5c7a6b5802 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1889,7 +1889,7 @@ void LB::b_updateStage(int nargs) {
return;
}
- score->renderFrame(score->getCurrentFrame(), false, true);
+ score->renderFrame(score->getCurrentFrame(), kRenderUpdateStageOnly);
g_director->processEvents(true);
if (debugChannelSet(-1, kDebugFewFramesOnly)) {
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index e72dba4bd4..25421b8246 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -648,7 +648,7 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
score->_stageColor = _vm->transformColor(d.asInt());
if (score->_surface) {
score->_surface->clear(score->_stageColor);
- score->renderFrame(score->getCurrentFrame(), true);
+ score->renderFrame(score->getCurrentFrame(), kRenderForceUpdate);
} else {
warning("setStageColor: score has no surface, skipping");
}
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 747141468b..9086848c58 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -563,10 +563,29 @@ void Score::update() {
_nextFrameTime += 1000;
}
-void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly) {
-
+void Score::renderFrame(uint16 frameId, RenderMode mode) {
Frame *currentFrame = _frames[frameId];
+ renderSprites(frameId, _surface, mode);
+ if (mode != kRenderUpdateStageOnly) {
+ _vm->_wm->renderZoomBox();
+
+ _vm->_wm->draw();
+
+ if (currentFrame->_transType != 0) {
+ // TODO Handle changing area case
+ playTransition(currentFrame->_transDuration, currentFrame->_transArea, currentFrame->_transChunkSize, currentFrame->_transType);
+ }
+
+ if (currentFrame->_sound1 != 0 || currentFrame->_sound2 != 0) {
+ playSoundChannel(frameId);
+ }
+ }
+
+ g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height());
+}
+
+void Score::renderSprites(uint16 frameId, Graphics::ManagedSurface *surface, RenderMode mode) {
for (uint16 i = 0; i < _channels.size(); i++) {
Channel *channel = _channels[i];
Sprite *currentSprite = channel->_sprite;
@@ -575,7 +594,7 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
if (currentSprite->_puppet)
nextSprite = currentSprite;
else
- nextSprite = currentFrame->_sprites[i];
+ nextSprite = _frames[frameId]->_sprites[i];
// A sprite needs to be updated if one of the following happens:
// - The dimensions/bounding box of the sprite has changed (_dirty flag set)
@@ -588,7 +607,9 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
currentSprite->getDims() != nextSprite->getDims() ||
channel->_currentPoint != nextSprite->_startPoint;
- if ((needsUpdate || forceUpdate) && !currentSprite->_trails)
+ if (mode != kRenderNoUnrender &&
+ (needsUpdate || mode == kRenderForceUpdate) &&
+ !currentSprite->_trails)
markDirtyRect(channel->getBbox());
channel->_sprite = nextSprite;
@@ -617,13 +638,13 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
debugC(1, kDebugImages, "Score::renderFrame(): channel: %d, castType: %d, castId: %d", id, sprite->_castType, sprite->_castId);
if (sprite->_castType == kCastShape) {
- renderShape(id);
+ renderShape(id, surface);
} else {
Cast *cast = sprite->_cast;
if (cast && cast->_widget) {
cast->_widget->_priority = id;
cast->_widget->draw();
- inkBasedBlit(cast->_widget->getMask(), cast->_widget->getSurface()->rawSurface(), channel->_sprite->_ink, currentBbox, id);
+ inkBasedBlit(surface, cast->_widget->getMask(), cast->_widget->getSurface()->rawSurface(), channel->_sprite->_ink, currentBbox, id);
} else {
warning("Score::renderFrame(): No widget for channel ID %d", id);
}
@@ -631,25 +652,6 @@ void Score::renderFrame(uint16 frameId, bool forceUpdate, bool updateStageOnly)
sprite->setClean();
}
-
- if (!updateStageOnly) {
- _vm->_wm->renderZoomBox();
-
- _vm->_wm->draw();
-
- if (currentFrame->_transType != 0) {
- // TODO Handle changing area case
- playTransition(currentFrame->_transDuration, currentFrame->_transArea, currentFrame->_transChunkSize, currentFrame->_transType);
- }
-
- if (currentFrame->_sound1 != 0 || currentFrame->_sound2 != 0) {
- playSoundChannel(frameId);
- }
-
- }
-
- g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height());
-
}
void Score::markDirtyRect(Common::Rect dirty) {
@@ -678,7 +680,7 @@ void Score::screenShot() {
newSurface->free();
}
-void Score::renderShape(uint16 spriteId) {
+void Score::renderShape(uint16 spriteId, Graphics::ManagedSurface *surface) {
Sprite *sp = _channels[spriteId]->_sprite;
InkType ink = sp->_ink;
@@ -787,7 +789,7 @@ void Score::renderShape(uint16 spriteId) {
break;
}
- inkBasedBlit(&maskSurface, tmpSurface, ink, shapeRect, spriteId);
+ inkBasedBlit(surface, &maskSurface, tmpSurface, ink, shapeRect, spriteId);
}
Cast *Score::getCastMember(int castId) {
diff --git a/engines/director/score.h b/engines/director/score.h
index f665f3b3a4..335471a48b 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -56,6 +56,13 @@ class ScriptCast;
class ShapeCast;
class TextCast;
+enum RenderMode {
+ kRenderModeNormal,
+ kRenderForceUpdate,
+ kRenderUpdateStageOnly,
+ kRenderNoUnrender
+};
+
struct TransParams {
TransitionType type;
uint duration;
@@ -146,7 +153,8 @@ public:
Cast *getCastMember(int castId);
const Stxt *getStxt(int castId);
- void renderFrame(uint16 frameId, bool forceUpdate = false, bool updateStageOnly = false);
+ void renderFrame(uint16 frameId, RenderMode mode = kRenderModeNormal);
+ void renderSprites(uint16 frameId, Graphics::ManagedSurface *surface, RenderMode mode = kRenderModeNormal);
void markDirtyRect(Common::Rect dirty);
// transition.cpp
@@ -154,12 +162,12 @@ public:
private:
void update();
- void renderShape(uint16 spriteId);
+ void renderShape(uint16 spriteId, Graphics::ManagedSurface *surface);
// ink.cpp
- void inkBasedBlit(Graphics::ManagedSurface *maskSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect, uint spriteId);
- void drawMatteSprite(const Graphics::Surface &sprite, Common::Rect &drawRect);
- void drawReverseSprite(const Graphics::Surface &sprite, Common::Rect &drawRect, uint16 spriteId);
+ void inkBasedBlit(Graphics::ManagedSurface *destSurface, Graphics::ManagedSurface *maskSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect, uint spriteId);
+ void drawMatteSprite(Graphics::ManagedSurface *destSurface, const Graphics::Surface &sprite, Common::Rect &drawRect);
+ void drawReverseSprite(Graphics::ManagedSurface *destSurface, const Graphics::Surface &sprite, Common::Rect &drawRect, uint16 spriteId);
// transitions.cpp
void initTransParams(TransParams &t, Common::Rect &clipRect);
More information about the Scummvm-git-logs
mailing list