[Scummvm-git-logs] scummvm branch-2-5 -> 9e4e05dca3b75308ded083274496414b3c9bd96a

eriktorbjorn noreply at scummvm.org
Sat Jan 8 13:36:15 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:
af47d15ba4 SHEROCK: Fix slowdown in Serrated Scalpel intro (#13198)
9e4e05dca3 NEWS: Mention Sherlock fix


Commit: af47d15ba4ac32ef7af6984d22dbdeef78cbeac1
    https://github.com/scummvm/scummvm/commit/af47d15ba4ac32ef7af6984d22dbdeef78cbeac1
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-01-08T14:34:46+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 3fb652227f3..6588b227d35 100644
--- a/engines/sherlock/image_file.cpp
+++ b/engines/sherlock/image_file.cpp
@@ -35,19 +35,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);
 }
@@ -57,6 +64,7 @@ ImageFile::~ImageFile() {
 		if (_frames[idx]._decoded)
 			_frames[idx]._frame.free();
 	}
+	delete _stream;
 }
 
 ImageFrame& ImageFile::operator[](uint index) {
@@ -76,14 +84,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 b3dc10c13c2..67594d6e2d4 100644
--- a/engines/sherlock/image_file.h
+++ b/engines/sherlock/image_file.h
@@ -83,6 +83,7 @@ private:
 	static SherlockEngine *_vm;
 	Common::Array<ImageFrame> _frames;
 	Common::String _name;
+	Common::SeekableReadStream *_stream;
 
 	/**
 	 * Load the data of the sprite


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

Commit Message:
NEWS: Mention Sherlock fix

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index 1f9aaf2828e..604fcf23b5d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,12 @@
 For a more comprehensive changelog of the latest experimental code, see:
         https://github.com/scummvm/scummvm/commits/
 
+#### 2.5.2 (XXXX-XX-XX)
+
+ Sherlock:
+   - Fixed slowdown in Serrated Scalpel intro when playing the game from a small
+     installation.
+
 #### 2.5.1 (2022-01-02)
 
  General:




More information about the Scummvm-git-logs mailing list