Fix spray and jumble tools (fix #1130)

This commit is contained in:
David Capello 2016-05-11 13:14:52 -03:00
parent 4f97970b98
commit 94e56ad97a
3 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -38,7 +38,7 @@ namespace app {
// Like accumulate, but the destination is copied to the source
// on each ToolLoop step, so the tool overlaps its own effect.
// Used by blur, jumble, or spray.
// Used by jumble and spray.
Overlap,
};

View File

@ -73,6 +73,7 @@ ExpandCelCanvas::ExpandCelCanvas(
, m_closed(false)
, m_committed(false)
, m_transaction(transaction)
, m_canCompareSrcVsDst((m_flags & NeedsSource) == NeedsSource)
{
ASSERT(!singleton);
singleton = this;
@ -184,7 +185,7 @@ void ExpandCelCanvas::commit()
gfx::Region* regionToPatch = &m_validDstRegion;
gfx::Region reduced;
if ((m_flags & NeedsSource) == NeedsSource) {
if (m_canCompareSrcVsDst) {
ASSERT(gfx::Region().createSubtraction(m_validDstRegion, m_validSrcRegion).isEmpty());
for (gfx::Rect rc : m_validDstRegion) {
@ -193,6 +194,7 @@ void ExpandCelCanvas::commit()
reduced |= gfx::Region(rc);
}
}
regionToPatch = &reduced;
}
@ -352,6 +354,11 @@ void ExpandCelCanvas::copyValidDestToSourceCanvas(const gfx::Region& rgn)
for (const auto& rc : rgn2)
m_srcImage->copy(m_dstImage.get(),
gfx::Clip(rc.x, rc.y, rc.x, rc.y, rc.w, rc.h));
// We cannot compare src vs dst in this case (e.g. on tools like
// spray and jumble that updated the source image form the modified
// destination).
m_canCompareSrcVsDst = false;
}
gfx::Rect ExpandCelCanvas::getTrimDstImageBounds() const

View File

@ -91,6 +91,11 @@ namespace app {
Transaction& m_transaction;
gfx::Region m_validSrcRegion;
gfx::Region m_validDstRegion;
// True if we can compare src image with dst image to patch the
// cel. This is false when dst is copied to the src, so we cannot
// reduce the patched region because both images will be the same.
bool m_canCompareSrcVsDst;
};
} // namespace app