[Scummvm-git-logs] scummvm master -> a7426c28722058aeed2cfc823b715b3ddde21736
npjg
nathanael.gentrydb8 at gmail.com
Tue Jul 21 18:48:34 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:
a7426c2872 GRAPHICS: MACGUI: Eliminate window composition surface
Commit: a7426c28722058aeed2cfc823b715b3ddde21736
https://github.com/scummvm/scummvm/commit/a7426c28722058aeed2cfc823b715b3ddde21736
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-21T14:48:27-04:00
Commit Message:
GRAPHICS: MACGUI: Eliminate window composition surface
Now there is just the composeSurface from the widget. This fixes a bug where the
inner window contents would be blitted with transparency and also eliminates a
redundant copying. Now the border and inner surfaces are composed together on demand.
Changed paths:
engines/director/stage.cpp
engines/director/transitions.cpp
graphics/macgui/mactextwindow.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
diff --git a/engines/director/stage.cpp b/engines/director/stage.cpp
index 79b96edbb6..5ad4de606b 100644
--- a/engines/director/stage.cpp
+++ b/engines/director/stage.cpp
@@ -69,7 +69,7 @@ void Stage::invertChannel(Channel *channel) {
Common::Rect destRect = channel->getBbox();
for (int i = 0; i < destRect.height(); i++) {
- byte *src = (byte *)_surface.getBasePtr(destRect.left, destRect.top + i);
+ byte *src = (byte *)_composeSurface->getBasePtr(destRect.left, destRect.top + i);
const byte *msk = mask ? (const byte *)mask->getBasePtr(0, i) : nullptr;
for (int j = 0; j < destRect.width(); j++, src++)
@@ -85,7 +85,7 @@ bool Stage::render(bool forceRedraw, Graphics::ManagedSurface *blitTo) {
if (forceRedraw) {
blitTo->clear(_stageColor);
_dirtyRects.clear();
- _dirtyRects.push_back(Common::Rect(_surface.w, _surface.h));
+ _dirtyRects.push_back(Common::Rect(_composeSurface->w, _composeSurface->h));
} else {
if (_dirtyRects.size() == 0)
return false;
@@ -94,7 +94,7 @@ bool Stage::render(bool forceRedraw, Graphics::ManagedSurface *blitTo) {
}
if (!blitTo)
- blitTo = &_surface;
+ blitTo = _composeSurface;
for (Common::List<Common::Rect>::iterator i = _dirtyRects.begin(); i != _dirtyRects.end(); i++) {
const Common::Rect &r = *i;
@@ -121,7 +121,7 @@ void Stage::setStageColor(uint stageColor) {
}
void Stage::reset() {
- _surface.clear(_stageColor);
+ _composeSurface->clear(_stageColor);
_contentIsDirty = true;
}
diff --git a/engines/director/transitions.cpp b/engines/director/transitions.cpp
index 36efb29e94..a8135d6b88 100644
--- a/engines/director/transitions.cpp
+++ b/engines/director/transitions.cpp
@@ -132,8 +132,8 @@ struct {
};
void Stage::exitTransition(Graphics::ManagedSurface *nextFrame, Common::Rect clipRect) {
- _surface.blitFrom(*nextFrame, clipRect, Common::Point(clipRect.left, clipRect.top));
- g_system->copyRectToScreen(_surface.getBasePtr(clipRect.left, clipRect.top), _surface.pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
+ _composeSurface->blitFrom(*nextFrame, clipRect, Common::Point(clipRect.left, clipRect.top));
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(clipRect.left, clipRect.top), _composeSurface->pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
}
void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChunkSize, TransitionType transType, uint frame) {
@@ -151,11 +151,11 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
t.duration = 250;
// Cache a copy of the frame before the transition.
- Graphics::ManagedSurface currentFrame(Graphics::ManagedSurface(_surface.w, _surface.h));
- currentFrame.copyFrom(_surface);
+ Graphics::ManagedSurface currentFrame(Graphics::ManagedSurface(_composeSurface->w, _composeSurface->h));
+ currentFrame.copyFrom(*_composeSurface);
// If a transition is being played, render the frame after the transition.
- Graphics::ManagedSurface nextFrame(Graphics::ManagedSurface(_surface.w, _surface.h));
+ Graphics::ManagedSurface nextFrame(Graphics::ManagedSurface(_composeSurface->w, _composeSurface->h));
Common::Rect clipRect;
if (t.area) {
@@ -246,7 +246,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
if (transProps[t.type].algo == kTransAlgoReveal ||
transProps[t.type].algo == kTransAlgoEdgesIn) {
- _surface.copyRectToSurface(nextFrame, clipRect.left, clipRect.top, clipRect);
+ _composeSurface->copyRectToSurface(nextFrame, clipRect.left, clipRect.top, clipRect);
}
switch (t.type) {
@@ -318,7 +318,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
rto.translate(w - t.xStepSize * i, 0);
rfrom.right -= w - clipRect.findIntersectingRect(rto).width();
rto.clip(clipRect);
- _surface.blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
+ _composeSurface->blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
rfrom.translate(t.xStepSize * i, 0);
rfrom.setWidth(w - t.xStepSize * i);
@@ -328,7 +328,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
case kTransPushRight: // 12
rfrom.translate(w - t.xStepSize * i, 0);
rfrom.setWidth(t.xStepSize * i);
- _surface.blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
+ _composeSurface->blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
rto.setWidth(w - t.xStepSize * i);
rto.translate(t.xStepSize * i, 0);
@@ -339,7 +339,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
case kTransPushDown: // 13
rfrom.translate(0, h - t.yStepSize * i);
rfrom.setHeight(t.yStepSize * i);
- _surface.blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
+ _composeSurface->blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
rto.setHeight(h - t.yStepSize * i);
rto.translate(0, t.yStepSize * i);
@@ -349,7 +349,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
case kTransPushUp: // 14
rto.translate(0, h - t.yStepSize * i);
- _surface.blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
+ _composeSurface->blitFrom(nextFrame, rfrom, Common::Point(rto.left, rto.top));
rfrom.translate(0, t.yStepSize * i);
rfrom.setHeight(h - t.yStepSize * i);
@@ -507,7 +507,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
if (stop)
break;
- _surface.blitFrom(*blitFrom, rfrom, Common::Point(rto.left, rto.top));
+ _composeSurface->blitFrom(*blitFrom, rfrom, Common::Point(rto.left, rto.top));
g_system->delayMillis(t.stepDuration);
if (processQuitEvent(true)) {
@@ -516,12 +516,12 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
}
if (fullredraw) {
- g_system->copyRectToScreen(_surface.getBasePtr(clipRect.left, clipRect.top), _surface.pitch, clipRect.left, clipRect.top, w, h);
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(clipRect.left, clipRect.top), _composeSurface->pitch, clipRect.left, clipRect.top, w, h);
} else {
rto.clip(clipRect);
if (rto.height() > 0 && rto.width() > 0) {
- g_system->copyRectToScreen(_surface.getBasePtr(rto.left, rto.top), _surface.pitch, rto.left, rto.top, rto.width(), rto.height());
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(rto.left, rto.top), _composeSurface->pitch, rto.left, rto.top, rto.width(), rto.height());
}
}
@@ -677,7 +677,7 @@ void Stage::dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::Mana
r.clip(clipRect);
if (!r.isEmpty())
- _surface.copyRectToSurface(*nextFrame, x, y, r);
+ _composeSurface->copyRectToSurface(*nextFrame, x, y, r);
}
} else {
mask = pixmask[x % -t.xStepSize];
@@ -686,7 +686,7 @@ void Stage::dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::Mana
x += clipRect.left;
y += clipRect.top;
- byte *dst = (byte *)_surface.getBasePtr(x, y);
+ byte *dst = (byte *)_composeSurface->getBasePtr(x, y);
byte *src = (byte *)nextFrame->getBasePtr(x, y);
*dst = ((*dst & ~mask) | (*src & mask)) & 0xff;
@@ -702,7 +702,7 @@ void Stage::dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::Mana
}
} while (rnd != seed);
- g_system->copyRectToScreen(_surface.getBasePtr(clipRect.left, clipRect.top), _surface.pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(clipRect.left, clipRect.top), _composeSurface->pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
g_system->updateScreen();
g_lingo->executePerFrameHook(t.frame, i + 1);
@@ -790,7 +790,7 @@ void Stage::dissolvePatternsTrans(TransParams &t, Common::Rect &clipRect, Graphi
for (int i = 0; i < t.steps; i++) {
for (int y = clipRect.top; y < clipRect.bottom; y++) {
byte pat = dissolvePatterns[i][y % 8];
- byte *dst = (byte *)_surface.getBasePtr(clipRect.left, y);
+ byte *dst = (byte *)_composeSurface->getBasePtr(clipRect.left, y);
byte *src = (byte *)nextFrame->getBasePtr(clipRect.left, y);
for (int x = clipRect.left; x < clipRect.right;) {
@@ -806,7 +806,7 @@ void Stage::dissolvePatternsTrans(TransParams &t, Common::Rect &clipRect, Graphi
}
}
- g_system->copyRectToScreen(_surface.getBasePtr(clipRect.left, clipRect.top), _surface.pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(clipRect.left, clipRect.top), _composeSurface->pitch, clipRect.left, clipRect.top, clipRect.width(), clipRect.height());
g_system->updateScreen();
g_lingo->executePerFrameHook(t.frame, i + 1);
@@ -976,8 +976,8 @@ void Stage::transMultiPass(TransParams &t, Common::Rect &clipRect, Graphics::Man
rto.clip(clipRect);
if (rto.height() > 0 && rto.width() > 0) {
- _surface.blitFrom(*nextFrame, rto, Common::Point(rto.left, rto.top));
- g_system->copyRectToScreen(_surface.getBasePtr(rto.left, rto.top), _surface.pitch, rto.left, rto.top, rto.width(), rto.height());
+ _composeSurface->blitFrom(*nextFrame, rto, Common::Point(rto.left, rto.top));
+ g_system->copyRectToScreen(_composeSurface->getBasePtr(rto.left, rto.top), _composeSurface->pitch, rto.left, rto.top, rto.width(), rto.height());
}
}
rects.clear();
@@ -1003,7 +1003,7 @@ void Stage::transZoom(TransParams &t, Common::Rect &clipRect, Graphics::ManagedS
t.steps += 2;
- Graphics::MacPlotData pd(&_surface, nullptr, &g_director->_wm->getPatterns(), Graphics::kPatternCheckers, 0, 0, 1, 0);
+ Graphics::MacPlotData pd(_composeSurface, nullptr, &g_director->_wm->getPatterns(), Graphics::kPatternCheckers, 0, 0, 1, 0);
for (uint16 i = 1; i < t.steps; i++) {
@@ -1031,7 +1031,7 @@ void Stage::transZoom(TransParams &t, Common::Rect &clipRect, Graphics::ManagedS
r.setWidth(t.xStepSize * i * 2);
r.moveTo(w / 2 - t.xStepSize * i, h / 2 - t.yStepSize * i);
- g_system->copyRectToScreen(_surface.getPixels(), _surface.pitch, 0, 0, w, h);
+ g_system->copyRectToScreen(_composeSurface->getPixels(), _composeSurface->pitch, 0, 0, w, h);
g_system->updateScreen();
g_lingo->executePerFrameHook(t.frame, i);
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index ce2c4bedc4..8f397067c6 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -79,7 +79,7 @@ MacTextWindow::MacTextWindow(MacWindowManager *wm, const MacFont *font, int fgco
}
void MacTextWindow::resize(int w, int h, bool inner) {
- if (_surface.w == w && _surface.h == h)
+ if (_composeSurface->w == w && _composeSurface->h == h)
return;
undrawInput();
@@ -154,7 +154,7 @@ bool MacTextWindow::draw(bool forceRedraw) {
_cursorDirty = false;
// Compose
- _mactext->draw(_composeSurface, 0, _scrollPos, _surface.w - 2, _scrollPos + _surface.h - 2, kConWOverlap - 2, kConWOverlap - 2);
+ _mactext->draw(_composeSurface, 0, _scrollPos, _composeSurface->w - 2, _scrollPos + _composeSurface->h - 2, kConWOverlap - 2, kConWOverlap - 2);
if (_cursorState)
_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX + kConWOverlap - 2, _cursorY + kConHOverlap - 2));
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 5cc3587eff..197c8f7acd 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -105,7 +105,7 @@ void MacWindow::setActive(bool active) {
bool MacWindow::isActive() { return _active; }
void MacWindow::resize(int w, int h, bool inner) {
- if (_surface.w == w && _surface.h == h)
+ if (_composeSurface->w == w && _composeSurface->h == h)
return;
if (inner) {
@@ -118,16 +118,14 @@ void MacWindow::resize(int w, int h, bool inner) {
updateInnerDims();
}
- _surface.free();
- _surface.create(_innerDims.width(), _innerDims.height(), PixelFormat::createFormatCLUT8());
+ _composeSurface->free();
+ _composeSurface->create(_innerDims.width(), _innerDims.height(), PixelFormat::createFormatCLUT8());
if (_hasPattern)
drawPattern();
_borderSurface.free();
_borderSurface.create(_dims.width(), _dims.height(), PixelFormat::createFormatCLUT8());
- _composeSurface->free();
- _composeSurface->create(_dims.width(), _dims.height(), PixelFormat::createFormatCLUT8());
_contentIsDirty = true;
_borderIsDirty = true;
@@ -167,10 +165,6 @@ bool MacWindow::draw(bool forceRedraw) {
_contentIsDirty = false;
- // Compose
- _composeSurface->blitFrom(_surface, Common::Rect(0, 0, _surface.w, _surface.h), Common::Point(_innerDims.left - _dims.left, _innerDims.top - _dims.top));
- _composeSurface->transBlitFrom(_borderSurface, kColorGreen);
-
return true;
}
@@ -178,12 +172,14 @@ bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
if (!draw(forceRedraw))
return false;
- g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), Common::Point(_dims.left, _dims.top), kColorGreen2);
+ g->blitFrom(*_composeSurface, Common::Rect(0, 0, _composeSurface->w, _composeSurface->h), Common::Point(_innerDims.left, _innerDims.top));
+ g->transBlitFrom(_borderSurface, Common::Rect(0, 0, _borderSurface.w, _borderSurface.h), Common::Point(_dims.left, _dims.top), kColorGreen);
return true;
}
void MacWindow::blit(ManagedSurface *g, Common::Rect &dest) {
+ // Only the inner surface is blitted here
g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, kColorGreen2);
}
@@ -338,9 +334,9 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
void MacWindow::drawPattern() {
byte *pat = _wm->getPatterns()[_pattern - 1];
- for (int y = 0; y < _surface.h; y++) {
- for (int x = 0; x < _surface.w; x++) {
- byte *dst = (byte *)_surface.getBasePtr(x, y);
+ for (int y = 0; y < _composeSurface->h; y++) {
+ for (int x = 0; x < _composeSurface->w; x++) {
+ byte *dst = (byte *)_composeSurface->getBasePtr(x, y);
if (pat[y % 8] & (1 << (7 - (x % 8))))
*dst = _wm->_colorBlack;
else
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 24376593ec..fc0e672c4a 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -110,10 +110,10 @@ public:
bool isVisible();
/**
- * Method to access the entire surface of the window (e.g. to draw an image).
- * @return A pointer to the entire surface of the window.
+ * Method to access the entire interior surface of the window (e.g. to draw an image).
+ * @return A pointer to the entire interior surface of the window.
*/
- ManagedSurface *getWindowSurface() { return &_surface; }
+ ManagedSurface *getWindowSurface() { return _composeSurface; }
/**
* Method called to draw the window into the target surface.
@@ -148,8 +148,6 @@ protected:
bool _editable;
- ManagedSurface _surface;
-
bool (*_callback)(WindowClick, Common::Event &, void *);
void *_dataPtr;
More information about the Scummvm-git-logs
mailing list