mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Don't generate cmd::CropCel() if it isn't necessary
This commit is contained in:
parent
6f72666330
commit
e8a057a334
@ -27,6 +27,8 @@ CropCel::CropCel(Cel* cel, const gfx::Rect& newBounds)
|
||||
{
|
||||
m_oldBounds.offset(-m_newOrigin);
|
||||
m_newBounds.offset(-m_oldOrigin);
|
||||
|
||||
ASSERT(m_newBounds != m_oldBounds);
|
||||
}
|
||||
|
||||
void CropCel::onExecute()
|
||||
|
@ -35,10 +35,11 @@ void PatchCel::onExecute()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
|
||||
executeAndAdd(
|
||||
new CropCel(cel,
|
||||
cel->bounds() |
|
||||
gfx::Rect(m_region.bounds()).offset(m_pos)));
|
||||
const gfx::Rect newBounds =
|
||||
cel->bounds() | gfx::Rect(m_region.bounds()).offset(m_pos);
|
||||
if (cel->bounds() != newBounds) {
|
||||
executeAndAdd(new CropCel(cel, newBounds));
|
||||
}
|
||||
|
||||
executeAndAdd(
|
||||
new CopyRegion(cel->image(),
|
||||
@ -46,8 +47,7 @@ void PatchCel::onExecute()
|
||||
m_region,
|
||||
m_pos - cel->position()));
|
||||
|
||||
executeAndAdd(
|
||||
new TrimCel(cel));
|
||||
executeAndAdd(new TrimCel(cel));
|
||||
|
||||
m_patch = nullptr;
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ TrimCel::TrimCel(Cel* cel)
|
||||
if (algorithm::shrink_bounds(cel->image(), newBounds,
|
||||
cel->image()->maskColor())) {
|
||||
newBounds.offset(cel->position());
|
||||
add(new cmd::CropCel(cel, newBounds));
|
||||
if (cel->bounds() != newBounds) {
|
||||
add(new cmd::CropCel(cel, newBounds));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Delete the given "cel" and all its links.
|
||||
|
Loading…
x
Reference in New Issue
Block a user