From f9a9e1a0bc2c1e47b7436b150799bd6d10f78d9c Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Wed, 10 Jun 2020 16:35:13 -0300 Subject: [PATCH] Intersect selection too slow (fix #2393) Before this fix, the Intersect selection context option were much slower than Add or Subtract. To reproduce the old 'bug': - Create a 1000x1000 sprite - Make a small rectangular selection on some place - Click on the empty area with the Magic Wand in Intersect context option. The same action in Add or Substract is much faster. --- src/app/tools/inks.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/tools/inks.h b/src/app/tools/inks.h index 7de8580f1..cd8a32733 100644 --- a/src/app/tools/inks.h +++ b/src/app/tools/inks.h @@ -460,6 +460,7 @@ public: void setFinalStep(ToolLoop* loop, bool state) override { m_modify_selection = state; + int modifiers = int(loop->getModifiers()); if (state) { m_maxBounds = loop->getMask()->bounds(); @@ -467,11 +468,16 @@ public: m_mask.copyFrom(loop->getMask()); m_mask.freeze(); m_mask.reserve(loop->sprite()->bounds()); + + if ((modifiers & int(ToolLoopModifiers::kIntersectSelection)) != 0) { + m_intersectMask.clear(); + m_intersectMask.reserve(loop->sprite()->bounds()); + } } else { - int modifiers = int(loop->getModifiers()); if ((modifiers & int(ToolLoopModifiers::kIntersectSelection)) != 0) { m_mask.intersect(m_intersectMask); + m_intersectMask.clear(); } // We can intersect the used bounds in inkHline() calls to