From 6f4e8de059078057a28db2e7e331bbd365e74c2e Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Thu, 13 Oct 2022 04:37:41 +0200 Subject: [PATCH 1/3] Fix crash when navigating before the first camera keyframe --- core_lib/src/structure/layercamera.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/core_lib/src/structure/layercamera.cpp b/core_lib/src/structure/layercamera.cpp index 2d4712ed69..07f3da3226 100644 --- a/core_lib/src/structure/layercamera.cpp +++ b/core_lib/src/structure/layercamera.cpp @@ -61,11 +61,9 @@ QTransform LayerCamera::getViewAtFrame(int frameNumber) const } Camera* camera1 = static_cast(getLastKeyFrameAtPosition(frameNumber)); - camera1->setEasingType(camera1->getEasingType()); int nextFrame = getNextKeyFramePosition(frameNumber); Camera* camera2 = static_cast(getLastKeyFrameAtPosition(nextFrame)); - camera2->setEasingType(camera2->getEasingType()); if (camera1 == nullptr && camera2 == nullptr) { From 9fbb7710c881570bf936b2e8dabfd06d60d63291 Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Thu, 13 Oct 2022 13:31:22 +0200 Subject: [PATCH 2/3] Fix unintentional reset of internal clipboard position data --- core_lib/src/managers/clipboardmanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core_lib/src/managers/clipboardmanager.cpp b/core_lib/src/managers/clipboardmanager.cpp index f1ccf279d2..a6ad45da96 100644 --- a/core_lib/src/managers/clipboardmanager.cpp +++ b/core_lib/src/managers/clipboardmanager.cpp @@ -34,10 +34,14 @@ void ClipboardManager::setFromSystemClipboard(const QPointF& pos, const Layer* l { // We intentially do not call resetStates here because we can only store image changes to the clipboard // otherwise we break pasting for vector. + // Only bitmap is supported currently... + // Only update clipboard data if it was stored by other applications + if (layer->type() != Layer::BITMAP || mClipboard->ownsClipboard()) { + return; + } QImage image = mClipboard->image(QClipboard::Clipboard); - // Only bitmap is supported currently... - if (layer->type() == Layer::BITMAP && !image.isNull()) { + if (!image.isNull()) { mBitmapImage = BitmapImage(pos.toPoint()-QPoint(image.size().width()/2, image.size().height()/2), image); } } From 0091efd3dfe372d378da4f4a331049a69ff8562e Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Fri, 14 Oct 2022 02:30:10 +0200 Subject: [PATCH 3/3] Ensure BitmapImage always uses premultiplied ARGB32 format --- core_lib/src/graphics/bitmap/bitmapimage.cpp | 13 +++---------- tests/src/test_bitmapbucket.cpp | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/core_lib/src/graphics/bitmap/bitmapimage.cpp b/core_lib/src/graphics/bitmap/bitmapimage.cpp index 7ea0797ae0..e334e84f92 100644 --- a/core_lib/src/graphics/bitmap/bitmapimage.cpp +++ b/core_lib/src/graphics/bitmap/bitmapimage.cpp @@ -51,7 +51,7 @@ BitmapImage::BitmapImage(const QPoint& topLeft, const QImage& image) { mBounds = QRect(topLeft, image.size()); mMinBound = true; - mImage = image; + mImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); } BitmapImage::BitmapImage(const QPoint& topLeft, const QString& path) @@ -70,7 +70,7 @@ BitmapImage::~BitmapImage() void BitmapImage::setImage(QImage* img) { - Q_ASSERT(img); + Q_ASSERT(img && img->format() == QImage::Format_ARGB32_Premultiplied); mImage = *img; mMinBound = false; @@ -125,7 +125,7 @@ void BitmapImage::loadFile() { if (!fileName().isEmpty() && !isLoaded()) { - mImage = QImage(fileName()); + mImage = QImage(fileName()).convertToFormat(QImage::Format_ARGB32_Premultiplied); mBounds.setSize(mImage.size()); mMinBound = false; } @@ -182,13 +182,6 @@ BitmapImage BitmapImage::copy(QRect rectangle) QRect intersection2 = rectangle.translated(-mBounds.topLeft()); - // If the region goes out of bounds, make sure the image is formatted in ARGB - // so that the area beyond the image bounds is transparent. - if (!mBounds.contains(rectangle) && !image()->hasAlphaChannel()) - { - mImage = mImage.convertToFormat(QImage::Format_ARGB32); - } - BitmapImage result(rectangle.topLeft(), image()->copy(intersection2)); return result; } diff --git a/tests/src/test_bitmapbucket.cpp b/tests/src/test_bitmapbucket.cpp index 2030a60311..4b7db42665 100644 --- a/tests/src/test_bitmapbucket.cpp +++ b/tests/src/test_bitmapbucket.cpp @@ -90,7 +90,7 @@ TEST_CASE("BitmapBucket - Fill drag logic") image->writeFile(resultsPath + "test1.png"); - verifyPixels(pressPoint, image, fillColor.rgba()); + verifyPixels(pressPoint, image, qPremultiply(fillColor.rgba())); } SECTION("FillTo: Layer below - reference: current layer") @@ -133,6 +133,6 @@ TEST_CASE("BitmapBucket - Fill drag logic") image->writeFile(resultsPath + "test4.png"); - verifyPixels(pressPoint, image, fillColor.rgba()); + verifyPixels(pressPoint, image, qPremultiply(fillColor.rgba())); } }