Commit 6cbc829e authored by Casper Boemann's avatar Casper Boemann

added nConseqPixels() and += to the rectIterator


svn path=/trunk/koffice/; revision=444318
parent 0d1a09c5
......@@ -52,6 +52,13 @@ public:
/// Returns a pointer to the pixel data as it was at the moment of the last memento creation.
inline const Q_UINT8 * oldRawData() const { return ACTUAL_RECTITERATOR::oldRawData();};
/// Returns the number of consequtive pixels that we point at
/// This is useful for optimizing
inline Q_INT32 nConseqPixels() const { return ACTUAL_RECTITERATOR::nConseqPixels(); };
/// Advances a number of pixels until it reaches the end of the rect
inline KisRectIterator & operator+=(int n) { ACTUAL_RECTITERATOR::operator+=(n); return *this; };
/// Advances one pixel going to the beginning of the next line when it reaches the end of a line
inline KisRectIterator & operator++() { ACTUAL_RECTITERATOR::operator++(); return *this; };
......
......@@ -80,6 +80,11 @@ public:
~KisTiledRectIterator();
public:
Q_INT32 nConseqPixels() const;
/// Advances a number of pixels until it reaches the end of the rect
KisTiledRectIterator & operator+=(int n);
/// Advances one pixel. Going to the beginning of the next line when it reaches the end of a line
KisTiledRectIterator & operator++();
......
......@@ -120,6 +120,48 @@ KisTiledRectIterator::~KisTiledRectIterator( )
{
}
Q_INT32 KisTiledRectIterator::nConseqPixels() const
{
if(m_leftInTile || (m_rightInTile != KisTile::WIDTH - 1))
return m_rightInTile - m_xInTile + 1;
else
return KisTile::WIDTH * (m_bottomInTile - m_yInTile + 1) - m_xInTile;
}
KisTiledRectIterator & KisTiledRectIterator::operator+=(int n)
{
int remainInTile;
remainInTile= (m_bottomInTile - m_yInTile) * (m_rightInTile - m_leftInTile + 1);
remainInTile += m_rightInTile - m_xInTile + 1;
// This while loop may not bet the fastest, but usually it's not entered more than once.
while(n >= remainInTile)
{
n -= remainInTile;
nextTile();
if(m_beyondEnd)
return *this;
m_yInTile = m_topInTile;
m_xInTile = m_leftInTile;
}
int lWidth = m_rightInTile - m_leftInTile + 1;
while(n >= lWidth)
{
n -= lWidth;
m_yInTile++;
}
m_xInTile += n;
m_x = m_col * KisTile::WIDTH + m_xInTile;
m_y = m_row * KisTile::HEIGHT + m_yInTile;
fetchTileData(m_col, m_row);
m_offset = m_pixelSize * (m_yInTile * KisTile::WIDTH + m_xInTile);
return *this;
}
KisTiledRectIterator & KisTiledRectIterator::operator ++ ()
{
// advance through rect completing each tile before moving on
......
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