Commit 94b3f140 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix the bug in HLineIterator, when nConseqPixels return wrong values.

Before the patch using nConseqPixels could result in iterating
past the rightmost border of the iteration rect.
parent 633f7b23
......@@ -94,7 +94,7 @@ bool KisHLineIterator2::nextPixel()
} else {
++m_x;
m_data += m_pixelSize;
if (m_data < m_dataRight)
if (m_x <= m_rightmostInTile)
m_oldData += m_pixelSize;
else {
// Switching to the beginning of the next tile
......@@ -128,7 +128,7 @@ void KisHLineIterator2::nextRow()
qint32 KisHLineIterator2::nConseqPixels() const
{
return (m_dataRight - m_data) / m_pixelSize;
return qMin(m_rightmostInTile, m_right) - m_x + 1;
}
......@@ -192,7 +192,7 @@ void KisHLineIterator2::switchToTile(qint32 xInTile)
int offset_row = m_pixelSize * (m_yInTile * KisTileData::WIDTH);
m_data += offset_row;
m_dataRight = m_data + m_tileWidth;
m_rightmostInTile = (m_leftCol + m_index + 1) * KisTileData::WIDTH - 1;
int offset_col = m_pixelSize * xInTile;
m_data += offset_col;
m_oldData += offset_row + offset_col;
......
......@@ -60,7 +60,6 @@ private:
quint32 m_index; // current col in tilemgr
quint32 m_tileWidth;
quint8 *m_data;
quint8 *m_dataRight;
quint8 *m_oldData;
bool m_havePixels;
......@@ -70,6 +69,8 @@ private:
qint32 m_leftCol;
qint32 m_rightCol;
qint32 m_rightmostInTile; // limited by the current tile border only
qint32 m_leftInLeftmostTile;
qint32 m_yInTile;
......
Markdown is supported
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