Commit d4556045 authored by Agata Cacko's avatar Agata Cacko Committed by Halla Rempt
Browse files

Remove the workaround border from the ref images

Before this commit, Reference Images would use the same workaround
as the brush tips since they all use KisQImagePyramid.
However it is not needed for Reference Images and creates
an empty margin around the images.

This commit adds a new method to KisQImagePyramid to get the image
without the workaround border.
(The workaround is just 1 pixel of transparency around the whole edge
that KisQImagePyramid is returning as the closest mipmap image).

CCBUG:411118
(cherry picked from commit fb247f6a)
parent d6185420
......@@ -335,3 +335,12 @@ QImage KisQImagePyramid::getClosest(QTransform transform, qreal *scale) const
int level = findNearestLevel(estimatedScale, scale);
return m_levels[level].image;
}
QImage KisQImagePyramid::getClosestWithoutWorkaroundBorder(QTransform transform, qreal *scale) const
{
QImage image = getClosest(transform, scale);
return image.copy(QPAINTER_WORKAROUND_BORDER,
QPAINTER_WORKAROUND_BORDER,
image.width() - 2 * QPAINTER_WORKAROUND_BORDER,
image.height() - 2 * QPAINTER_WORKAROUND_BORDER);
}
......@@ -43,6 +43,8 @@ public:
QImage getClosest(QTransform transform, qreal *scale) const;
QImage getClosestWithoutWorkaroundBorder(QTransform transform, qreal *scale) const;
private:
friend class KisGbrBrushTest;
int findNearestLevel(qreal scale, qreal *baseScale) const;
......
......@@ -234,7 +234,7 @@ void KisReferenceImage::paint(QPainter &gc, KoShapePaintingContext &/*paintconte
QTransform devicePixelRatioFTransform = QTransform::fromScale(gc.device()->devicePixelRatioF(), gc.device()->devicePixelRatioF());
// all three transformations: scale and rotation done by the user, scale from highDPI display, and zoom + rotation of the view
// order: zoom/rotation of the view; scale to high res; scale and rotation done by the user
QImage prescaled = d->mipmap.getClosest(transform * devicePixelRatioFTransform * gc.transform(), &scale);
QImage prescaled = d->mipmap.getClosestWithoutWorkaroundBorder(transform * devicePixelRatioFTransform * gc.transform(), &scale);
transform.scale(1.0 / scale, 1.0 / scale);
if (scale > 1.0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment