aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/support/video_surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/support/video_surface.cpp')
-rw-r--r--engines/titanic/support/video_surface.cpp55
1 files changed, 17 insertions, 38 deletions
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 7455e8cfef..e24063188d 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -158,25 +158,9 @@ void CVideoSurface::blitRect(const Rect &srcRect, const Rect &destRect, CVideoSu
if (src->lock()) {
const Graphics::ManagedSurface *srcSurface = src->_rawSurface;
Graphics::ManagedSurface *destSurface = _rawSurface;
- Graphics::Surface destArea = destSurface->getSubArea(destRect);
const uint transColor = src->getTransparencyColor();
- const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr(
- srcRect.left, srcRect.top);
- uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, 0);
-
- for (int yCtr = 0; yCtr < srcRect.height(); ++yCtr,
- srcPtr += src->getPitch() / 2,
- destPtr += destArea.pitch / 2) {
- // Prepare for copying the line
- const uint16 *lineSrcP = srcPtr;
- uint16 *lineDestP = destPtr;
-
- for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX, ++lineSrcP, ++lineDestP) {
- if (*lineSrcP != transColor)
- *lineDestP = *lineSrcP;
- }
- }
+ destSurface->transBlitFrom(*srcSurface, srcRect, destRect, transColor);
src->unlock();
}
@@ -190,28 +174,22 @@ void CVideoSurface::flippedBlitRect(const Rect &srcRect, const Rect &destRect, C
transBlitRect(srcRect, destRect, src, true);
} else if (lock()) {
if (src->lock()) {
- const Graphics::ManagedSurface *srcSurface = src->_rawSurface;
+ Graphics::ManagedSurface *srcSurface = src->_rawSurface;
Graphics::ManagedSurface *destSurface = _rawSurface;
- Graphics::Surface destArea = destSurface->getSubArea(destRect);
+ const Graphics::Surface srcArea = srcSurface->getSubArea(srcRect);
const uint transColor = src->getTransparencyColor();
- const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr(
- srcRect.left, srcRect.top);
- uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, destArea.h - 1);
-
- for (int yCtr = 0; yCtr < srcRect.height(); ++yCtr,
- srcPtr += src->getPitch() / 2,
- destPtr -= destArea.pitch / 2) {
- // Prepare for copying the line
- const uint16 *lineSrcP = srcPtr;
- uint16 *lineDestP = destPtr;
-
- for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX, ++lineSrcP, ++lineDestP) {
- if (*lineSrcP != transColor)
- *lineDestP = *lineSrcP;
- }
+ // Vertically flip the source area
+ Graphics::ManagedSurface flippedArea(srcArea.w, srcArea.h, srcArea.format);
+ for (int y = 0; y < srcArea.h; ++y) {
+ const byte *pSrc = (const byte *)srcArea.getBasePtr(0, y);
+ byte *pDest = (byte *)flippedArea.getBasePtr(0, flippedArea.h - y - 1);
+ Common::copy(pSrc, pSrc + srcArea.pitch, pDest);
}
+ destSurface->transBlitFrom(flippedArea,
+ Common::Point(destRect.left, destRect.top), transColor);
+
src->unlock();
}
@@ -221,6 +199,7 @@ void CVideoSurface::flippedBlitRect(const Rect &srcRect, const Rect &destRect, C
void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src, bool flipFlag) {
assert(srcRect.width() == destRect.width() && srcRect.height() == destRect.height());
+ assert(src->getPixelDepth() == 2);
if (lock()) {
if (src->lock()) {
@@ -442,18 +421,18 @@ int OSVideoSurface::getBpp() {
return getPixelDepth();
}
-void OSVideoSurface::recreate(int width, int height) {
+void OSVideoSurface::recreate(int width, int height, int bpp) {
freeSurface();
- _screenManager->resizeSurface(this, width, height);
+ _screenManager->resizeSurface(this, width, height, bpp);
if (_ddSurface)
_videoSurfaceCounter += _ddSurface->getSize();
}
-void OSVideoSurface::resize(int width, int height) {
+void OSVideoSurface::resize(int width, int height, int bpp) {
if (!_ddSurface || _ddSurface->getWidth() != width ||
_ddSurface->getHeight() != height)
- recreate(width, height);
+ recreate(width, height, bpp);
}
void OSVideoSurface::detachSurface() {