From a94fbe7fd81f788a9f15603cbd6246f748072f7a Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 6 Jul 2015 13:38:34 -0300 Subject: [PATCH] Fix Eraser brush preview problems when the brush size is changed with the slider --- src/app/ui/editor/brush_preview.cpp | 15 ++++++++++----- src/app/ui/editor/brush_preview.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp index a7fb1c317..d19b39c2e 100644 --- a/src/app/ui/editor/brush_preview.cpp +++ b/src/app/ui/editor/brush_preview.cpp @@ -41,6 +41,7 @@ using namespace doc; std::vector BrushPreview::m_savedPixels; int BrushPreview::m_savedPixelsIterator; +int BrushPreview::m_savedPixelsLimit; BrushPreview::BrushPreview(Editor* editor) : m_editor(editor) @@ -328,6 +329,8 @@ void BrushPreview::forEachBrushPixel( // little dot inside the active pixel) if (m_editor->zoom().scale() >= 4.0) (this->*pixelDelegate)(g, screenPos, color); + + m_savedPixelsLimit = m_savedPixelsIterator; } void BrushPreview::traceCrossPixels( @@ -462,12 +465,14 @@ void BrushPreview::drawPixelDelegate(ui::Graphics* gfx, const gfx::Point& pt, gf void BrushPreview::clearPixelDelegate(ui::Graphics* g, const gfx::Point& pt, gfx::Color color) { if (m_savedPixelsIterator < (int)m_savedPixels.size()) { - if (m_clippingRegion.contains(pt)) - g->putPixel(m_savedPixels[m_savedPixelsIterator++], pt.x, pt.y); - else if (!m_oldClippingRegion.isEmpty() && - m_oldClippingRegion.contains(pt)) - m_savedPixelsIterator++; + if (m_oldClippingRegion.contains(pt)) { + if (m_clippingRegion.contains(pt)) + g->putPixel(m_savedPixels[m_savedPixelsIterator], pt.x, pt.y); + ++m_savedPixelsIterator; + } } + + ASSERT(m_savedPixelsIterator <= m_savedPixelsLimit); } } // namespace app diff --git a/src/app/ui/editor/brush_preview.h b/src/app/ui/editor/brush_preview.h index ee33d8545..8ed1d7f7f 100644 --- a/src/app/ui/editor/brush_preview.h +++ b/src/app/ui/editor/brush_preview.h @@ -96,6 +96,7 @@ namespace app { static std::vector m_savedPixels; static int m_savedPixelsIterator; + static int m_savedPixelsLimit; gfx::Region m_clippingRegion; gfx::Region m_oldClippingRegion;