[Scummvm-git-logs] scummvm master -> 6338496dffd3e1dc07fa4cd17654a2daa95f60fe

csnover csnover at users.noreply.github.com
Sun Dec 18 01:59:07 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:
07919b79ba SCI32: Improve SciBitmap segment table debugging output
6338496dff SCI32: Fix bitmap surface memory leaks in video players


Commit: 07919b79baca911dcda4708406f5dee85d22b655
    https://github.com/scummvm/scummvm/commit/07919b79baca911dcda4708406f5dee85d22b655
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-12-17T18:55:22-06:00

Commit Message:
SCI32: Improve SciBitmap segment table debugging output

Changed paths:
    engines/sci/console.cpp
    engines/sci/engine/segment.h


diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index cfbc2f3..63a1f0c 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -2216,9 +2216,17 @@ bool Console::segmentInfo(int nr) {
 	case SEG_TYPE_ARRAY:
 		debugPrintf("SCI32 arrays\n");
 		break;
-	case SEG_TYPE_BITMAP:
-		debugPrintf("SCI32 bitmaps\n");
+
+	case SEG_TYPE_BITMAP: {
+		BitmapTable &table = *(BitmapTable *)mobj;
+		debugPrintf("SCI32 bitmaps (total %d)\n", table.entries_used);
+		for (uint i = 0; i < table.size(); ++i) {
+			if (table.isValidEntry(i)) {
+				debugPrintf("    [%04x] %s", i, table[i].toString().c_str());
+			}
+		}
 		break;
+	}
 #endif
 
 	default :
@@ -4663,13 +4671,7 @@ void Console::printBitmap(reg_t reg) {
 
 	const SciBitmap &bitmap = table->at(reg.getOffset());
 
-	debugPrintf("SCI32 bitmap (%dx%d; res %dx%d; origin %dx%d; skip color %u; %s; %s):\n",
-				bitmap.getWidth(), bitmap.getHeight(),
-				bitmap.getXResolution(), bitmap.getYResolution(),
-				bitmap.getOrigin().x, bitmap.getOrigin().y,
-				bitmap.getSkipColor(),
-				bitmap.getRemap() ? "remap" : "no remap",
-				bitmap.getShouldGC() ? "GC" : "no GC");
+	debugPrintf("SCI32 bitmap (%s):\n", bitmap.toString().c_str());
 
 	Common::hexdump((const byte *) bitmap.getRawData(), bitmap.getRawSize(), 16, 0);
 }
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index e8f0be3..7c415f3 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -1136,6 +1136,16 @@ public:
 			*pixel++ = (uint8)color;
 		}
 	}
+
+	Common::String toString() const {
+		return Common::String::format("%dx%d; res %dx%d; origin %dx%d; skip color %u; %s; %s):\n",
+			getWidth(), getHeight(),
+			getXResolution(), getYResolution(),
+			getOrigin().x, getOrigin().y,
+			getSkipColor(),
+			getRemap() ? "remap" : "no remap",
+			getShouldGC() ? "GC" : "no GC");
+	}
 };
 
 struct BitmapTable : public SegmentObjTable<SciBitmap> {


Commit: 6338496dffd3e1dc07fa4cd17654a2daa95f60fe
    https://github.com/scummvm/scummvm/commit/6338496dffd3e1dc07fa4cd17654a2daa95f60fe
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-12-17T18:55:23-06:00

Commit Message:
SCI32: Fix bitmap surface memory leaks in video players

Fixes Trac#9662.

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 6eae4cc..c3aafb6 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -71,12 +71,13 @@ void SEQPlayer::play(const Common::String &fileName, const int16 numTicks, const
 	// mechanism that is very similar to that used by the VMD player, which
 	// allows the SEQ to be drawn into a bitmap ScreenItem and displayed using
 	// the normal graphics system.
-	SciBitmap &bitmap = *_segMan->allocateBitmap(&_bitmap, _decoder->getWidth(), _decoder->getHeight(), kDefaultSkipColor, 0, 0, kLowResX, kLowResY, 0, false, false);
+	reg_t bitmapId;
+	SciBitmap &bitmap = *_segMan->allocateBitmap(&bitmapId, _decoder->getWidth(), _decoder->getHeight(), kDefaultSkipColor, 0, 0, kLowResX, kLowResY, 0, false, false);
 	bitmap.getBuffer().fillRect(Common::Rect(_decoder->getWidth(), _decoder->getHeight()), 0);
 
 	CelInfo32 celInfo;
 	celInfo.type = kCelTypeMem;
-	celInfo.bitmap = _bitmap;
+	celInfo.bitmap = bitmapId;
 
 	_plane = new Plane(Common::Rect(kLowResX, kLowResY), kPlanePicColored);
 	g_sci->_gfxFrameout->addPlane(*_plane);
@@ -94,20 +95,19 @@ void SEQPlayer::play(const Common::String &fileName, const int16 numTicks, const
 
 	while (!g_engine->shouldQuit() && !_decoder->endOfVideo()) {
 		g_sci->sleep(_decoder->getTimeToNextFrame());
-		renderFrame();
+		renderFrame(bitmap);
 	}
 
-	_segMan->freeBitmap(_screenItem->_celInfo.bitmap);
+	_segMan->freeBitmap(bitmapId);
 	g_sci->_gfxFrameout->deletePlane(*_plane);
 	g_sci->_gfxFrameout->frameOut(true);
 	_screenItem = nullptr;
 	_plane = nullptr;
 }
 
-void SEQPlayer::renderFrame() const {
+void SEQPlayer::renderFrame(SciBitmap &bitmap) const {
 	const Graphics::Surface *surface = _decoder->decodeNextFrame();
 
-	SciBitmap &bitmap = *_segMan->lookupBitmap(_bitmap);
 	bitmap.getBuffer().copyRectToSurface(*surface, 0, 0, Common::Rect(surface->w, surface->h));
 
 	const bool dirtyPalette = _decoder->hasDirtyPalette();
@@ -326,6 +326,8 @@ AVIPlayer::IOStatus AVIPlayer::close() {
 
 	_decoder->close();
 	_status = kAVINotOpen;
+	_segMan->freeBitmap(_bitmap);
+	_bitmap = NULL_REG;
 	g_sci->_gfxFrameout->deletePlane(*_plane);
 	_plane = nullptr;
 	_screenItem = nullptr;
@@ -569,9 +571,10 @@ VMDPlayer::IOStatus VMDPlayer::close() {
 	_isInitialized = false;
 	_ignorePalettes = false;
 
+	_segMan->freeBitmap(_screenItem->_celInfo.bitmap);
+
 	if (!_planeIsOwned && _screenItem != nullptr) {
 		g_sci->_gfxFrameout->deleteScreenItem(*_screenItem);
-		_segMan->freeBitmap(_screenItem->_celInfo.bitmap);
 		_screenItem = nullptr;
 	} else if (_plane != nullptr) {
 		g_sci->_gfxFrameout->deletePlane(*_plane);
diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h
index 4fc627e..69acdf2 100644
--- a/engines/sci/graphics/video32.h
+++ b/engines/sci/graphics/video32.h
@@ -73,14 +73,9 @@ private:
 	ScreenItem *_screenItem;
 
 	/**
-	 * The bitmap used to render video output.
-	 */
-	reg_t _bitmap;
-
-	/**
 	 * Renders a single frame of video.
 	 */
-	void renderFrame() const;
+	void renderFrame(SciBitmap &bitmap) const;
 };
 
 #pragma mark -





More information about the Scummvm-git-logs mailing list