mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Rename IConstImage to more clear ISharedImage
This commit is contained in:
		| @@ -82,7 +82,7 @@ public: | ||||
| 	virtual ~IImage() = default; | ||||
| }; | ||||
|  | ||||
| class IConstImage | ||||
| class ISharedImage | ||||
| { | ||||
| public: | ||||
| 	virtual Point dimensions() const = 0; | ||||
| @@ -91,9 +91,9 @@ public: | ||||
|  | ||||
| 	virtual std::shared_ptr<IImage> createImageReference(EImageBlitMode mode) = 0; | ||||
|  | ||||
| 	virtual std::shared_ptr<IConstImage> horizontalFlip() const = 0; | ||||
| 	virtual std::shared_ptr<IConstImage> verticalFlip() const = 0; | ||||
| 	virtual std::shared_ptr<ISharedImage> horizontalFlip() const = 0; | ||||
| 	virtual std::shared_ptr<ISharedImage> verticalFlip() const = 0; | ||||
|  | ||||
|  | ||||
| 	virtual ~IConstImage() = default; | ||||
| 	virtual ~ISharedImage() = default; | ||||
| }; | ||||
|   | ||||
| @@ -17,60 +17,60 @@ | ||||
|  | ||||
| #include <SDL_surface.h> | ||||
|  | ||||
| ImageConstScaled::ImageConstScaled(std::shared_ptr<SDLImageConst> sourceImage) | ||||
| ImageSharedScaled::ImageSharedScaled(std::shared_ptr<SDLImageShared> sourceImage) | ||||
| 	:sourceImage(sourceImage) | ||||
| { | ||||
| 	scaledImage = sourceImage->scaleFast(sourceImage->dimensions() * getScalingFactor()); | ||||
| } | ||||
|  | ||||
| int ImageConstScaled::getScalingFactor() const | ||||
| int ImageSharedScaled::getScalingFactor() const | ||||
| { | ||||
| 	return 2; | ||||
| } | ||||
|  | ||||
| void ImageConstScaled::draw(SDL_Surface *where, const Point &dest, const Rect *src, uint8_t alpha, EImageBlitMode mode) const | ||||
| void ImageSharedScaled::draw(SDL_Surface *where, const Point &dest, const Rect *src, uint8_t alpha, EImageBlitMode mode) const | ||||
| { | ||||
| 	scaledImage->draw(where, nullptr, dest, src, alpha, mode); | ||||
| } | ||||
|  | ||||
| void ImageConstScaled::exportBitmap(const boost::filesystem::path &path) const | ||||
| void ImageSharedScaled::exportBitmap(const boost::filesystem::path &path) const | ||||
| { | ||||
| 	sourceImage->exportBitmap(path); | ||||
| } | ||||
|  | ||||
| Point ImageConstScaled::dimensions() const | ||||
| Point ImageSharedScaled::dimensions() const | ||||
| { | ||||
| 	return sourceImage->dimensions(); | ||||
| } | ||||
|  | ||||
| bool ImageConstScaled::isTransparent(const Point &coords) const | ||||
| bool ImageSharedScaled::isTransparent(const Point &coords) const | ||||
| { | ||||
| 	return sourceImage->isTransparent(coords); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IImage> ImageConstScaled::createImageReference(EImageBlitMode mode) | ||||
| std::shared_ptr<IImage> ImageSharedScaled::createImageReference(EImageBlitMode mode) | ||||
| { | ||||
| 	return std::make_shared<ImageScaled>(shared_from_this(), mode); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> ImageConstScaled::horizontalFlip() const | ||||
| std::shared_ptr<ISharedImage> ImageSharedScaled::horizontalFlip() const | ||||
| { | ||||
| 	return std::make_shared<ImageConstScaled>(std::dynamic_pointer_cast<SDLImageConst>(sourceImage->horizontalFlip())); | ||||
| 	return std::make_shared<ImageSharedScaled>(std::dynamic_pointer_cast<SDLImageShared>(sourceImage->horizontalFlip())); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> ImageConstScaled::verticalFlip() const | ||||
| std::shared_ptr<ISharedImage> ImageSharedScaled::verticalFlip() const | ||||
| { | ||||
| 	return std::make_shared<ImageConstScaled>(std::dynamic_pointer_cast<SDLImageConst>(sourceImage->verticalFlip())); | ||||
| 	return std::make_shared<ImageSharedScaled>(std::dynamic_pointer_cast<SDLImageShared>(sourceImage->verticalFlip())); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<ImageConstScaled> ImageConstScaled::scaleFast(const Point &size) const | ||||
| std::shared_ptr<ImageSharedScaled> ImageSharedScaled::scaleFast(const Point &size) const | ||||
| { | ||||
| 	return std::make_shared<ImageConstScaled>(sourceImage->scaleFast(size)); | ||||
| 	return std::make_shared<ImageSharedScaled>(sourceImage->scaleFast(size)); | ||||
| } | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| ImageScaled::ImageScaled(const std::shared_ptr<ImageConstScaled> &image, EImageBlitMode mode) | ||||
| ImageScaled::ImageScaled(const std::shared_ptr<ImageSharedScaled> &image, EImageBlitMode mode) | ||||
| 	:image(image) | ||||
| 	, alphaValue(SDL_ALPHA_OPAQUE) | ||||
| 	, blitMode(mode) | ||||
|   | ||||
| @@ -13,16 +13,16 @@ | ||||
|  | ||||
| struct SDL_Palette; | ||||
|  | ||||
| class SDLImageConst; | ||||
| class SDLImageShared; | ||||
|  | ||||
| class ImageConstScaled final : public IConstImage, public std::enable_shared_from_this<ImageConstScaled>, boost::noncopyable | ||||
| class ImageSharedScaled final : public ISharedImage, public std::enable_shared_from_this<ImageSharedScaled>, boost::noncopyable | ||||
| { | ||||
| 	std::shared_ptr<SDLImageConst> sourceImage; | ||||
| 	std::shared_ptr<SDLImageConst> scaledImage; | ||||
| 	std::shared_ptr<SDLImageShared> sourceImage; | ||||
| 	std::shared_ptr<SDLImageShared> scaledImage; | ||||
|  | ||||
| 	int getScalingFactor() const; | ||||
| public: | ||||
| 	ImageConstScaled(std::shared_ptr<SDLImageConst> sourceImage); | ||||
| 	ImageSharedScaled(std::shared_ptr<SDLImageShared> sourceImage); | ||||
|  | ||||
| 	void draw(SDL_Surface * where, const Point & dest, const Rect * src, uint8_t alpha, EImageBlitMode mode) const; | ||||
|  | ||||
| @@ -30,21 +30,21 @@ public: | ||||
| 	Point dimensions() const override; | ||||
| 	bool isTransparent(const Point & coords) const override; | ||||
| 	std::shared_ptr<IImage> createImageReference(EImageBlitMode mode) override; | ||||
| 	std::shared_ptr<IConstImage> horizontalFlip() const override; | ||||
| 	std::shared_ptr<IConstImage> verticalFlip() const override; | ||||
| 	std::shared_ptr<ImageConstScaled> scaleFast(const Point & size) const; | ||||
| 	std::shared_ptr<ISharedImage> horizontalFlip() const override; | ||||
| 	std::shared_ptr<ISharedImage> verticalFlip() const override; | ||||
| 	std::shared_ptr<ImageSharedScaled> scaleFast(const Point & size) const; | ||||
| }; | ||||
|  | ||||
| class ImageScaled final : public IImage | ||||
| { | ||||
| private: | ||||
| 	std::shared_ptr<ImageConstScaled> image; | ||||
| 	std::shared_ptr<ImageSharedScaled> image; | ||||
|  | ||||
| 	uint8_t alphaValue; | ||||
| 	EImageBlitMode blitMode; | ||||
|  | ||||
| public: | ||||
| 	ImageScaled(const std::shared_ptr<ImageConstScaled> & image, EImageBlitMode mode); | ||||
| 	ImageScaled(const std::shared_ptr<ImageSharedScaled> & image, EImageBlitMode mode); | ||||
|  | ||||
| 	void scaleFast(const Point & size) override; | ||||
| 	void exportBitmap(const boost::filesystem::path & path) const override; | ||||
|   | ||||
| @@ -131,22 +131,22 @@ int RenderHandler::getScalingFactor() const | ||||
| 	return 2; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> RenderHandler::createScaledImage(std::shared_ptr<SDLImageConst> input) | ||||
| std::shared_ptr<ISharedImage> RenderHandler::createScaledImage(std::shared_ptr<SDLImageShared> input) | ||||
| { | ||||
| 	if (getScalingFactor() == 1) | ||||
| 		return input; | ||||
|  | ||||
| 	return std::make_shared<ImageConstScaled>(input); | ||||
| 	return std::make_shared<ImageSharedScaled>(input); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> RenderHandler::loadImageFromSingleFile(const ImagePath & path) | ||||
| std::shared_ptr<ISharedImage> RenderHandler::loadImageFromSingleFile(const ImagePath & path) | ||||
| { | ||||
| 	auto result = createScaledImage(std::make_shared<SDLImageConst>(path)); | ||||
| 	auto result = createScaledImage(std::make_shared<SDLImageShared>(path)); | ||||
| 	imageFiles[ImageLocator(path)] = result; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> RenderHandler::loadImageFromAnimationFileUncached(const AnimationPath & path, int frame, int group) | ||||
| std::shared_ptr<ISharedImage> RenderHandler::loadImageFromAnimationFileUncached(const AnimationPath & path, int frame, int group) | ||||
| { | ||||
| 	const auto & layout = getAnimationLayout(path); | ||||
| 	if (!layout.count(group)) | ||||
| @@ -163,24 +163,24 @@ std::shared_ptr<IConstImage> RenderHandler::loadImageFromAnimationFileUncached(c | ||||
| 	else | ||||
| 	{ | ||||
| 		auto defFile = getAnimationFile(path); | ||||
| 		return createScaledImage(std::make_shared<SDLImageConst>(defFile.get(), frame, group)); | ||||
| 		return createScaledImage(std::make_shared<SDLImageShared>(defFile.get(), frame, group)); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> RenderHandler::loadImageFromAnimationFile(const AnimationPath & path, int frame, int group) | ||||
| std::shared_ptr<ISharedImage> RenderHandler::loadImageFromAnimationFile(const AnimationPath & path, int frame, int group) | ||||
| { | ||||
| 	auto result = loadImageFromAnimationFileUncached(path, frame, group); | ||||
| 	imageFiles[ImageLocator(path, frame, group)] = result; | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> RenderHandler::loadImageImpl(const ImageLocator & locator) | ||||
| std::shared_ptr<ISharedImage> RenderHandler::loadImageImpl(const ImageLocator & locator) | ||||
| { | ||||
| 	auto it = imageFiles.find(locator); | ||||
| 	if (it != imageFiles.end()) | ||||
| 		return it->second; | ||||
|  | ||||
| 	std::shared_ptr<IConstImage> result; | ||||
| 	std::shared_ptr<ISharedImage> result; | ||||
|  | ||||
| 	if (locator.image) | ||||
| 		result = loadImageFromSingleFile(*locator.image); | ||||
| @@ -217,7 +217,7 @@ std::shared_ptr<IImage> RenderHandler::loadImage(const ImagePath & path, EImageB | ||||
|  | ||||
| std::shared_ptr<IImage> RenderHandler::createImage(SDL_Surface * source) | ||||
| { | ||||
| 	return std::make_shared<SDLImageConst>(source)->createImageReference(EImageBlitMode::ALPHA); | ||||
| 	return std::make_shared<SDLImageShared>(source)->createImageReference(EImageBlitMode::ALPHA); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<CAnimation> RenderHandler::loadAnimation(const AnimationPath & path, EImageBlitMode mode) | ||||
|   | ||||
| @@ -16,8 +16,8 @@ class EntityService; | ||||
| VCMI_LIB_NAMESPACE_END | ||||
|  | ||||
| class CDefFile; | ||||
| class SDLImageConst; | ||||
| class IConstImage; | ||||
| class SDLImageShared; | ||||
| class ISharedImage; | ||||
|  | ||||
| class RenderHandler : public IRenderHandler | ||||
| { | ||||
| @@ -25,7 +25,7 @@ class RenderHandler : public IRenderHandler | ||||
|  | ||||
| 	std::map<AnimationPath, std::shared_ptr<CDefFile>> animationFiles; | ||||
| 	std::map<AnimationPath, AnimationLayoutMap> animationLayouts; | ||||
| 	std::map<ImageLocator, std::shared_ptr<IConstImage>> imageFiles; | ||||
| 	std::map<ImageLocator, std::shared_ptr<ISharedImage>> imageFiles; | ||||
|  | ||||
| 	std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path); | ||||
| 	AnimationLayoutMap & getAnimationLayout(const AnimationPath & path); | ||||
| @@ -34,14 +34,14 @@ class RenderHandler : public IRenderHandler | ||||
| 	void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName); | ||||
| 	void addImageListEntries(const EntityService * service); | ||||
|  | ||||
| 	std::shared_ptr<IConstImage> loadImageFromSingleFile(const ImagePath & path); | ||||
| 	std::shared_ptr<IConstImage> loadImageFromAnimationFileUncached(const AnimationPath & path, int frame, int group); | ||||
| 	std::shared_ptr<IConstImage> loadImageFromAnimationFile(const AnimationPath & path, int frame, int group); | ||||
| 	std::shared_ptr<IConstImage> loadImageImpl(const ImageLocator & config); | ||||
| 	std::shared_ptr<ISharedImage> loadImageFromSingleFile(const ImagePath & path); | ||||
| 	std::shared_ptr<ISharedImage> loadImageFromAnimationFileUncached(const AnimationPath & path, int frame, int group); | ||||
| 	std::shared_ptr<ISharedImage> loadImageFromAnimationFile(const AnimationPath & path, int frame, int group); | ||||
| 	std::shared_ptr<ISharedImage> loadImageImpl(const ImageLocator & config); | ||||
|  | ||||
| 	int getScalingFactor() const; | ||||
|  | ||||
| 	std::shared_ptr<IConstImage> createScaledImage(std::shared_ptr<SDLImageConst> input); | ||||
| 	std::shared_ptr<ISharedImage> createScaledImage(std::shared_ptr<SDLImageShared> input); | ||||
| public: | ||||
|  | ||||
| 	// IRenderHandler implementation | ||||
|   | ||||
| @@ -32,7 +32,7 @@ int IImage::height() const | ||||
| 	return dimensions().y; | ||||
| } | ||||
|  | ||||
| SDLImageConst::SDLImageConst(CDefFile * data, size_t frame, size_t group) | ||||
| SDLImageShared::SDLImageShared(CDefFile * data, size_t frame, size_t group) | ||||
| 	: surf(nullptr), | ||||
| 	margins(0, 0), | ||||
| 	fullSize(0, 0), | ||||
| @@ -44,7 +44,7 @@ SDLImageConst::SDLImageConst(CDefFile * data, size_t frame, size_t group) | ||||
| 	savePalette(); | ||||
| } | ||||
|  | ||||
| SDLImageConst::SDLImageConst(SDL_Surface * from) | ||||
| SDLImageShared::SDLImageShared(SDL_Surface * from) | ||||
| 	: surf(nullptr), | ||||
| 	margins(0, 0), | ||||
| 	fullSize(0, 0), | ||||
| @@ -61,7 +61,7 @@ SDLImageConst::SDLImageConst(SDL_Surface * from) | ||||
| 	fullSize.y = surf->h; | ||||
| } | ||||
|  | ||||
| SDLImageConst::SDLImageConst(const ImagePath & filename) | ||||
| SDLImageShared::SDLImageShared(const ImagePath & filename) | ||||
| 	: surf(nullptr), | ||||
| 	margins(0, 0), | ||||
| 	fullSize(0, 0), | ||||
| @@ -83,7 +83,7 @@ SDLImageConst::SDLImageConst(const ImagePath & filename) | ||||
| } | ||||
|  | ||||
|  | ||||
| void SDLImageConst::draw(SDL_Surface * where, SDL_Palette * palette, const Point & dest, const Rect * src, uint8_t alpha, EImageBlitMode mode) const | ||||
| void SDLImageShared::draw(SDL_Surface * where, SDL_Palette * palette, const Point & dest, const Rect * src, uint8_t alpha, EImageBlitMode mode) const | ||||
| { | ||||
| 	if (!surf) | ||||
| 		return; | ||||
| @@ -129,7 +129,7 @@ void SDLImageConst::draw(SDL_Surface * where, SDL_Palette * palette, const Point | ||||
| 	} | ||||
| } | ||||
|  | ||||
| const SDL_Palette * SDLImageConst::getPalette() const | ||||
| const SDL_Palette * SDLImageShared::getPalette() const | ||||
| { | ||||
| 	if (originalPalette == nullptr) | ||||
| 		throw std::runtime_error("Palette not found!"); | ||||
| @@ -137,7 +137,7 @@ const SDL_Palette * SDLImageConst::getPalette() const | ||||
| 	return originalPalette; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<SDLImageConst> SDLImageConst::scaleFast(const Point & size) const | ||||
| std::shared_ptr<SDLImageShared> SDLImageShared::scaleFast(const Point & size) const | ||||
| { | ||||
| 	float scaleX = float(size.x) / dimensions().x; | ||||
| 	float scaleY = float(size.y) / dimensions().y; | ||||
| @@ -151,7 +151,7 @@ std::shared_ptr<SDLImageConst> SDLImageConst::scaleFast(const Point & size) cons | ||||
| 	else | ||||
| 		CSDL_Ext::setDefaultColorKey(scaled);//just in case | ||||
|  | ||||
| 	auto ret = std::make_shared<SDLImageConst>(scaled); | ||||
| 	auto ret = std::make_shared<SDLImageShared>(scaled); | ||||
|  | ||||
| 	ret->fullSize.x = (int) round((float)fullSize.x * scaleX); | ||||
| 	ret->fullSize.y = (int) round((float)fullSize.y * scaleY); | ||||
| @@ -165,7 +165,7 @@ std::shared_ptr<SDLImageConst> SDLImageConst::scaleFast(const Point & size) cons | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| void SDLImageConst::exportBitmap(const boost::filesystem::path& path) const | ||||
| void SDLImageShared::exportBitmap(const boost::filesystem::path& path) const | ||||
| { | ||||
| 	SDL_SaveBMP(surf, path.string().c_str()); | ||||
| } | ||||
| @@ -181,7 +181,7 @@ void SDLImageIndexed::setFlagColor(PlayerColor player) | ||||
| 		graphics->setPlayerFlagColor(currentPalette, player); | ||||
| } | ||||
|  | ||||
| bool SDLImageConst::isTransparent(const Point & coords) const | ||||
| bool SDLImageShared::isTransparent(const Point & coords) const | ||||
| { | ||||
| 	if (surf) | ||||
| 		return CSDL_Ext::isTransparent(surf, coords.x, coords.y); | ||||
| @@ -189,12 +189,12 @@ bool SDLImageConst::isTransparent(const Point & coords) const | ||||
| 		return true; | ||||
| } | ||||
|  | ||||
| Point SDLImageConst::dimensions() const | ||||
| Point SDLImageShared::dimensions() const | ||||
| { | ||||
| 	return fullSize; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IImage> SDLImageConst::createImageReference(EImageBlitMode mode) | ||||
| std::shared_ptr<IImage> SDLImageShared::createImageReference(EImageBlitMode mode) | ||||
| { | ||||
| 	if (surf && surf->format->palette) | ||||
| 		return std::make_shared<SDLImageIndexed>(shared_from_this(), mode); | ||||
| @@ -202,10 +202,10 @@ std::shared_ptr<IImage> SDLImageConst::createImageReference(EImageBlitMode mode) | ||||
| 		return std::make_shared<SDLImageRGB>(shared_from_this(), mode); | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> SDLImageConst::horizontalFlip() const | ||||
| std::shared_ptr<ISharedImage> SDLImageShared::horizontalFlip() const | ||||
| { | ||||
| 	SDL_Surface * flipped = CSDL_Ext::horizontalFlip(surf); | ||||
| 	auto ret = std::make_shared<SDLImageConst>(flipped); | ||||
| 	auto ret = std::make_shared<SDLImageShared>(flipped); | ||||
| 	ret->fullSize = fullSize; | ||||
| 	ret->margins.x = margins.x; | ||||
| 	ret->margins.y = fullSize.y - surf->h - margins.y; | ||||
| @@ -214,10 +214,10 @@ std::shared_ptr<IConstImage> SDLImageConst::horizontalFlip() const | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| std::shared_ptr<IConstImage> SDLImageConst::verticalFlip() const | ||||
| std::shared_ptr<ISharedImage> SDLImageShared::verticalFlip() const | ||||
| { | ||||
| 	SDL_Surface * flipped = CSDL_Ext::verticalFlip(surf); | ||||
| 	auto ret = std::make_shared<SDLImageConst>(flipped); | ||||
| 	auto ret = std::make_shared<SDLImageShared>(flipped); | ||||
| 	ret->fullSize = fullSize; | ||||
| 	ret->margins.x = fullSize.x - surf->w - margins.x; | ||||
| 	ret->margins.y = margins.y; | ||||
| @@ -227,7 +227,7 @@ std::shared_ptr<IConstImage> SDLImageConst::verticalFlip() const | ||||
| } | ||||
|  | ||||
| // Keep the original palette, in order to do color switching operation | ||||
| void SDLImageConst::savePalette() | ||||
| void SDLImageShared::savePalette() | ||||
| { | ||||
| 	// For some images that don't have palette, skip this | ||||
| 	if(surf->format->palette == nullptr) | ||||
| @@ -265,7 +265,7 @@ void SDLImageIndexed::adjustPalette(const ColorFilter & shifter, uint32_t colors | ||||
| 	} | ||||
| } | ||||
|  | ||||
| SDLImageIndexed::SDLImageIndexed(const std::shared_ptr<SDLImageConst> & image, EImageBlitMode mode) | ||||
| SDLImageIndexed::SDLImageIndexed(const std::shared_ptr<SDLImageShared> & image, EImageBlitMode mode) | ||||
| 	:SDLImageBase::SDLImageBase(image, mode) | ||||
| { | ||||
| 	auto originalPalette = image->getPalette(); | ||||
| @@ -290,13 +290,13 @@ void SDLImageIndexed::setSpecialPalette(const IImage::SpecialPalette & specialPa | ||||
| 	} | ||||
| } | ||||
|  | ||||
| SDLImageConst::~SDLImageConst() | ||||
| SDLImageShared::~SDLImageShared() | ||||
| { | ||||
| 	SDL_FreeSurface(surf); | ||||
| 	SDL_FreePalette(originalPalette); | ||||
| } | ||||
|  | ||||
| SDLImageBase::SDLImageBase(const std::shared_ptr<SDLImageConst> & image, EImageBlitMode mode) | ||||
| SDLImageBase::SDLImageBase(const std::shared_ptr<SDLImageShared> & image, EImageBlitMode mode) | ||||
| 	:image(image) | ||||
| 	, alphaValue(SDL_ALPHA_OPAQUE) | ||||
| 	, blitMode(mode) | ||||
|   | ||||
| @@ -24,7 +24,7 @@ struct SDL_Palette; | ||||
| /* | ||||
|  * Wrapper around SDL_Surface | ||||
|  */ | ||||
| class SDLImageConst final : public IConstImage, public std::enable_shared_from_this<SDLImageConst>, boost::noncopyable | ||||
| class SDLImageShared final : public ISharedImage, public std::enable_shared_from_this<SDLImageShared>, boost::noncopyable | ||||
| { | ||||
| 	//Surface without empty borders | ||||
| 	SDL_Surface * surf; | ||||
| @@ -40,12 +40,12 @@ class SDLImageConst final : public IConstImage, public std::enable_shared_from_t | ||||
|  | ||||
| public: | ||||
| 	//Load image from def file | ||||
| 	SDLImageConst(CDefFile *data, size_t frame, size_t group=0); | ||||
| 	SDLImageShared(CDefFile *data, size_t frame, size_t group=0); | ||||
| 	//Load from bitmap file | ||||
| 	SDLImageConst(const ImagePath & filename); | ||||
| 	SDLImageShared(const ImagePath & filename); | ||||
| 	//Create using existing surface, extraRef will increase refcount on SDL_Surface | ||||
| 	SDLImageConst(SDL_Surface * from); | ||||
| 	~SDLImageConst(); | ||||
| 	SDLImageShared(SDL_Surface * from); | ||||
| 	~SDLImageShared(); | ||||
|  | ||||
| 	void draw(SDL_Surface * where, SDL_Palette * palette, const Point & dest, const Rect * src, uint8_t alpha, EImageBlitMode mode) const; | ||||
|  | ||||
| @@ -53,9 +53,9 @@ public: | ||||
| 	Point dimensions() const override; | ||||
| 	bool isTransparent(const Point & coords) const override; | ||||
| 	std::shared_ptr<IImage> createImageReference(EImageBlitMode mode) override; | ||||
| 	std::shared_ptr<IConstImage> horizontalFlip() const override; | ||||
| 	std::shared_ptr<IConstImage> verticalFlip() const override; | ||||
| 	std::shared_ptr<SDLImageConst> scaleFast(const Point & size) const; | ||||
| 	std::shared_ptr<ISharedImage> horizontalFlip() const override; | ||||
| 	std::shared_ptr<ISharedImage> verticalFlip() const override; | ||||
| 	std::shared_ptr<SDLImageShared> scaleFast(const Point & size) const; | ||||
|  | ||||
| 	const SDL_Palette * getPalette() const; | ||||
|  | ||||
| @@ -65,13 +65,13 @@ public: | ||||
| class SDLImageBase : public IImage, boost::noncopyable | ||||
| { | ||||
| protected: | ||||
| 	std::shared_ptr<SDLImageConst> image; | ||||
| 	std::shared_ptr<SDLImageShared> image; | ||||
|  | ||||
| 	uint8_t alphaValue; | ||||
| 	EImageBlitMode blitMode; | ||||
|  | ||||
| public: | ||||
| 	SDLImageBase(const std::shared_ptr<SDLImageConst> & image, EImageBlitMode mode); | ||||
| 	SDLImageBase(const std::shared_ptr<SDLImageShared> & image, EImageBlitMode mode); | ||||
|  | ||||
| 	void scaleFast(const Point & size) override; | ||||
| 	void exportBitmap(const boost::filesystem::path & path) const override; | ||||
| @@ -86,7 +86,7 @@ class SDLImageIndexed final : public SDLImageBase | ||||
| 	SDL_Palette * currentPalette = nullptr; | ||||
|  | ||||
| public: | ||||
| 	SDLImageIndexed(const std::shared_ptr<SDLImageConst> & image, EImageBlitMode mode); | ||||
| 	SDLImageIndexed(const std::shared_ptr<SDLImageShared> & image, EImageBlitMode mode); | ||||
| 	~SDLImageIndexed(); | ||||
|  | ||||
| 	void draw(SDL_Surface * where, const Point & pos, const Rect * src) const override; | ||||
|   | ||||
| @@ -17,7 +17,7 @@ | ||||
|  | ||||
| #include <SDL_surface.h> | ||||
|  | ||||
| SDLImageLoader::SDLImageLoader(SDLImageConst * Img): | ||||
| SDLImageLoader::SDLImageLoader(SDLImageShared * Img): | ||||
| 	image(Img), | ||||
| 	lineStart(nullptr), | ||||
| 	position(nullptr) | ||||
|   | ||||
| @@ -11,13 +11,13 @@ | ||||
|  | ||||
| #include "../render/IImageLoader.h" | ||||
|  | ||||
| class SDLImageConst; | ||||
| class SDLImageShared; | ||||
|  | ||||
| class SDLImageLoader : public IImageLoader | ||||
| { | ||||
| 	static constexpr int DEFAULT_PALETTE_COLORS = 256; | ||||
|  | ||||
| 	SDLImageConst * image; | ||||
| 	SDLImageShared * image; | ||||
| 	ui8 * lineStart; | ||||
| 	ui8 * position; | ||||
| public: | ||||
| @@ -29,7 +29,7 @@ public: | ||||
| 	//init image with these sizes and palette | ||||
| 	void init(Point SpriteSize, Point Margins, Point FullSize, SDL_Color *pal); | ||||
|  | ||||
| 	SDLImageLoader(SDLImageConst * Img); | ||||
| 	SDLImageLoader(SDLImageShared * Img); | ||||
| 	~SDLImageLoader(); | ||||
| }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user