[Scummvm-git-logs] scummvm master -> 53dd55ebf215e269142c875b10d9ce854287f5d8

csnover csnover at users.noreply.github.com
Sun Sep 24 23:22:52 CEST 2017


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:
56cc138e58 IMAGE: Remove unnecessary heap allocation in BitmapRawDecoder
53dd55ebf2 SCI32: Fix bad palettes in Lighthouse when HQ video is enabled


Commit: 56cc138e58b70695d83da890ce6a11ff8148043d
    https://github.com/scummvm/scummvm/commit/56cc138e58b70695d83da890ce6a11ff8148043d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-24T16:22:40-05:00

Commit Message:
IMAGE: Remove unnecessary heap allocation in BitmapRawDecoder

Changed paths:
    image/codecs/bmp_raw.cpp
    image/codecs/bmp_raw.h


diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index 1a856f1..149136c 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -29,16 +29,12 @@
 namespace Image {
 
 BitmapRawDecoder::BitmapRawDecoder(int width, int height, int bitsPerPixel) : Codec(),
-		_surface(0), _width(width), _height(height), _bitsPerPixel(bitsPerPixel) {
-	_surface = new Graphics::Surface();
-	_surface->create(_width, _height, getPixelFormat());
+		_width(width), _height(height), _bitsPerPixel(bitsPerPixel) {
+	_surface.create(_width, _height, getPixelFormat());
 }
 
 BitmapRawDecoder::~BitmapRawDecoder() {
-	if (_surface) {
-		_surface->free();
-		delete _surface;
-	}
+	_surface.free();
 }
 
 const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStream &stream) {
@@ -54,7 +50,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 
 	if (_bitsPerPixel == 1) {
 		for (int i = 0; i < _height; i++) {
-			byte *dst = (byte *)_surface->getBasePtr(0, i);
+			byte *dst = (byte *)_surface.getBasePtr(0, i);
 			for (int j = 0; j != _width;) {
 				byte color = stream.readByte();
 				for (int k = 0; k < 8; k++) {
@@ -70,7 +66,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 		}
 	} else if (_bitsPerPixel == 4) {
 		for (int i = 0; i < _height; i++) {
-			byte *dst = (byte *)_surface->getBasePtr(0, _height - i - 1);
+			byte *dst = (byte *)_surface.getBasePtr(0, _height - i - 1);
 			for (int j = 0; j < _width; j++) {
 				byte color = stream.readByte();
 
@@ -86,14 +82,14 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 			stream.skip(extraDataLength);
 		}
 	} else if (_bitsPerPixel == 8) {
-		byte *dst = (byte *)_surface->getPixels();
+		byte *dst = (byte *)_surface.getPixels();
 
 		for (int i = 0; i < _height; i++) {
 			stream.read(dst + (_height - i - 1) * _width, _width);
 			stream.skip(extraDataLength);
 		}
 	} else if (_bitsPerPixel == 24) {
-		byte *dst = (byte *)_surface->getBasePtr(0, _height - 1);
+		byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
 
 		for (int i = 0; i < _height; i++) {
 			for (int j = 0; j < _width; j++) {
@@ -107,10 +103,10 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 			}
 
 			stream.skip(extraDataLength);
-			dst -= _surface->pitch * 2;
+			dst -= _surface.pitch * 2;
 		}
 	} else { // 32 bpp
-		byte *dst = (byte *)_surface->getBasePtr(0, _height - 1);
+		byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
 
 		for (int i = 0; i < _height; i++) {
 			for (int j = 0; j < _width; j++) {
@@ -128,11 +124,11 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 			}
 
 			stream.skip(extraDataLength);
-			dst -= _surface->pitch * 2;
+			dst -= _surface.pitch * 2;
 		}
 	}
 
-	return _surface;
+	return &_surface;
 }
 
 Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
diff --git a/image/codecs/bmp_raw.h b/image/codecs/bmp_raw.h
index 99509a1..8ec79e7 100644
--- a/image/codecs/bmp_raw.h
+++ b/image/codecs/bmp_raw.h
@@ -41,7 +41,7 @@ public:
 	Graphics::PixelFormat getPixelFormat() const;
 
 private:
-	Graphics::Surface *_surface;
+	Graphics::Surface _surface;
 	int _width, _height;
 	int _bitsPerPixel;
 };


Commit: 53dd55ebf215e269142c875b10d9ce854287f5d8
    https://github.com/scummvm/scummvm/commit/53dd55ebf215e269142c875b10d9ce854287f5d8
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-24T16:22:40-05:00

Commit Message:
SCI32: Fix bad palettes in Lighthouse when HQ video is enabled

In a couple of places, Lighthouse updates the renderer with screen
items for the next room before the room transition video plays.
This is normally fine when using the compositing video renderer
because the videos are drawn into new planes which occlude the
screen items, so the screen items are culled from the draw list
and do not submit their palettes. However, when in HQ video mode,
we currently force the overlay renderer, which was not blocking
screen items before forcing a frameOut, so the screen items'
palettes got submitted prematurely in this case and caused bad
rendering after the video finished playback.

Now, if we are forcing into the overlay code path, we still create
a blank plane behind the overlay before the forced frameOut in
order to correctly occlude screen items and keep them from
participating in rendering before they normally would.

Fixes Trac#10233, Trac#10235.

Changed paths:
    engines/sci/graphics/video32.cpp
    engines/sci/graphics/video32.h


diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index 91e4861..16884a1 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -743,6 +743,20 @@ VMDPlayer::EventFlags VMDPlayer::checkForEvent(const EventFlags flags) {
 }
 
 void VMDPlayer::initOverlay() {
+	// Composited videos forced through the overlay renderer (due to HQ video
+	// mode) still need to occlude whatever is behind them in the renderer (as
+	// in composited mode) to prevent palette glitches caused by premature
+	// submission of occluded screen items (e.g. leaving the lava room sphere in
+	// the volcano in Lighthouse, the pic after the video finishes playing will
+	// be rendered with the wrong palette)
+	if (isNormallyComposited() && _planeIsOwned) {
+		_plane = new Plane(_drawRect, kPlanePicColored);
+		if (_priority) {
+			_plane->_priority = _priority;
+		}
+		g_sci->_gfxFrameout->addPlane(_plane);
+	}
+
 	// Make sure that any pending graphics changes from the game are submitted
 	// before starting playback, since if they aren't, and the video player
 	// yields back to the VM in the middle of playback, there may be a flash of
@@ -854,6 +868,11 @@ void VMDPlayer::submitPalette(const uint8 rawPalette[256 * 3]) const {
 }
 
 void VMDPlayer::closeOverlay() {
+	if (isNormallyComposited() && _planeIsOwned && _plane != nullptr) {
+		g_sci->_gfxFrameout->deletePlane(*_plane);
+		_plane = nullptr;
+	}
+
 #ifdef USE_RGB_COLOR
 	if (_hqVideoMode) {
 		if (endHQVideo()) {
diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h
index cd4436f..7b2cffa 100644
--- a/engines/sci/graphics/video32.h
+++ b/engines/sci/graphics/video32.h
@@ -503,12 +503,16 @@ private:
 	 */
 	bool shouldUseCompositing() const {
 #ifdef USE_RGB_COLOR
-		return getSciVersion() == SCI_VERSION_3 && !shouldStartHQVideo();
+		return isNormallyComposited() && !shouldStartHQVideo();
 #else
-		return getSciVersion() == SCI_VERSION_3;
+		return isNormallyComposited();
 #endif
 	}
 
+	bool isNormallyComposited() const {
+		return getSciVersion() == SCI_VERSION_3;
+	}
+
 	void initOverlay();
 	void renderOverlay(const Graphics::Surface &nextFrame) const;
 	void closeOverlay();





More information about the Scummvm-git-logs mailing list