From 32411daa670e57150d6a5c54593305ddd09693d1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:05:00 +1000 Subject: Fix 1:1 scale cursors being Australian --- source/application/StarMainApplication_sdl.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'source/application/StarMainApplication_sdl.cpp') diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp index 6831a4f..45e224d 100644 --- a/source/application/StarMainApplication_sdl.cpp +++ b/source/application/StarMainApplication_sdl.cpp @@ -681,20 +681,22 @@ private: auto& entry = m_cursorCache.get(m_currentCursor = { scale, offset, id }, [&](auto const&) { auto entry = std::make_shared(); - if (scale != 1) { - List operations{ - FlipImageOperation{FlipImageOperation::Mode::FlipY}, // SDL wants an Australian cursor. - BorderImageOperation{1, Vec4B(), Vec4B(), false, false}, // Nearest scaling fucks up and clips half off the edges, work around this with border+crop for now. - ScaleImageOperation{ScaleImageOperation::Mode::Nearest, Vec2F::filled(scale)}, - CropImageOperation{RectI::withSize(Vec2I::filled(ceilf((float)scale / 2)), Vec2I(imageSize))} + List operations; + if (scale != 1) + operations = { + FlipImageOperation{ FlipImageOperation::Mode::FlipY }, // SDL wants an Australian cursor. + BorderImageOperation{ 1, Vec4B(), Vec4B(), false, false }, // Nearest scaling fucks up and clips half off the edges, work around this with border+crop for now. + ScaleImageOperation{ ScaleImageOperation::Mode::Nearest, Vec2F::filled(scale) }, + CropImageOperation{ RectI::withSize(Vec2I::filled(ceilf((float)scale / 2)), Vec2I(imageSize)) } }; - auto newImage = std::make_shared(move(processImageOperations(operations, *image))); - // Fix fully transparent pixels inverting the underlying display pixel on Windows (allowing this could be made configurable per cursor later!) - newImage->forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { if (!pixel[3]) pixel[0] = pixel[1] = pixel[2] = 0; }); - entry->image = move(newImage); - } else - entry->image = image; + operations = { FlipImageOperation{ FlipImageOperation::Mode::FlipY } }; + + auto newImage = std::make_shared(move(processImageOperations(operations, *image))); + // Fix fully transparent pixels inverting the underlying display pixel on Windows (allowing this could be made configurable per cursor later!) + newImage->forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { if (!pixel[3]) pixel[0] = pixel[1] = pixel[2] = 0; }); + entry->image = move(newImage); + auto size = entry->image->size(); uint32_t pixelFormat; -- cgit v1.2.3