From 8baa511ba00fa9295dcf8fb3333e58a48c03408c Mon Sep 17 00:00:00 2001 From: MrStevns Date: Sun, 3 Dec 2023 19:17:41 +0100 Subject: [PATCH] Regression - #1799: Fix pen dabs being added to each other --- core_lib/src/canvaspainter.cpp | 3 ++- core_lib/src/interface/scribblearea.cpp | 15 +++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/core_lib/src/canvaspainter.cpp b/core_lib/src/canvaspainter.cpp index 24529ec38..ca63f3d0f 100644 --- a/core_lib/src/canvaspainter.cpp +++ b/core_lib/src/canvaspainter.cpp @@ -305,8 +305,9 @@ void CanvasPainter::paintCurrentBitmapFrame(QPainter& painter, const QRect& blit // so in that case, in order to see the previously laid-down polyline stroke, // the surrounding area must be drawn again before // applying the new tiled output on top + if (!blitRect.contains(mTiledBuffer->bounds()) || mOptions.bIgnoreCanvasBuffer) { - currentBitmapPainter.setCompositionMode(QPainter::CompositionMode_Source); + currentBitmapPainter.setCompositionMode(QPainter::CompositionMode_SourceOver); currentBitmapPainter.drawImage(paintedImage->topLeft(), *paintedImage->image()); } diff --git a/core_lib/src/interface/scribblearea.cpp b/core_lib/src/interface/scribblearea.cpp index 4e8d5e319..3ff8e8dec 100644 --- a/core_lib/src/interface/scribblearea.cpp +++ b/core_lib/src/interface/scribblearea.cpp @@ -202,16 +202,6 @@ void ScribbleArea::onTileUpdated(TiledBuffer* tiledBuffer, Tile* tile) void ScribbleArea::onTileCreated(TiledBuffer* tiledBuffer, Tile* tile) { Q_UNUSED(tiledBuffer) - Layer::LAYER_TYPE layerType = mEditor->layers()->currentLayer()->type(); - if (layerType == Layer::BITMAP) { - const auto& bitmapImage = currentBitmapImage(mEditor->layers()->currentLayer()); - const QImage& image = *bitmapImage->image(); - tile->load(image, bitmapImage->topLeft()); - } else if (layerType == Layer::VECTOR) { - - // Not used, we only use the buffer to paint the stroke before painting the real vector stroke - } - const QRectF& mappedRect = mEditor->view()->getView().mapRect(QRectF(tile->bounds())); update(mappedRect.toAlignedRect()); } @@ -855,7 +845,7 @@ void ScribbleArea::paintBitmapBuffer() BitmapImage* targetImage = currentBitmapImage(layer); if (targetImage != nullptr) { - targetImage->paste(&mTiledBuffer, QPainter::CompositionMode_Source); + targetImage->paste(&mTiledBuffer, QPainter::CompositionMode_SourceOver); } QRect rect = mEditor->view()->mapCanvasToScreen(mTiledBuffer.bounds()).toRect(); @@ -1270,7 +1260,8 @@ void ScribbleArea::drawPath(QPainterPath path, QPen pen, QBrush brush, QPainter: void ScribbleArea::drawPen(QPointF thePoint, qreal brushWidth, QColor fillColor, bool useAA) { - mTiledBuffer.drawBrush(thePoint, brushWidth, mEditor->view()->mapScreenToCanvas(mCursorImg.rect()).width(), Qt::NoPen, QBrush(fillColor, Qt::SolidPattern), QPainter::CompositionMode_SourceOver, useAA); + // We use Source as opposed to SourceOver here to avoid the dabs being added on top of each other + mTiledBuffer.drawBrush(thePoint, brushWidth, mEditor->view()->mapScreenToCanvas(mCursorImg.rect()).width(), Qt::NoPen, QBrush(fillColor, Qt::SolidPattern), QPainter::CompositionMode_Source, useAA); } void ScribbleArea::drawPencil(QPointF thePoint, qreal brushWidth, qreal fixedBrushFeather, QColor fillColor, qreal opacity)