Fix filters preview for tiled mode

This commit is contained in:
David Capello 2017-11-10 16:29:47 -03:00
parent 29c2c0cd90
commit b856c71f9d
3 changed files with 37 additions and 2 deletions

View File

@ -126,8 +126,9 @@ void FilterManagerImpl::beginForPreview()
m_row = m_nextRowToFlush = 0;
m_mask = m_previewMask;
{
Editor* editor = current_editor;
Editor* editor = current_editor;
// If we have a tiled mode enabled, we'll apply the filter to the whole areaes
if (editor->docPref().tiled.mode() == filters::TiledMode::NONE) {
Sprite* sprite = m_site.sprite();
gfx::Rect vp = View::getView(editor)->viewportBounds();
vp = editor->screenToEditor(vp);
@ -314,6 +315,8 @@ void FilterManagerImpl::flush()
editor->projection().removeY(h+2))));
gfx::Region reg1(rect);
editor->expandRegionByTiledMode(reg1, true);
gfx::Region reg2;
editor->getDrawableRegion(reg2, Widget::kCutTopWindows);
reg1.createIntersection(reg1, reg2);

View File

@ -2388,6 +2388,36 @@ gfx::Point Editor::mainTilePosition() const
return pt;
}
void Editor::expandRegionByTiledMode(gfx::Region& rgn,
const bool withProj) const
{
gfx::Region tile = rgn;
const bool xTiled = (int(m_docPref.tiled.mode()) & int(filters::TiledMode::X_AXIS));
const bool yTiled = (int(m_docPref.tiled.mode()) & int(filters::TiledMode::Y_AXIS));
int w = m_sprite->width();
int h = m_sprite->height();
if (withProj) {
w = m_proj.applyX(w);
h = m_proj.applyY(h);
}
if (xTiled) {
tile.offset(w, 0); rgn |= tile;
tile.offset(w, 0); rgn |= tile;
tile.offset(-2*w, 0);
}
if (yTiled) {
tile.offset(0, h); rgn |= tile;
tile.offset(0, h); rgn |= tile;
tile.offset(0, -2*h);
}
if (xTiled && yTiled) {
tile.offset(w, h); rgn |= tile;
tile.offset(w, 0); rgn |= tile;
tile.offset(-w, h); rgn |= tile;
tile.offset(w, 0); rgn |= tile;
}
}
bool Editor::isMovingPixels() const
{
return (dynamic_cast<MovingPixelsState*>(m_state.get()) != nullptr);

View File

@ -179,6 +179,8 @@ namespace app {
gfx::Size canvasSize() const;
gfx::Point mainTilePosition() const;
void expandRegionByTiledMode(gfx::Region& rgn,
const bool withProj) const;
// Changes the scroll to see the given point as the center of the editor.
void centerInSpritePoint(const gfx::Point& spritePos);