[graphics/krita] libs/ui/tool: Fix normal view peaking in when zooming at the edge of canvas

Emmet O'Neill <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit a72b8fd65af2612fbf615a847b1d86ad19e37a41 by Emmet O'Neill, on behalf of Le Tien Dat.
Committed on 13/08/2026 at 23:16.
Pushed by emmetoneill into branch 'master'.

Fix normal view peaking in when zooming at the edge of canvas

M  +21   -6    libs/ui/tool/KisAsyncColorSamplerHelper.cpp

https://invent.kde.org/graphics/krita/-/commit/a72b8fd65af2612fbf615a847b1d86ad19e37a41

diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
index a08c5563616..9e9e48c8921 100644
--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
@@ -482,6 +482,15 @@ void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,
     if (needsNewCache || (needsDualColor && !qFuzzyCompare(m_d->cacheRotation, canvasRotationAngle))) {
         m_d->cacheRotation = canvasRotationAngle;
 
+        QColor backgroundColor = colorWithAlpha(qApp->palette().color(QPalette::Base), OPACITY_OPAQUE_U8 / 2 + 1);
+        qreal penWidth = m_d->circlePreviewDiameter > 100 ? (2.0 * dpr) : (1.0 * dpr);
+        QPen pen = QPen(backgroundColor, penWidth);
+        if (m_d->circlePreviewOutlineEnabled) {
+            cachePainter.setPen(pen);
+        } else {
+            cachePainter.setPen(Qt::NoPen);
+        }
+
         QRectF outerRect = cacheRect.marginsRemoved(QMarginsF(penWidth, penWidth, penWidth, penWidth));
 
         if (needsDualColor) {
@@ -544,11 +553,17 @@ void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,
         }
     }
 
-    // Always need to clear the center because canvas preview is set to DestinationOver
+    // Clear the center if no zoom
+    // Or fill with an opaque color to hide normal view when zooming at edge of canvas
     cachePainter.setPen(Qt::NoPen);
     // If the cached block don't run, no brush is set. So set it
-    cachePainter.setBrush(Qt::transparent);
-    cachePainter.setCompositionMode(QPainter::CompositionMode_Clear);
+    cachePainter.setBrush(qApp->palette().color(QPalette::ColorRole::Base));
+    if (m_d->circleZoomPreviewScale > 1){
+        cachePainter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+    }
+    else {
+        cachePainter.setCompositionMode(QPainter::CompositionMode_Clear);
+    }
     cachePainter.drawPath(tf.map(m_d->cacheCircleInnerClip));
 
     if (m_d->circleZoomPreviewScale > 1) {
@@ -556,9 +571,9 @@ void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,
         sampleDocRectF.setSize(sampleDocRectF.size() / m_d->circleZoomPreviewScale);
         sampleDocRectF.moveCenter(m_d->previewDocRect.center());
 
-        paintCircleReferenceImagePreview(cachePainter, cacheRect, sampleDocRectF, tf.map(m_d->cacheCircleInnerClip));
-
         paintCircleCanvasPreview(cachePainter, cacheRect, sampleDocRectF, tf.map(m_d->cacheCircleInnerClip));
+
+        paintCircleReferenceImagePreview(cachePainter, cacheRect, sampleDocRectF, tf.map(m_d->cacheCircleInnerClip));
     }
 
     gc.drawPixmap(viewRectF.toRect(), m_d->cache);
@@ -571,7 +586,7 @@ void KisAsyncColorSamplerHelper::paintCircleCanvasPreview(QPainter &gc, const QR
 
     // Copy a piece of canvas image with size = (previewDocRect size) / (zoom preview scale)
     QImage canvasPreview = m_d->canvas->image()->convertToQImage(canvasSampleRectF.toRect(), nullptr);
-    gc.setCompositionMode(QPainter::CompositionMode_DestinationOver);
+    gc.setCompositionMode(QPainter::CompositionMode_SourceOver);
 
     gc.setClipPath(clip);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.