Drop IImageLoader::loadImages as only IImageLoader::loadImage is usable

This commit is contained in:
numzero 2023-04-08 01:23:20 +03:00 committed by sfan5
parent 462657960d
commit fc0440ff89
2 changed files with 22 additions and 57 deletions

@ -45,17 +45,6 @@ public:
/** \param file File handle to check.
\return Pointer to newly created image, or 0 upon error. */
virtual IImage* loadImage(io::IReadFile* file) const = 0;
//! Creates a multiple surfaces from the file eg. whole cube map.
/** \param file File handle to check.
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\return Array of pointers to newly created images. */
virtual core::array<IImage*> loadImages(io::IReadFile* file, E_TEXTURE_TYPE* type) const
{
core::array<IImage*> image;
return image;
}
};

@ -1196,59 +1196,35 @@ core::array<IImage*> CNullDriver::createImagesFromFile(io::IReadFile* file, E_TE
core::array<IImage*> imageArray;
if (file)
{
s32 i;
if (!file)
return imageArray;
// try to load file based on file extension
for (i = SurfaceLoader.size() - 1; i >= 0; --i)
{
if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName()))
{
// reset file position which might have changed due to previous loadImage calls
file->seek(0);
imageArray = SurfaceLoader[i]->loadImages(file, type);
for (int i = SurfaceLoader.size() - 1; i >= 0; --i) {
if (!SurfaceLoader[i]->isALoadableFileExtension(file->getFileName()))
continue;
if (imageArray.size() == 0)
{
file->seek(0);
IImage* image = SurfaceLoader[i]->loadImage(file);
if (image)
file->seek(0); // reset file position which might have changed due to previous loadImage calls
if (IImage *image = SurfaceLoader[i]->loadImage(file)) {
imageArray.push_back(image);
}
if (imageArray.size() > 0)
return imageArray;
}
}
// try to load file based on what is in it
for (i = SurfaceLoader.size() - 1; i >= 0; --i)
{
// dito
file->seek(0);
if (SurfaceLoader[i]->isALoadableFileFormat(file)
&& !SurfaceLoader[i]->isALoadableFileExtension(file->getFileName()) // extension was tried above already
)
{
file->seek(0);
imageArray = SurfaceLoader[i]->loadImages(file, type);
for (int i = SurfaceLoader.size() - 1; i >= 0; --i) {
if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName()))
continue; // extension was tried above already
file->seek(0); // dito
if (!SurfaceLoader[i]->isALoadableFileFormat(file))
continue;
if (imageArray.size() == 0)
{
file->seek(0);
IImage* image = SurfaceLoader[i]->loadImage(file);
if (image)
if (IImage *image = SurfaceLoader[i]->loadImage(file)) {
imageArray.push_back(image);
}
if (imageArray.size() > 0)
return imageArray;
}
}
}
return imageArray;
}