Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Change paintedCircleCanvasPreview return logic to be more logical
Dat Le93ddac07fa5e
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cppindex 2248a24ac6..8dd11defc2 100644--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp@@ -674,9 +674,11 @@ void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,zoomDocRectF.setSize(zoomDocRectF.size() / m_d->circleZoomPreviewScale);zoomDocRectF.moveCenter(m_d->sampleDocPoint);- bool paintLater = paintCircleCanvasPreview(cachePainter, cacheRect, zoomDocRectF, tf.map(m_d->cacheCircleInnerClip));+ bool isPainted = paintCircleCanvasPreview(cachePainter, cacheRect, zoomDocRectF, tf.map(m_d->cacheCircleInnerClip));- if (!paintLater) {+ // This is only false for the very first frame, when canvas preview is not yet available, leave the center hollow for better visual+ // the gray flickering otherwise would be an eyesore+ if (isPainted) {paintCircleReferenceImagePreview(cachePainter, cacheRect, zoomDocRectF, tf.map(m_d->cacheCircleInnerClip));// Draw crosshair if preview is offseted@@ -754,6 +756,7 @@ QImage KisAsyncColorSamplerHelper::cacheCanvasImage(QRect &canvasPixelRect) {if (!m_d->oldCanvasPixelRect.isNull()) canvasPixelRect = m_d->oldCanvasPixelRect;return m_d->cacheCanvasPreviewImage;}+canvasPixelRect.translate(-m_d->cacheCanvasPreviewRect.topLeft());m_d->oldCanvasPixelRect = canvasPixelRect;@@ -774,10 +777,9 @@ bool KisAsyncColorSamplerHelper::paintCircleCanvasPreview(QPainter &gc, const QRcanvasPixelRect.moveCenter(image->documentToImagePixelFloored(zoomDocRectF.center()));QImage cachedImage = cacheCanvasImage(canvasPixelRect);- // A null QImage and a null canvasPixelRect => No need to paint canvas- // A null QImage and a not null canvasPixelRect => Cache miss, skip painting and paint later when canvas image is ready- bool paintLater = cachedImage.isNull() && !canvasPixelRect.isNull();- if (cachedImage.isNull()) return paintLater;+ // If cachedImage and canvasPixelRect is null, painting is not needed+ // If cachedImage is null and canvasPixelRect is not null, painting was deferred+ if (cachedImage.isNull()) return canvasPixelRect.isNull();gc.save();gc.setCompositionMode(QPainter::CompositionMode_SourceOver);@@ -791,7 +793,7 @@ bool KisAsyncColorSamplerHelper::paintCircleCanvasPreview(QPainter &gc, const QRgc.restore();- return false;+ return true;}// Preview won't respect opacity because the color sampled doesn't respect opacity eitherdiff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.h b/libs/ui/tool/KisAsyncColorSamplerHelper.hindex 074489ba64..528d779756 100644--- a/libs/ui/tool/KisAsyncColorSamplerHelper.h+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.h@@ -83,8 +83,7 @@ private:void paintCircle(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor, const QColor &baseColor);void paintCircleCrosshair(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor);- // Return true if cache miss, will repaint later when canvas image is fetched- // Return false if cache hit, and painted+ // Returns true if painted or not needed, returns false if painting was deferredbool paintCircleCanvasPreview(QPainter &gc, const QRectF &viewRectF, const QRectF &zoomDocRectF, const QPainterPath &clip);void paintCircleReferenceImagePreview(QPainter &gc, const QRectF &viewRectF, const QRectF &zoomDocRectF, const QPainterPath &clip);