Commit b4b8166a authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Adjust signal compressor in shape layer when image size changes

BUG:403340
BUG:405698
parent 27678b4c
......@@ -126,6 +126,7 @@ KisShapeLayerCanvas::KisShapeLayerCanvas(KisShapeLayer *parent, KisImageWSP imag
: KisShapeLayerCanvasBase(parent, image)
, m_projection(0)
, m_parentLayer(parent)
, m_canvasUpdateCompressor(100, KisSignalCompressor::FIRST_INACTIVE)
, m_asyncUpdateSignalCompressor(100, KisSignalCompressor::FIRST_INACTIVE)
{
/**
......@@ -136,23 +137,8 @@ KisShapeLayerCanvas::KisShapeLayerCanvas(KisShapeLayer *parent, KisImageWSP imag
m_shapeManager->selection()->setActiveLayer(parent);
connect(&m_asyncUpdateSignalCompressor, SIGNAL(timeout()), SLOT(slotStartAsyncRepaint()));
if (image->width() * image->height() < 2480 * 3508) { // A4 300 DPI
m_canvasUpdateCompressor = new KisSignalCompressor(10, KisSignalCompressor::FIRST_INACTIVE, this);
}
else if (image->width() * image->height() < 4961 * 7061) { // A4 600 DPI
m_canvasUpdateCompressor = new KisSignalCompressor(100, KisSignalCompressor::FIRST_INACTIVE, this);
}
else { // Really big
m_canvasUpdateCompressor = new KisSignalCompressor(500, KisSignalCompressor::FIRST_INACTIVE, this);
}
qDebug() << m_canvasUpdateCompressor->
connect(this, SIGNAL(forwardRepaint()), m_canvasUpdateCompressor, SLOT(start()));
connect(m_canvasUpdateCompressor, SIGNAL(timeout()), this, SLOT(repaint()));
connect(this, SIGNAL(forwardRepaint()), &m_canvasUpdateCompressor, SLOT(start()));
connect(&m_canvasUpdateCompressor, SIGNAL(timeout()), this, SLOT(repaint()));
setImage(image);
}
......@@ -175,6 +161,8 @@ void KisShapeLayerCanvas::setImage(KisImageWSP image)
connect(m_image, SIGNAL(sigSizeChanged(QPointF,QPointF)), SLOT(slotImageSizeChanged()));
m_cachedImageRect = m_image->bounds();
}
updateUpdateCompressorDelay();
}
......@@ -284,6 +272,7 @@ void KisShapeLayerCanvas::slotImageSizeChanged()
updateCanvas(dirtyRects);
m_cachedImageRect = m_image->bounds();
updateUpdateCompressorDelay();
}
void KisShapeLayerCanvas::repaint()
......@@ -364,3 +353,14 @@ void KisShapeLayerCanvas::rerenderAfterBeingInvisible()
m_hasChangedWhileBeingInvisible = false;
resetCache();
}
void KisShapeLayerCanvas::updateUpdateCompressorDelay()
{
if (m_cachedImageRect.width() * m_cachedImageRect.height() < 2480 * 3508) { // A4 300 DPI
m_canvasUpdateCompressor.setDelay(25);
} else if (m_cachedImageRect.width() * m_cachedImageRect.height() < 4961 * 7061) { // A4 600 DPI
m_canvasUpdateCompressor.setDelay(100);
} else { // Really big
m_canvasUpdateCompressor.setDelay(500);
}
}
......@@ -111,10 +111,13 @@ private Q_SLOTS:
Q_SIGNALS:
void forwardRepaint();
private:
void updateUpdateCompressorDelay();
private:
KisPaintDeviceSP m_projection;
KisShapeLayer *m_parentLayer {0};
KisSignalCompressor *m_canvasUpdateCompressor {0};
KisSignalCompressor m_canvasUpdateCompressor;
KisThreadSafeSignalCompressor m_asyncUpdateSignalCompressor;
volatile bool m_hasUpdateInCompressor = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment