[Scummvm-git-logs] scummvm master -> 8239acc5aeb270c3f052b97f18d740564fdd5ffa

eriktorbjorn noreply at scummvm.org
Sat Jan 8 13:34:30 UTC 2022


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:
d38c86fec0 SHEROCK: Fix slowdown in Serrated Scalpel intro (#13198)
8239acc5ae NEWS: Mention Sherlock fix


Commit: d38c86fec0c6de9023fcd03d1a4c41e80e4d869e
    https://github.com/scummvm/scummvm/commit/d38c86fec0c6de9023fcd03d1a4c41e80e4d869e
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-01-08T13:55:52+01:00

Commit Message:
SHEROCK: Fix slowdown in Serrated Scalpel intro (#13198)

This was a regression from fixing bug #13101. The resource stream was
created for every frame that was decoded, and apparently each frame of
the intro is made up of lots of little frame.

Normally this wasn't much of a problem, but when using the smaller
installation offered by some versions, each such decoded frame caused
the entire resource file to be decompressed. This slowed things down a
lot.

Now the stream is kept alive throughout, so that the file is only
decompressed once. Note that this is only necessary when creating the
ImageFile object from a filename. When it's created from a stream,
frames are still decoded in advance the old way, so there is no need for
the class to have its own stream. At least that's how it works now.

Changed paths:
    engines/sherlock/image_file.cpp
    engines/sherlock/image_file.h


diff --git a/engines/sherlock/image_file.cpp b/engines/sherlock/image_file.cpp
index a540fb18481..d839f01b7b5 100644
--- a/engines/sherlock/image_file.cpp
+++ b/engines/sherlock/image_file.cpp
@@ -34,19 +34,26 @@ void ImageFile::setVm(SherlockEngine *vm) {
 }
 
 ImageFile::ImageFile() {
+	_stream = nullptr;
 }
 
 ImageFile::ImageFile(const Common::String &name, bool skipPal, bool animImages) {
+	// When we have a filename, the ImageFile class is responsible for
+	// decoding frames on demand, not all at once. But we don't want to
+	// recreate the stream every time since in the case where resources
+	// files are compressed that will decompress the entire resource file
+	// for each call. This makes the Serrated Scalpel intro very slow, even
+	// on decent hardware.
+
 	_name = name;
-	Common::SeekableReadStream *stream = _vm->_res->load(name);
+	_stream = _vm->_res->load(name);
 
 	Common::fill(&_palette[0], &_palette[PALETTE_SIZE], 0);
-	load(*stream, skipPal, animImages);
-
-	delete stream;
+	load(*_stream, skipPal, animImages);
 }
 
 ImageFile::ImageFile(Common::SeekableReadStream &stream, bool skipPal) {
+	_stream = nullptr;
 	Common::fill(&_palette[0], &_palette[PALETTE_SIZE], 0);
 	load(stream, skipPal, false);
 }
@@ -56,6 +63,7 @@ ImageFile::~ImageFile() {
 		if (_frames[idx]._decoded)
 			_frames[idx]._frame.free();
 	}
+	delete _stream;
 }
 
 ImageFrame& ImageFile::operator[](uint index) {
@@ -75,14 +83,12 @@ void ImageFile::push_back(const ImageFrame &frame) {
 }
 
 void ImageFile::decodeFrame(ImageFrame &frame) {
-	Common::SeekableReadStream *stream = _vm->_res->load(_name);
-	stream->seek(frame._pos);
+	_stream->seek(frame._pos);
 	byte *data = new byte[frame._size + 4];
-	stream->read(data, frame._size);
+	_stream->read(data, frame._size);
 	Common::fill(data + frame._size, data + frame._size + 4, 0);
 	frame.decompressFrame(data, IS_ROSE_TATTOO);
 	delete[] data;
-	delete stream;
 }
 
 void ImageFile::load(Common::SeekableReadStream &stream, bool skipPalette, bool animImages) {
diff --git a/engines/sherlock/image_file.h b/engines/sherlock/image_file.h
index 9faa39b151d..caf6103682a 100644
--- a/engines/sherlock/image_file.h
+++ b/engines/sherlock/image_file.h
@@ -82,6 +82,7 @@ private:
 	static SherlockEngine *_vm;
 	Common::Array<ImageFrame> _frames;
 	Common::String _name;
+	Common::SeekableReadStream *_stream;
 
 	/**
 	 * Load the data of the sprite


Commit: 8239acc5aeb270c3f052b97f18d740564fdd5ffa
    https://github.com/scummvm/scummvm/commit/8239acc5aeb270c3f052b97f18d740564fdd5ffa
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-01-08T14:28:57+01:00

Commit Message:
NEWS: Mention Sherlock fix

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index b5cf8e6c6a1..a8a4d280bdc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -53,6 +53,10 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Rewrote music player for Amiga versions of Indy3 and Loom in accordance
      to the original code.
 
+ Sherlock:
+   - Fixed slowdown in Serrated Scalpel intro when playing the game from a small
+     installation.
+
  TwinE:
    - Fixed a bug in the collision code that made the game unfinishable due to the
      tank not moving any further in scene 63.




More information about the Scummvm-git-logs mailing list