mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
GRAPHICS: Simplify the interface of Graphics::loadThumbnail().
Now it returns the Surface, so the caller does not need to create one and pass it.
This commit is contained in:
parent
b4b6ce0954
commit
e35b4f20c1
@ -258,12 +258,7 @@ SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int sl
|
||||
|
||||
char saveVersion = in->readByte();
|
||||
if (saveVersion >= 4) {
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*in, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
|
||||
|
||||
desc.setThumbnail(thumbnail);
|
||||
|
||||
|
@ -62,12 +62,9 @@ bool readSavegameHeader(Common::InSaveFile *in, CruiseSavegameHeader &header) {
|
||||
while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
|
||||
|
||||
// Get the thumbnail
|
||||
header.thumbnail = new Graphics::Surface();
|
||||
if (!Graphics::loadThumbnail(*in, *header.thumbnail)) {
|
||||
delete header.thumbnail;
|
||||
header.thumbnail = NULL;
|
||||
header.thumbnail = Graphics::loadThumbnail(*in);
|
||||
if (!header.thumbnail)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -58,13 +58,9 @@ bool readSavegameHeader(Common::InSaveFile *in, DraciSavegameHeader &header) {
|
||||
header.playtime = in->readUint32LE();
|
||||
|
||||
// Get the thumbnail
|
||||
header.thumbnail = new Graphics::Surface();
|
||||
if (!Graphics::loadThumbnail(*in, *header.thumbnail)) {
|
||||
header.thumbnail->free();
|
||||
delete header.thumbnail;
|
||||
header.thumbnail = NULL;
|
||||
header.thumbnail = Graphics::loadThumbnail(*in);
|
||||
if (!header.thumbnail)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -241,12 +241,7 @@ SaveStateDescriptor HugoMetaEngine::querySaveMetaInfos(const char *target, int s
|
||||
|
||||
SaveStateDescriptor desc(slot, saveName);
|
||||
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*file, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file);
|
||||
desc.setThumbnail(thumbnail);
|
||||
|
||||
desc.setDeletableFlag(true);
|
||||
|
@ -113,12 +113,7 @@ KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::Seekab
|
||||
|
||||
if (header.version >= 14) {
|
||||
if (loadThumbnail) {
|
||||
header.thumbnail = new Graphics::Surface();
|
||||
assert(header.thumbnail);
|
||||
if (!Graphics::loadThumbnail(*in, *header.thumbnail)) {
|
||||
delete header.thumbnail;
|
||||
header.thumbnail = 0;
|
||||
}
|
||||
header.thumbnail = Graphics::loadThumbnail(*in);
|
||||
} else {
|
||||
Graphics::skipThumbnail(*in);
|
||||
}
|
||||
|
@ -256,13 +256,7 @@ SaveStateDescriptor SagaMetaEngine::querySaveMetaInfos(const char *target, int s
|
||||
desc.setWriteProtectedFlag(false);
|
||||
|
||||
if (version >= 6) {
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*in, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
|
||||
desc.setThumbnail(thumbnail);
|
||||
|
||||
uint32 saveDate = in->readUint32BE();
|
||||
|
@ -676,13 +676,7 @@ SaveStateDescriptor SciMetaEngine::querySaveMetaInfos(const char *target, int sl
|
||||
|
||||
SaveStateDescriptor desc(slot, meta.name);
|
||||
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*in, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
|
||||
desc.setThumbnail(thumbnail);
|
||||
|
||||
desc.setDeletableFlag(true);
|
||||
|
@ -686,12 +686,7 @@ Graphics::Surface *ScummEngine::loadThumbnailFromSlot(const char *target, int sl
|
||||
|
||||
Graphics::Surface *thumb = 0;
|
||||
if (Graphics::checkThumbnailHeader(*in)) {
|
||||
thumb = new Graphics::Surface();
|
||||
assert(thumb);
|
||||
if (!Graphics::loadThumbnail(*in, *thumb)) {
|
||||
delete thumb;
|
||||
thumb = 0;
|
||||
}
|
||||
thumb = Graphics::loadThumbnail(*in);
|
||||
}
|
||||
|
||||
delete in;
|
||||
|
@ -274,13 +274,7 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int
|
||||
in->skip(1);
|
||||
|
||||
if (Graphics::checkThumbnailHeader(*in)) {
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*in, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
|
||||
desc.setThumbnail(thumbnail);
|
||||
}
|
||||
|
||||
|
@ -177,9 +177,8 @@ public:
|
||||
ssd.setDeletableFlag(true);
|
||||
|
||||
//checking for the thumbnail
|
||||
Common::ScopedPtr<Graphics::Surface> thumb(new Graphics::Surface);
|
||||
if (Graphics::loadThumbnail(*in, *thumb))
|
||||
ssd.setThumbnail(thumb.release());
|
||||
if (Graphics::Surface *const thumb = Graphics::loadThumbnail(*in))
|
||||
ssd.setThumbnail(thumb);
|
||||
|
||||
return ssd;
|
||||
}
|
||||
|
@ -224,12 +224,7 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s
|
||||
|
||||
SaveStateDescriptor desc(slot, saveName);
|
||||
|
||||
Graphics::Surface *thumbnail = new Graphics::Surface();
|
||||
assert(thumbnail);
|
||||
if (!Graphics::loadThumbnail(*file, *thumbnail)) {
|
||||
delete thumbnail;
|
||||
thumbnail = 0;
|
||||
}
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file);
|
||||
desc.setThumbnail(thumbnail);
|
||||
|
||||
desc.setDeletableFlag(true);
|
||||
|
@ -249,12 +249,9 @@ bool Saver::readSavegameHeader(Common::InSaveFile *in, tSageSavegameHeader &head
|
||||
while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
|
||||
|
||||
// Get the thumbnail
|
||||
header.thumbnail = new Graphics::Surface();
|
||||
if (!Graphics::loadThumbnail(*in, *header.thumbnail)) {
|
||||
delete header.thumbnail;
|
||||
header.thumbnail = NULL;
|
||||
header.thumbnail = Graphics::loadThumbnail(*in);
|
||||
if (!header.thumbnail)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in save date/time
|
||||
header.saveYear = in->readSint16LE();
|
||||
|
@ -94,23 +94,24 @@ bool skipThumbnail(Common::SeekableReadStream &in) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to) {
|
||||
Graphics::Surface* loadThumbnail(Common::SeekableReadStream &in) {
|
||||
ThumbnailHeader header;
|
||||
|
||||
if (!loadHeader(in, header, true))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
if (header.bpp != 2) {
|
||||
warning("trying to load thumbnail with unsupported bit depth %d", header.bpp);
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Graphics::PixelFormat format = g_system->getOverlayFormat();
|
||||
to.create(header.width, header.height, format);
|
||||
Graphics::Surface *const to = new Graphics::Surface();
|
||||
to->create(header.width, header.height, format);
|
||||
|
||||
OverlayColor *pixels = (OverlayColor *)to.pixels;
|
||||
for (int y = 0; y < to.h; ++y) {
|
||||
for (int x = 0; x < to.w; ++x) {
|
||||
OverlayColor *pixels = (OverlayColor *)to->pixels;
|
||||
for (int y = 0; y < to->h; ++y) {
|
||||
for (int x = 0; x < to->w; ++x) {
|
||||
uint8 r, g, b;
|
||||
colorToRGB<ColorMasks<565> >(in.readUint16BE(), r, g, b);
|
||||
|
||||
@ -119,7 +120,7 @@ bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to) {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return to;
|
||||
}
|
||||
|
||||
bool saveThumbnail(Common::WriteStream &out) {
|
||||
|
@ -53,7 +53,7 @@ bool skipThumbnail(Common::SeekableReadStream &in);
|
||||
* The loaded thumbnail will be automatically converted to the
|
||||
* current overlay pixelformat.
|
||||
*/
|
||||
bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface &to);
|
||||
Graphics::Surface* loadThumbnail(Common::SeekableReadStream &in);
|
||||
|
||||
/**
|
||||
* Saves a thumbnail to the given write stream.
|
||||
|
Loading…
x
Reference in New Issue
Block a user