mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
no async for generated images
This commit is contained in:
@@ -128,6 +128,10 @@ public:
|
||||
/// Returns true if this image is still loading and can't be used
|
||||
virtual bool isLoading() const = 0;
|
||||
|
||||
/// When disabled upscaling needs to be done in sync (e.g. because there is no 1x base image)
|
||||
virtual void setAsyncUpscale(bool on) = 0;
|
||||
virtual bool getAsyncUpscale() const = 0;
|
||||
|
||||
virtual ~ISharedImage() = default;
|
||||
|
||||
virtual const SDL_Palette * getPalette() const = 0;
|
||||
|
||||
@@ -333,6 +333,9 @@ std::shared_ptr<SDLImageShared> RenderHandler::loadScaledImage(const ImageLocato
|
||||
img = img->drawShadow((*locator.generateShadow) == SharedImageLocator::ShadowMode::SHADOW_SHEAR);
|
||||
if(isOverlay && generateOverlay && (*locator.generateOverlay) == SharedImageLocator::OverlayMode::OVERLAY_OUTLINE)
|
||||
img = img->drawOutline(Colors::WHITE, 1);
|
||||
|
||||
if(locator.scalingFactor == 1)
|
||||
img->setAsyncUpscale(false); // no base image, needs to be done in sync
|
||||
}
|
||||
|
||||
return img;
|
||||
|
||||
@@ -271,7 +271,7 @@ std::shared_ptr<SDLImageShared> SDLImageShared::createScaled(const SDLImageShare
|
||||
self->upscalingInProgress = false;
|
||||
};
|
||||
|
||||
if(settings["video"]["asyncUpscaling"].Bool())
|
||||
if(settings["video"]["asyncUpscaling"].Bool() && from->getAsyncUpscale())
|
||||
ENGINE->async().run(scalingTask);
|
||||
else
|
||||
scalingTask();
|
||||
@@ -284,6 +284,16 @@ bool SDLImageShared::isLoading() const
|
||||
return upscalingInProgress;
|
||||
}
|
||||
|
||||
void SDLImageShared::setAsyncUpscale(bool on)
|
||||
{
|
||||
asyncUpscale = on;
|
||||
}
|
||||
|
||||
bool SDLImageShared::getAsyncUpscale() const
|
||||
{
|
||||
return asyncUpscale;
|
||||
}
|
||||
|
||||
std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Palette * palette) const
|
||||
{
|
||||
if(upscalingInProgress)
|
||||
|
||||
@@ -36,6 +36,7 @@ class SDLImageShared final : public ISharedImage, public std::enable_shared_from
|
||||
Point fullSize;
|
||||
|
||||
std::atomic_bool upscalingInProgress = false;
|
||||
bool asyncUpscale = true;
|
||||
|
||||
// Keep the original palette, in order to do color switching operation
|
||||
void savePalette();
|
||||
@@ -63,6 +64,8 @@ public:
|
||||
Rect contentRect() const override;
|
||||
|
||||
bool isLoading() const override;
|
||||
void setAsyncUpscale(bool on) override;
|
||||
bool getAsyncUpscale() const override;
|
||||
|
||||
const SDL_Palette * getPalette() const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user