Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/application/StarMainApplication_sdl.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-26 18:05:00 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-26 18:05:00 +1000
commit32411daa670e57150d6a5c54593305ddd09693d1 (patch)
treec92e42dbeae298fb079b0fd8a84fa7b22256c3e3 /source/application/StarMainApplication_sdl.cpp
parentc6cb370c1356d16c477f2759f98b55dfa480b71e (diff)
Fix 1:1 scale cursors being Australian
Diffstat (limited to 'source/application/StarMainApplication_sdl.cpp')
-rw-r--r--source/application/StarMainApplication_sdl.cpp26
1 files changed, 14 insertions, 12 deletions
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<CursorEntry>();
- if (scale != 1) {
- List<ImageOperation> 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<ImageOperation> 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<Image>(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<Image>(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;