Skip to content

Commit

Permalink
Regression - #1799: Fix pen dabs being added to each other
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Dec 3, 2023
1 parent 18c5494 commit 8baa511
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
3 changes: 2 additions & 1 deletion core_lib/src/canvaspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
15 changes: 3 additions & 12 deletions core_lib/src/interface/scribblearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8baa511

Please sign in to comment.