aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/video_surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/video_surface.cpp')
-rw-r--r--engines/titanic/video_surface.cpp56
1 files changed, 26 insertions, 30 deletions
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index 8a723cce07..6cbea17c40 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -132,7 +132,8 @@ void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoS
lock();
// TODO: Do it like the original does it
- _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top));
+ _rawSurface->transBlitFrom(*src->_rawSurface, srcRect, destRect,
+ getTransparencyColor());
src->unlock();
unlock();
@@ -143,9 +144,11 @@ void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoS
blitRect1(srcRect, destRect, src);
}
-uint16 CVideoSurface::getTransparencyColor() const {
- // TODO: Do like the original
- return 0xF81F;
+uint CVideoSurface::getTransparencyColor() {
+ uint32 val = -(getPixelDepth() - 2);
+ val &= 0xFFFF8400;
+ val += 0xF81F;
+ return val;
}
/*------------------------------------------------------------------------*/
@@ -181,7 +184,7 @@ void OSVideoSurface::loadTarga(const CResourceKey &key) {
CTargaDecode decoder;
decoder.decode(*this, key.getString());
- if (proc26() == 2)
+ if (getPixelDepth() == 2)
shiftColors();
_resourceKey = key;
@@ -193,7 +196,7 @@ void OSVideoSurface::loadJPEG(const CResourceKey &key) {
CJPEGDecode decoder;
decoder.decode(*this, key.getString());
- if (proc26() == 2)
+ if (getPixelDepth() == 2)
shiftColors();
_resourceKey = key;
@@ -213,10 +216,11 @@ bool OSVideoSurface::lock() {
}
void OSVideoSurface::unlock() {
- if (_rawSurface)
- _ddSurface->unlock();
- _rawSurface = nullptr;
- --_lockCount;
+ if (!--_lockCount) {
+ if (_rawSurface)
+ _ddSurface->unlock();
+ _rawSurface = nullptr;
+ }
}
bool OSVideoSurface::hasSurface() {
@@ -252,12 +256,19 @@ void OSVideoSurface::resize(int width, int height) {
_videoSurfaceCounter += _ddSurface->getSize();
}
-int OSVideoSurface::proc26() {
+int OSVideoSurface::getPixelDepth() {
if (!loadIfReady())
assert(0);
- warning("TODO");
- return 0;
+ lock();
+
+ int result = _rawSurface->format.bytesPerPixel;
+ if (result == 1)
+ // Paletted 8-bit images don't store the color directly in the pixels
+ result = 0;
+
+ unlock();
+ return result;
}
bool OSVideoSurface::load() {
@@ -305,23 +316,8 @@ void OSVideoSurface::shiftColors() {
if (!loadIfReady())
return;
- if (!lock())
- assert(0);
-
- int width = getWidth();
- int height = getHeight();
- int pitch = getPitch();
- uint16 *pixels = (uint16 *)_rawSurface->getPixels();
- uint16 *p;
- int x, y;
-
- for (y = 0; y < height; ++y, pixels += pitch) {
- for (x = 0, p = pixels; x < width; ++x, ++p) {
- *p = ((*p & 0xFFE0) * 2) | (*p & 0x1F);
- }
- }
-
- unlock();
+ // Currently no further processing is needed, since for ScummVM,
+ // we already convert 16-bit surfaces as soon as they're loaded
}
void OSVideoSurface::proc32(int v1, CVideoSurface *surface) {