1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00
This commit is contained in:
MichalZr6 2024-12-15 21:32:23 +01:00
parent 81e29d6ce2
commit f4a15a198b
6 changed files with 6 additions and 31 deletions

View File

@ -38,8 +38,7 @@ enum class DefType : uint32_t
CDefFile::CDefFile(const AnimationPath & Name):
data(nullptr),
palette(nullptr),
fileName(Name.getName())
palette(nullptr)
{
data = CResourceHandler::get()->load(Name)->readAll().first;

View File

@ -43,8 +43,6 @@ public:
CDefFile(const AnimationPath & Name);
~CDefFile();
std::string fileName;
//load frame as SDL_Surface
void loadFrame(size_t frame, size_t group, IImageLoader &loader) const;
bool hasFrame(size_t frame, size_t group) const;

View File

@ -245,7 +245,7 @@ std::shared_ptr<const ISharedImage> RenderHandler::loadImageFromFileUncached(con
return std::make_shared<SDLImageShared>(*locator.image, locator.preScaledFactor);
}
if (locator.defFile)
if(locator.defFile)
{
auto defFile = getAnimationFile(*locator.defFile);
int preScaledFactor = locator.preScaledFactor;

View File

@ -99,9 +99,6 @@ SDLImageShared::SDLImageShared(const CDefFile * data, size_t frame, size_t group
SDLImageLoader loader(this);
data->loadFrame(frame, group, loader);
if(surf == nullptr)
return;
savePalette();
}

View File

@ -11,7 +11,6 @@
#include "../render/IImage.h"
#include "../../lib/Point.h"
#include <SDL_surface.h>
VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
@ -25,7 +24,7 @@ struct SDL_Palette;
/*
* Wrapper around SDL_Surface
*/
class SDLImageShared : public ISharedImage, public std::enable_shared_from_this<SDLImageShared>, boost::noncopyable
class SDLImageShared final : public ISharedImage, public std::enable_shared_from_this<SDLImageShared>, boost::noncopyable
{
//Surface without empty borders
SDL_Surface * surf;
@ -67,20 +66,6 @@ public:
friend class SDLImageLoader;
};
class SDLEmptyImageShared : public SDLImageShared
{
public:
SDLEmptyImageShared() : SDLImageShared(createDefaultSurface().get()) {}
private:
std::shared_ptr<SDL_Surface> createDefaultSurface()
{
auto surface = SDL_CreateRGBSurface(0, 32, 32, 32, 0, 0, 0, 0);
SDL_FillRect(surface, nullptr, SDL_MapRGB(surface->format, 255, 0, 0));
return std::shared_ptr<SDL_Surface>(surface, SDL_FreeSurface);
}
};
class SDLImageBase : public IImage, boost::noncopyable
{
protected:

View File

@ -38,7 +38,6 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C
SDL_FreePalette(p);
SDL_LockSurface(image->surf);
lineStart = position = (ui8*)image->surf->pixels;
}
@ -68,11 +67,8 @@ inline void SDLImageLoader::endLine()
SDLImageLoader::~SDLImageLoader()
{
if(image->surf)
{
SDL_UnlockSurface(image->surf);
SDL_SetColorKey(image->surf, SDL_TRUE, 0);
//TODO: RLE if compressed and bpp>1
}
SDL_UnlockSurface(image->surf);
SDL_SetColorKey(image->surf, SDL_TRUE, 0);
//TODO: RLE if compressed and bpp>1
}