MOHAWK: RIVEN: Optimize image decoding

This mitigates long load times between cards on low-power devices
by streaming from memory. Code courtesy of Bastien Bouclet (bgK).
This commit is contained in:
Michael Ball 2020-03-14 08:27:15 -07:00 committed by Bastien Bouclet
parent 047545cc1b
commit 366793db22

View File

@ -29,6 +29,7 @@
#include "mohawk/riven_video.h"
#include "common/system.h"
#include "common/memstream.h"
#include "engines/util.h"
@ -354,7 +355,11 @@ RivenGraphics::~RivenGraphics() {
}
MohawkSurface *RivenGraphics::decodeImage(uint16 id) {
MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
Common::SeekableReadStream *resourceStream = _vm->getResource(ID_TBMP, id);
Common::SeekableReadStream *memResourceStream = resourceStream->readStream(resourceStream->size());
delete resourceStream;
MohawkSurface *surface = _bitmapDecoder->decodeImage(memResourceStream);
surface->convertToTrueColor();
return surface;
}