~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/image/tiles3/kis_tiledvlineiterator.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
KisTiledVLineIterator::KisTiledVLineIterator(KisTiledDataManager *dataManager,
25
25
        qint32 x,  qint32 y,
26
26
        qint32 h, bool writable) :
27
 
        KisTiledIterator(dataManager)
 
27
        KisTiledIterator(dataManager), m_tilesCacheSize(0)
28
28
{
29
29
    m_lineStride = m_pixelSize * KisTileData::WIDTH;
30
30
    m_writable = writable;
48
48
    m_xInTile = calcXInTile(m_x, m_col);
49
49
 
50
50
    qint32 topInTopmostTile = calcTopInTile(m_topRow);
 
51
 
 
52
    m_tilesCacheSize = m_bottomRow - m_topRow + 1;
 
53
 
 
54
    m_tilesCache.resize(m_tilesCacheSize);
 
55
 
 
56
    // let's prealocate first row
 
57
    for (quint32 i = 0; i < m_tilesCacheSize; i++){
 
58
        m_tilesCache[i] = fetchTileDataForCache( m_col, m_topRow + i);
 
59
    }
 
60
 
51
61
    switchToTile(m_topRow, topInTopmostTile);
52
62
}
53
63
 
89
99
 
90
100
KisTiledVLineIterator::~KisTiledVLineIterator()
91
101
{
 
102
    for (uint i = 0; i < m_tilesCacheSize; i++) {
 
103
        unlockTile(m_tilesCache[i].tile);
 
104
        unlockTile(m_tilesCache[i].oldtile);
 
105
    }
92
106
}
93
107
 
94
108
void KisTiledVLineIterator::switchToTile(qint32 row, qint32 yInTile)
136
150
    } else {
137
151
        m_col++;
138
152
        m_xInTile = 0;
 
153
        preallocateTiles(m_col);
139
154
    }
140
155
 
141
156
    switchToTile(m_topRow, topInTopmostTile);
143
158
    m_isDoneFlag = false;
144
159
}
145
160
 
146
 
/*
147
 
  KisTiledVLineIterator & KisTiledVLineIterator::operator -- ()
148
 
  {
149
 
  return *this;
150
 
  }
151
 
*/
 
161
void KisTiledVLineIterator::fetchTileData(qint32 col, qint32 row){
 
162
 
 
163
    Q_UNUSED(col);
 
164
    // check if we have the cached column and row
 
165
    int index = row - m_topRow;
 
166
 
 
167
    // setup correct data
 
168
    m_data = m_tilesCache[index].data;
 
169
    m_oldData = m_tilesCache[index].oldData;
 
170
}
 
171
 
 
172
KisTiledVLineIterator::KisTileInfo KisTiledVLineIterator::fetchTileDataForCache(qint32 col, qint32 row)
 
173
{
 
174
    KisTileInfo kti;
 
175
    kti.tile = m_dataManager->getTile(col, row, m_writable);
 
176
    lockTile(kti.tile);
 
177
    kti.data = kti.tile->data();
 
178
 
 
179
    // set old data
 
180
    kti.oldtile = m_dataManager->getOldTile(col, row);
 
181
    lockOldTile(kti.oldtile);
 
182
    kti.oldData = kti.oldtile->data();
 
183
    return kti;
 
184
}
 
185
 
 
186
void KisTiledVLineIterator::preallocateTiles(qint32 col)
 
187
{
 
188
    for (uint i = 0; i < m_tilesCacheSize; i++){
 
189
        unlockTile(m_tilesCache[i].tile);
 
190
        unlockTile(m_tilesCache[i].oldtile);
 
191
        m_tilesCache[i] = fetchTileDataForCache(col , m_topRow + i);
 
192
    }
 
193
}