Fix tiled mode when moving pixels #5369
Conversation
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
|
|
||
| auto corners = transformation.transformedCorners(); | ||
| gfx::Rect bounds = corners.bounds(transformation.cornerThick()); | ||
| gfx::Rect unexpandedBounds = bounds; |
There was a problem hiding this comment.
warning: variable 'unexpandedBounds' of type 'gfx::Rect' (aka 'RectT') can be declared 'const' [misc-const-correctness]
| gfx::Rect unexpandedBounds = bounds; | |
| gfx::Rect const unexpandedBounds = bounds; |
|
|
||
| // Temporal image. Used for copying several times the pixels being transformed by the user | ||
| // when tile mode is active. | ||
| doc::ImageRef tmp; |
There was a problem hiding this comment.
warning: variable 'tmp' of type 'doc::ImageRef' (aka 'shared_ptr') can be declared 'const' [misc-const-correctness]
| doc::ImageRef tmp; | |
| doc::ImageRef const tmp; |
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
| if (int(m_mode) & int(filters::TiledMode::X_AXIS)) | ||
| rgn.offset(m_canvas->width() * (1 - (rgn.bounds().x / m_canvas->width())), 0); | ||
| if (int(m_mode) & int(filters::TiledMode::X_AXIS)) { | ||
| int w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; |
There was a problem hiding this comment.
warning: variable 'w' of type 'int' can be declared 'const' [misc-const-correctness]
| int w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; | |
| int const w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; |
| } | ||
|
|
||
| if (int(m_mode) & int(filters::TiledMode::Y_AXIS)) { | ||
| int h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; |
There was a problem hiding this comment.
warning: variable 'h' of type 'int' can be declared 'const' [misc-const-correctness]
| int h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; | |
| int const h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; |
| // When Y axis tiled mode is enable, the analog algorithm is used for the Y coordinates. | ||
| void wrapTransformation(Transformation* transformation) const | ||
| { | ||
| gfx::Rect bounds = transformation->transformedBounds(); |
There was a problem hiding this comment.
warning: variable 'bounds' of type 'gfx::Rect' (aka 'RectT') can be declared 'const' [misc-const-correctness]
| gfx::Rect bounds = transformation->transformedBounds(); | |
| gfx::Rect const bounds = transformation->transformedBounds(); |
| doc::ImageRef tmp; | ||
| Mask tmpMask; | ||
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); |
There was a problem hiding this comment.
warning: variable 'x' of type 'int' can be declared 'const' [misc-const-correctness]
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | |
| int const x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); |
| Mask tmpMask; | ||
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); |
There was a problem hiding this comment.
warning: variable 'y' of type 'int' can be declared 'const' [misc-const-correctness]
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | |
| int const y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); |
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | ||
| int w = dst->width() - 2 * x; |
There was a problem hiding this comment.
warning: variable 'w' of type 'int' can be declared 'const' [misc-const-correctness]
| int w = dst->width() - 2 * x; | |
| int const w = dst->width() - 2 * x; |
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | ||
| int w = dst->width() - 2 * x; | ||
| int h = dst->height() - 2 * y; |
There was a problem hiding this comment.
warning: variable 'h' of type 'int' can be declared 'const' [misc-const-correctness]
| int h = dst->height() - 2 * y; | |
| int const h = dst->height() - 2 * y; |
|
Works great! A minor observation: Perhaps it would be better to use the new Throughout testing, I discovered that the pivot point isn't positioned correctly in tiled mode, but that's a different issue (#2316); I'll look into a fix for this in another PR. |
|
It works great 👍 it would be nice to move the whole |
9df632b to
ea70862
Compare
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
| const render::Projection* proj) const | ||
| { | ||
| gfx::Region tile = rgn; | ||
| const bool xTiled = (int(m_mode) & int(filters::TiledMode::X_AXIS)); |
There was a problem hiding this comment.
warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
| const bool xTiled = (int(m_mode) & int(filters::TiledMode::X_AXIS)); | |
| const bool xTiled = (int(m_mode) & int(filters::TiledMode::X_AXIS)) != 0; |
| { | ||
| gfx::Region tile = rgn; | ||
| const bool xTiled = (int(m_mode) & int(filters::TiledMode::X_AXIS)); | ||
| const bool yTiled = (int(m_mode) & int(filters::TiledMode::Y_AXIS)); |
There was a problem hiding this comment.
warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
| const bool yTiled = (int(m_mode) & int(filters::TiledMode::Y_AXIS)); | |
| const bool yTiled = (int(m_mode) & int(filters::TiledMode::Y_AXIS)) != 0; |
| return; | ||
|
|
||
| if (int(m_mode) & int(filters::TiledMode::X_AXIS)) { | ||
| int w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; |
There was a problem hiding this comment.
warning: variable 'w' of type 'int' can be declared 'const' [misc-const-correctness]
| int w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; | |
| int const w = rgn.bounds().origin().x < 0 ? (rgn.bounds().w - m_canvas->width()) : 0; |
| } | ||
|
|
||
| if (int(m_mode) & int(filters::TiledMode::Y_AXIS)) { | ||
| int h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; |
There was a problem hiding this comment.
warning: variable 'h' of type 'int' can be declared 'const' [misc-const-correctness]
| int h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; | |
| int const h = rgn.bounds().origin().y < 0 ? (rgn.bounds().h - m_canvas->height()) : 0; |
| // including its pivot. | ||
| void TiledModeHelper::wrapTransformation(Transformation* transformation) const | ||
| { | ||
| gfx::Rect bounds = transformation->transformedBounds(); |
There was a problem hiding this comment.
warning: variable 'bounds' of type 'gfx::Rect' (aka 'RectT') can be declared 'const' [misc-const-correctness]
| gfx::Rect bounds = transformation->transformedBounds(); | |
| gfx::Rect const bounds = transformation->transformedBounds(); |
| doc::ImageRef tmp; | ||
| Mask tmpMask; | ||
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); |
There was a problem hiding this comment.
warning: variable 'x' of type 'int' can be declared 'const' [misc-const-correctness]
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | |
| int const x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); |
| Mask tmpMask; | ||
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); |
There was a problem hiding this comment.
warning: variable 'y' of type 'int' can be declared 'const' [misc-const-correctness]
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | |
| int const y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); |
| tmpMask.freeze(); | ||
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | ||
| int w = dst->width() - 2 * x; |
There was a problem hiding this comment.
warning: variable 'w' of type 'int' can be declared 'const' [misc-const-correctness]
| int w = dst->width() - 2 * x; | |
| int const w = dst->width() - 2 * x; |
| int x = (hasModeFlag(TiledMode::X_AXIS) ? m_canvas->width() : 0); | ||
| int y = (hasModeFlag(TiledMode::Y_AXIS) ? m_canvas->height() : 0); | ||
| int w = dst->width() - 2 * x; | ||
| int h = dst->height() - 2 * y; |
There was a problem hiding this comment.
warning: variable 'h' of type 'int' can be declared 'const' [misc-const-correctness]
| int h = dst->height() - 2 * y; | |
| int const h = dst->height() - 2 * y; |
|
LGTM! 👍 |
Fix #1457
This PR doesn't include changes to make the fix work with tilemaps. Should this be addressed? If so, IMO it would be better to do it in a separate issue.