1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

no async for generated images

This commit is contained in:
Laserlicht
2025-08-17 15:46:59 +02:00
parent 182100dfd1
commit c9834c43d6
4 changed files with 21 additions and 1 deletions

View File

@@ -128,6 +128,10 @@ public:
/// Returns true if this image is still loading and can't be used /// Returns true if this image is still loading and can't be used
virtual bool isLoading() const = 0; 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 ~ISharedImage() = default;
virtual const SDL_Palette * getPalette() const = 0; virtual const SDL_Palette * getPalette() const = 0;

View File

@@ -333,6 +333,9 @@ std::shared_ptr<SDLImageShared> RenderHandler::loadScaledImage(const ImageLocato
img = img->drawShadow((*locator.generateShadow) == SharedImageLocator::ShadowMode::SHADOW_SHEAR); img = img->drawShadow((*locator.generateShadow) == SharedImageLocator::ShadowMode::SHADOW_SHEAR);
if(isOverlay && generateOverlay && (*locator.generateOverlay) == SharedImageLocator::OverlayMode::OVERLAY_OUTLINE) if(isOverlay && generateOverlay && (*locator.generateOverlay) == SharedImageLocator::OverlayMode::OVERLAY_OUTLINE)
img = img->drawOutline(Colors::WHITE, 1); img = img->drawOutline(Colors::WHITE, 1);
if(locator.scalingFactor == 1)
img->setAsyncUpscale(false); // no base image, needs to be done in sync
} }
return img; return img;

View File

@@ -271,7 +271,7 @@ std::shared_ptr<SDLImageShared> SDLImageShared::createScaled(const SDLImageShare
self->upscalingInProgress = false; self->upscalingInProgress = false;
}; };
if(settings["video"]["asyncUpscaling"].Bool()) if(settings["video"]["asyncUpscaling"].Bool() && from->getAsyncUpscale())
ENGINE->async().run(scalingTask); ENGINE->async().run(scalingTask);
else else
scalingTask(); scalingTask();
@@ -284,6 +284,16 @@ bool SDLImageShared::isLoading() const
return upscalingInProgress; 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 std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Palette * palette) const
{ {
if(upscalingInProgress) if(upscalingInProgress)

View File

@@ -36,6 +36,7 @@ class SDLImageShared final : public ISharedImage, public std::enable_shared_from
Point fullSize; Point fullSize;
std::atomic_bool upscalingInProgress = false; std::atomic_bool upscalingInProgress = false;
bool asyncUpscale = true;
// Keep the original palette, in order to do color switching operation // Keep the original palette, in order to do color switching operation
void savePalette(); void savePalette();
@@ -63,6 +64,8 @@ public:
Rect contentRect() const override; Rect contentRect() const override;
bool isLoading() const override; bool isLoading() const override;
void setAsyncUpscale(bool on) override;
bool getAsyncUpscale() const override;
const SDL_Palette * getPalette() const override; const SDL_Palette * getPalette() const override;