mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-07 10:21:30 +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_oldBounds.offset(-m_newOrigin);
|
||||||
m_newBounds.offset(-m_oldOrigin);
|
m_newBounds.offset(-m_oldOrigin);
|
||||||
|
|
||||||
|
ASSERT(m_newBounds != m_oldBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropCel::onExecute()
|
void CropCel::onExecute()
|
||||||
|
@ -35,10 +35,11 @@ void PatchCel::onExecute()
|
|||||||
{
|
{
|
||||||
Cel* cel = this->cel();
|
Cel* cel = this->cel();
|
||||||
|
|
||||||
executeAndAdd(
|
const gfx::Rect newBounds =
|
||||||
new CropCel(cel,
|
cel->bounds() | gfx::Rect(m_region.bounds()).offset(m_pos);
|
||||||
cel->bounds() |
|
if (cel->bounds() != newBounds) {
|
||||||
gfx::Rect(m_region.bounds()).offset(m_pos)));
|
executeAndAdd(new CropCel(cel, newBounds));
|
||||||
|
}
|
||||||
|
|
||||||
executeAndAdd(
|
executeAndAdd(
|
||||||
new CopyRegion(cel->image(),
|
new CopyRegion(cel->image(),
|
||||||
@ -46,8 +47,7 @@ void PatchCel::onExecute()
|
|||||||
m_region,
|
m_region,
|
||||||
m_pos - cel->position()));
|
m_pos - cel->position()));
|
||||||
|
|
||||||
executeAndAdd(
|
executeAndAdd(new TrimCel(cel));
|
||||||
new TrimCel(cel));
|
|
||||||
|
|
||||||
m_patch = nullptr;
|
m_patch = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ TrimCel::TrimCel(Cel* cel)
|
|||||||
if (algorithm::shrink_bounds(cel->image(), newBounds,
|
if (algorithm::shrink_bounds(cel->image(), newBounds,
|
||||||
cel->image()->maskColor())) {
|
cel->image()->maskColor())) {
|
||||||
newBounds.offset(cel->position());
|
newBounds.offset(cel->position());
|
||||||
add(new cmd::CropCel(cel, newBounds));
|
if (cel->bounds() != newBounds) {
|
||||||
|
add(new cmd::CropCel(cel, newBounds));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Delete the given "cel" and all its links.
|
// Delete the given "cel" and all its links.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user