Skip to content

Commit

Permalink
Fix delayed vector transformation rendering (#1818)
Browse files Browse the repository at this point in the history
* Fix vector selection not being painted immediately during undo/redo

* Simplify CanvasPainter::paintCurrentFrame logic

Since we're always drawing the backbuffer, the logic gates are redundant.
  • Loading branch information
MrStevns authored Apr 11, 2024
1 parent 68dc4ee commit f741205
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions core_lib/src/canvaspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,15 @@ void CanvasPainter::paintCurrentBitmapFrame(QPainter& painter, const QRect& blit
painter.setOpacity(paintedImage->getOpacity() - (1.0-painter.opacity()));
painter.setWorldMatrixEnabled(false);

currentBitmapPainter.drawImage(paintedImage->topLeft(), *paintedImage->image());

if (isCurrentLayer && isDrawing)
{
currentBitmapPainter.drawImage(paintedImage->topLeft(), *paintedImage->image());

currentBitmapPainter.setCompositionMode(mOptions.cmBufferBlendMode);
const auto tiles = mTiledBuffer->tiles();
for (const Tile* tile : tiles) {
currentBitmapPainter.drawPixmap(tile->posF(), tile->pixmap());
}
} else {
// When we're drawing using a tool, the surface will be painted by the tiled buffer,
// and thus we don't want to paint the current image again
// When we're on another layer though, the tiled buffer is not used
currentBitmapPainter.drawImage(paintedImage->topLeft(), *paintedImage->image());
}

// We do not wish to draw selection transformations on anything but the current layer
Expand All @@ -337,19 +332,19 @@ void CanvasPainter::paintCurrentVectorFrame(QPainter& painter, const QRect& blit

const bool isDrawing = mTiledBuffer->isValid();

if (mRenderTransform) {
vectorImage->setSelectionTransformation(mSelectionTransform);
}

// Paint existing vector image to the painter
vectorImage->paintImage(currentVectorPainter, *mObject, mOptions.bOutlines, mOptions.bThinLines, mOptions.bAntiAlias);

if (isCurrentLayer) {
if (isDrawing) {
currentVectorPainter.setCompositionMode(mOptions.cmBufferBlendMode);
if (isCurrentLayer && isDrawing) {
currentVectorPainter.setCompositionMode(mOptions.cmBufferBlendMode);

const auto tiles = mTiledBuffer->tiles();
for (const Tile* tile : tiles) {
currentVectorPainter.drawPixmap(tile->posF(), tile->pixmap());
}
} else if (mRenderTransform) {
vectorImage->setSelectionTransformation(mSelectionTransform);
const auto tiles = mTiledBuffer->tiles();
for (const Tile* tile : tiles) {
currentVectorPainter.drawPixmap(tile->posF(), tile->pixmap());
}
}

Expand Down

0 comments on commit f741205

Please sign in to comment.