comparison layer/WaveformLayer.cpp @ 214:8520b7918104

* Fix overzealous cacheing in waveform layer that was leading to inaccurate positioning of view rects & playback pointer on overview widget sometimes
author Chris Cannam
date Thu, 01 Mar 2007 17:12:50 +0000
parents 17f8d9cf60d7
children 34bbbcb3c01f
comparison
equal deleted inserted replaced
213:df791d8c8f58 214:8520b7918104
464 bool ready = m_model->isReady(); 464 bool ready = m_model->isReady();
465 QPainter *paint; 465 QPainter *paint;
466 466
467 if (m_aggressive) { 467 if (m_aggressive) {
468 468
469 #ifdef DEBUG_WAVEFORM_PAINT
470 std::cerr << "WaveformLayer::paint: aggressive is true" << std::endl;
471 #endif
472
469 if (m_cacheValid && (zoomLevel != m_cacheZoomLevel)) { 473 if (m_cacheValid && (zoomLevel != m_cacheZoomLevel)) {
470 m_cacheValid = false; 474 m_cacheValid = false;
475 }
476
477 if (!m_cache || m_cache->width() != w || m_cache->height() != h) {
478 #ifdef DEBUG_WAVEFORM_PAINT
479 if (m_cache) {
480 std::cerr << "WaveformLayer::paint: cache size " << m_cache->width() << "x" << m_cache->height() << " differs from view size " << w << "x" << h << ": regenerating aggressive cache" << std::endl;
481 }
482 #endif
483 delete m_cache;
484 m_cache = new QPixmap(w, h);
485 m_cacheValid = false;
471 } 486 }
472 487
473 if (m_cacheValid) { 488 if (m_cacheValid) {
474 viewPainter.drawPixmap(rect, *m_cache, rect); 489 viewPainter.drawPixmap(rect, *m_cache, rect);
475 return; 490 return;
476 }
477
478 if (!m_cache || m_cache->width() != w || m_cache->height() != h) {
479 delete m_cache;
480 m_cache = new QPixmap(w, h);
481 } 491 }
482 492
483 paint = new QPainter(m_cache); 493 paint = new QPainter(m_cache);
484 494
485 paint->setPen(Qt::NoPen); 495 paint->setPen(Qt::NoPen);