mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 03:40:57 +00:00
Fix spray and jumble tools (fix #1130)
This commit is contained in:
parent
4f97970b98
commit
94e56ad97a
@ -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,
|
||||
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user