[Scummvm-git-logs] scummvm master -> dd7525320f7778c0760cbae41647e90d419d7843
dreammaster
dreammaster at scummvm.org
Wed Nov 23 03:20:01 CET 2016
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:
fa0a6f2812 IMAGE: Support blitting from different surface formats in ManagedSurface
dd7525320f TITANIC: Simplify movie rendering due to ManagedSurface blit enhancements
Commit: fa0a6f281272181acc26dcab29cb9134a8ccd179
https://github.com/scummvm/scummvm/commit/fa0a6f281272181acc26dcab29cb9134a8ccd179
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-11-22T21:17:54-05:00
Commit Message:
IMAGE: Support blitting from different surface formats in ManagedSurface
Changed paths:
graphics/managed_surface.cpp
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 0b9fa11..0b29b19 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -166,15 +166,60 @@ void ManagedSurface::blitFrom(const Surface &src, const Common::Rect &srcRect,
Common::Rect srcBounds = srcRect;
Common::Rect destBounds(destPos.x, destPos.y, destPos.x + srcRect.width(),
destPos.y + srcRect.height());
- assert(src.format.bytesPerPixel == format.bytesPerPixel);
+ uint destPixel;
+ byte rSrc, gSrc, bSrc, aSrc;
+ byte rDest, gDest, bDest;
+ double alpha;
if (!srcRect.isValidRect() || !clip(srcBounds, destBounds))
return;
+ if (format != src.format) {
+ // When the pixel format differs, both source an dest must be
+ // 2 or 4 bytes per pixel
+ assert(format.bytesPerPixel == 2 || format.bytesPerPixel == 4);
+ assert(src.format.bytesPerPixel == 2 || src.format.bytesPerPixel == 4);
+ }
+
for (int y = 0; y < srcBounds.height(); ++y) {
const byte *srcP = (const byte *)src.getBasePtr(srcBounds.left, srcBounds.top + y);
byte *destP = (byte *)getBasePtr(destBounds.left, destBounds.top + y);
- Common::copy(srcP, srcP + srcBounds.width() * format.bytesPerPixel, destP);
+
+ if (src.format == format && format.bytesPerPixel <= 2) {
+ // Matching 8-bit or 16-bit surfaces (no alpha), so we can do a straight copy
+ Common::copy(srcP, srcP + srcBounds.width() * format.bytesPerPixel, destP);
+ } else {
+ for (int x = 0; x < srcBounds.width(); ++x,
+ srcP += src.format.bytesPerPixel,
+ destP += format.bytesPerPixel) {
+ src.format.colorToARGB(src.format.bytesPerPixel == 2 ? *(const uint16 *)srcP : *(const uint32 *)srcP,
+ aSrc, rSrc, gSrc, bSrc);
+ format.colorToRGB(format.bytesPerPixel == 2 ? *(const uint16 *)destP : *(const uint32 *)destP,
+ rDest, gDest, bDest);
+
+ if (aSrc == 0) {
+ // Completely transparent, so skip
+ continue;
+ } else if (aSrc == 0xff) {
+ // Completely opaque, so copy RGB values over
+ rDest = rSrc;
+ gDest = gSrc;
+ bDest = bSrc;
+ } else {
+ // Partially transparent, so calculate new pixel colors
+ alpha = (double)aSrc / 255.0;
+ rDest = (rSrc * alpha) + (rDest * (1.0 - alpha));
+ gDest = (gSrc * alpha) + (gDest * (1.0 - alpha));
+ bDest = (bSrc * alpha) + (bDest * (1.0 - alpha));
+ }
+
+ destPixel = format.ARGBToColor(0xff, rDest, gDest, bDest);
+ if (format.bytesPerPixel == 2)
+ *(uint16 *)destP = destPixel;
+ else
+ *(uint32 *)destP = destPixel;
+ }
+ }
}
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
Commit: dd7525320f7778c0760cbae41647e90d419d7843
https://github.com/scummvm/scummvm/commit/dd7525320f7778c0760cbae41647e90d419d7843
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-11-22T21:19:54-05:00
Commit Message:
TITANIC: Simplify movie rendering due to ManagedSurface blit enhancements
Changed paths:
engines/titanic/support/avi_surface.cpp
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 17a6fcf..2a67115 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -338,14 +338,22 @@ bool AVISurface::renderFrame() {
_videoSurface->unlock();
}
} else {
- // Blit the primary video track's frame to the video surface
- Graphics::Surface *s = _movieFrameSurface[0]->rawSurface().convertTo(
- g_system->getScreenFormat(), _decoder->getPalette());
+ const Graphics::Surface &frameSurface = _movieFrameSurface[0]->rawSurface();
_videoSurface->lock();
- _videoSurface->getRawSurface()->blitFrom(*s);
+
+ if (frameSurface.format.bytesPerPixel == 1) {
+ // For paletted 8-bit surfaces, we need to convert it to 16-bit,
+ // since the blitting method we're using doesn't support palettes
+ Graphics::Surface *s = frameSurface.convertTo(g_system->getScreenFormat(),
+ _decoder->getPalette());
+ _videoSurface->getRawSurface()->blitFrom(*s);
+ s->free();
+ delete s;
+ } else {
+ _videoSurface->getRawSurface()->blitFrom(frameSurface);
+ }
+
_videoSurface->unlock();
- s->free();
- delete s;
}
return false;
More information about the Scummvm-git-logs
mailing list