[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [krita/kazakov/multithreaded-brushes] /: Ensure all the dabs are generated before issuing the very l
From:       Dmitry Kazakov <null () kde ! org>
Date:       2017-09-20 19:37:47
Message-ID: E1dukod-0008Kc-He () code ! kde ! org
[Download RAW message or body]

Git commit 4f1c090ecefbcec05323cfa8a3fae92c95455c22 by Dmitry Kazakov.
Committed on 20/09/2017 at 19:37.
Pushed by dkazakov into branch 'kazakov/multithreaded-brushes'.

Ensure all the dabs are generated before issuing the very last update

This patch fixes inconsistency between dab rendering in Instant Preview
and normal modes (the length of lines was just random, because the tail
was chopped off).

M  +2    -1    libs/image/brushengine/kis_paintop.cc
M  +1    -1    libs/image/brushengine/kis_paintop.h
M  +3    -3    libs/ui/tool/strokes/freehand_stroke.cpp
M  +1    -1    libs/ui/tool/strokes/freehand_stroke.h
M  +5    -1    plugins/paintops/defaultpaintops/brush/kis_brushop.cpp
M  +1    -1    plugins/paintops/defaultpaintops/brush/kis_brushop.h

https://commits.kde.org/krita/4f1c090ecefbcec05323cfa8a3fae92c95455c22

diff --git a/libs/image/brushengine/kis_paintop.cc \
b/libs/image/brushengine/kis_paintop.cc index cb8976a6de6..a99772e2e52 100644
--- a/libs/image/brushengine/kis_paintop.cc
+++ b/libs/image/brushengine/kis_paintop.cc
@@ -103,8 +103,9 @@ void KisPaintOp::splitCoordinate(qreal coordinate, qint32 *whole, \
                qreal *fractio
     *fraction = f;
 }
 
-int KisPaintOp::doAsyncronousUpdate()
+int KisPaintOp::doAsyncronousUpdate(bool forceLastUpdate)
 {
+    Q_UNUSED(forceLastUpdate);
     return 40;
 }
 
diff --git a/libs/image/brushengine/kis_paintop.h \
b/libs/image/brushengine/kis_paintop.h index 6e7245042fe..839010bce00 100644
--- a/libs/image/brushengine/kis_paintop.h
+++ b/libs/image/brushengine/kis_paintop.h
@@ -117,7 +117,7 @@ public:
      *
      * @return the desired FPS rate (period of updates)
      */
-    virtual int doAsyncronousUpdate();
+    virtual int doAsyncronousUpdate(bool forceLastUpdate);
 
 protected:
     friend class KisPaintInformation;
diff --git a/libs/ui/tool/strokes/freehand_stroke.cpp \
b/libs/ui/tool/strokes/freehand_stroke.cpp index a1cc9534d5d..70ec54d916c 100644
--- a/libs/ui/tool/strokes/freehand_stroke.cpp
+++ b/libs/ui/tool/strokes/freehand_stroke.cpp
@@ -174,7 +174,7 @@ void FreehandStrokeStrategy::finishStrokeCallback()
     KisPainterBasedStrokeStrategy::finishStrokeCallback();
 }
 
-void FreehandStrokeStrategy::tryDoUpdate(bool force)
+void FreehandStrokeStrategy::tryDoUpdate(bool forceEnd)
 {
     // We do not distinguish between updates for each painter info. Just
     // update all of them at once!
@@ -182,10 +182,10 @@ void FreehandStrokeStrategy::tryDoUpdate(bool force)
     Q_FOREACH (PainterInfo *info, painterInfos()) {
         KisPaintOp *paintop = info->painter->paintOp();
         if (m_d->needsAsynchronousUpdates && paintop &&
-            (force || m_d->timeSinceLastUpdate.elapsed() > \
m_d->currentUpdatePeriod)) { +            (forceEnd || \
m_d->timeSinceLastUpdate.elapsed() > m_d->currentUpdatePeriod)) {  
             m_d->timeSinceLastUpdate.restart();
-            m_d->currentUpdatePeriod = paintop->doAsyncronousUpdate();
+            m_d->currentUpdatePeriod = paintop->doAsyncronousUpdate(forceEnd);
         }
 
         QVector<QRect> dirtyRects = info->painter->takeDirtyRegion();
diff --git a/libs/ui/tool/strokes/freehand_stroke.h \
b/libs/ui/tool/strokes/freehand_stroke.h index 7e95327b165..bcac1336f72 100644
--- a/libs/ui/tool/strokes/freehand_stroke.h
+++ b/libs/ui/tool/strokes/freehand_stroke.h
@@ -230,7 +230,7 @@ protected:
 private:
     void init(bool needsIndirectPainting, const QString \
&indirectPaintingCompositeOp);  
-    void tryDoUpdate(bool force = false);
+    void tryDoUpdate(bool forceEnd = false);
 
 private:
     struct Private;
diff --git a/plugins/paintops/defaultpaintops/brush/kis_brushop.cpp \
b/plugins/paintops/defaultpaintops/brush/kis_brushop.cpp index \
                134c4bab5e3..6b0848688ec 100644
--- a/plugins/paintops/defaultpaintops/brush/kis_brushop.cpp
+++ b/plugins/paintops/defaultpaintops/brush/kis_brushop.cpp
@@ -178,8 +178,12 @@ KisSpacingInformation KisBrushOp::paintAt(const \
                KisPaintInformation& info)
     return effectiveSpacing(scale, rotation, &m_airbrushOption, &m_spacingOption, \
info);  }
 
-int KisBrushOp::doAsyncronousUpdate()
+int KisBrushOp::doAsyncronousUpdate(bool forceLastUpdate)
 {
+    if (forceLastUpdate) {
+        m_dabExecutor->waitForDone();
+    }
+
     if (!m_dabExecutor->hasPreparedDabs()) return m_currentUpdatePeriod;
 
     const int numThreads = 8;
diff --git a/plugins/paintops/defaultpaintops/brush/kis_brushop.h \
b/plugins/paintops/defaultpaintops/brush/kis_brushop.h index f860d425fd0..eb55706850a \
                100644
--- a/plugins/paintops/defaultpaintops/brush/kis_brushop.h
+++ b/plugins/paintops/defaultpaintops/brush/kis_brushop.h
@@ -55,7 +55,7 @@ public:
 
     void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, \
KisDistanceInformation *currentDistance) override;  
-    int doAsyncronousUpdate() override;
+    int doAsyncronousUpdate(bool forceLastUpdate) override;
 
 protected:
     KisSpacingInformation paintAt(const KisPaintInformation& info) override;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic