Commit 63f62819e416da33062cd4397231e9fed88f6c1d

  • avatar
  • maemo <maemo @maemo-…ktop.(none)>
  • Thu Jan 14 16:19:45 CET 2010
tile cache threading fixes
  
138138 void invalidate(const IntRect&);
139139 void updateBuffer();
140140 void swapBuffer();
141 bool isReadyToPaint() const { return m_buffer; }
141142 void paint(QPainter* painter, const IntRect& rect);
142143
143144 const TileCache::TileCoordinate coordinate() const { return m_tileCoordinate; }
172172 , m_pixmapNeedsReset(false)
173173{
174174#if ENABLE(ENGINE_THREAD)
175 qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "CREATING tile " << QRectF(m_tileRect);
175 // qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "CREATING tile " << QRectF(m_tileRect);
176176#endif
177177}
178178
179179Tile::~Tile()
180180{
181181#if ENABLE(ENGINE_THREAD)
182 qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "DELETING tile " << QRectF(m_tileRect);
182 // qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "DELETING tile " << QRectF(m_tileRect);
183183#endif
184184 delete m_buffer;
185185 delete m_backBuffer;
204204 if (!m_backBuffer) {
205205 // Copy the current buffer if this is not a full tile update (or a new tile
206206 if (!m_buffer)
207 m_backBuffer = new QImage(m_cache->tileSize().width(), m_cache->tileSize().height(), QImage::Format_RGB32);
207 m_backBuffer = new QImage(m_cache->tileSize().width(), m_cache->tileSize().height(), QImage::Format_RGB16);
208208 else
209209 m_backBuffer = new QImage(m_buffer->copy());
210210 }
220220 }
221221
222222#if ENABLE(ENGINE_THREAD)
223 qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "BUFFERING tile " << QRectF(m_tileRect) << " dirty rects " << dirtyRects;
223 // qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "BUFFERING tile " << QRectF(m_tileRect) << " dirty rects " << dirtyRects;
224224#endif
225225
226226 // Paint to backbuffer, no locks held.
254254 if (!m_buffer)
255255 return;
256256
257 if (m_bufferPixmap.isNull() || m_pixmapNeedsReset)
258 m_bufferPixmap = QPixmap::fromImage(*m_buffer);
257 // if (m_bufferPixmap.isNull() || m_pixmapNeedsReset)
258 // m_bufferPixmap = QPixmap::fromImage(*m_buffer);
259259 m_pixmapNeedsReset = false;
260260
261261 FloatRect target = intersection(FloatRect(rect), m_tileRect);
268268 source.scale(scale.width(), scale.height());
269269
270270#if ENABLE(ENGINE_THREAD)
271 qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "painting tile " << QRectF(m_tileRect) << " source " << QRectF(source) << " target " << QRectF(target);
271 // qDebug() << (EngineThread::isCurrent() ? "EngineThread " : "MainThread ") << "painting tile " << QRectF(m_tileRect) << " source " << QRectF(source) << " target " << QRectF(target);
272272#endif
273 // painter->drawImage(target, *m_buffer, source);
274 painter->drawPixmap(target, m_bufferPixmap, source);
273 painter->drawImage(target, *m_buffer, source);
274 //painter->drawPixmap(target, m_bufferPixmap, source);
275275
276276}
277277
338338 for (unsigned n = 0; n < rectCount; ++n)
339339 paintedArea.append(qrects[n]);
340340
341 m_client->tileCachePaintEnd(paintedArea);
342#if ENABLE(ENGINE_THREAD)
343 EngineThread::unlock();
344#endif
345341 {
346342 // Swap the buffers atomically
347343#if ENABLE(ENGINE_THREAD)
346346 for (unsigned n = 0; n < size; ++n)
347347 m_dirtyTiles[n]->swapBuffer();
348348 }
349
350 m_client->tileCachePaintEnd(paintedArea);
351
352#if ENABLE(ENGINE_THREAD)
353 EngineThread::unlock();
354#endif
355
349356}
350357
351358void TileCache::paintCheckerPattern(QPainter* painter, const IntRect& rect, TileCoordinate coordinate)
398398 for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
399399 TileCoordinate currentCoordinate(xCoordinate, yCoordinate);
400400 RefPtr<Tile> currentTile = tile(currentCoordinate);
401 if (currentTile)
401 if (currentTile && currentTile->isReadyToPaint())
402402 currentTile->paint(painter, rect);
403403 else
404404 paintCheckerPattern(painter, rect, currentCoordinate);
418418 m_scale = scale;
419419
420420 if (!m_tileCreationTimer->isActive())
421 m_tileCreationTimer->startOneShot(0);
421 m_tileCreationTimer->startOneShot(.1);
422422}
423423
424424double TileCache::tileDistance(const IntRect& viewport, const TileCache::TileCoordinate& tileCoordinate)
496496
497497 // Keep creating tiles until the whole coverRect is covered.
498498 if (requiredTileCount)
499 m_tileCreationTimer->startOneShot(.3);
499 m_tileCreationTimer->startOneShot(.1);
500500}
501501
502502void TileCache::dropOverhangingTiles()