# HG changeset patch # User Chris Cannam # Date 1426088120 0 # Node ID f6d9f28f37cb2fdd594e3c50358d5920b69f0f72 # Parent 59e51842cf397bf59344bd42aafff41d7d2c2890 Experiment with querying paint rect separately from view rect diff -r 59e51842cf39 -r f6d9f28f37cb layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Wed Mar 11 13:54:01 2015 +0000 +++ b/layer/WaveformLayer.cpp Wed Mar 11 15:35:20 2015 +0000 @@ -494,8 +494,8 @@ mergingChannels, mixingChannels); if (channels == 0) return; - int w = v->width(); - int h = v->height(); + int w = v->getPaintWidth(); + int h = v->getPaintHeight(); bool ready = m_model->isReady(); QPainter *paint; @@ -559,7 +559,7 @@ y1 = rect.bottom(); if (x0 > 0) --x0; - if (x1 < v->width()) ++x1; + if (x1 < w) ++x1; // Our zoom level may differ from that at which the underlying // model has its blocks. @@ -939,7 +939,7 @@ if (m_aggressive) { - if (ready && rect == v->rect()) { + if (ready && rect == v->getPaintRect()) { m_cacheValid = true; m_cacheZoomLevel = zoomLevel; } diff -r 59e51842cf39 -r f6d9f28f37cb view/View.cpp --- a/view/View.cpp Wed Mar 11 13:54:01 2015 +0000 +++ b/view/View.cpp Wed Mar 11 15:35:20 2015 +0000 @@ -58,6 +58,7 @@ m_followPlayIsDetached(false), m_playPointerFrame(0), m_showProgress(showProgress), + m_paintScale(1), m_cache(0), m_cacheCentreFrame(0), m_cacheZoomLevel(1024), @@ -1658,6 +1659,14 @@ paint.setFont(font); } +QRect +View::getPaintRect() const +{ + QRect r(rect()); + return QRect(r.x() * m_paintScale, r.y() * m_paintScale, + r.width() * m_paintScale, r.height() * m_paintScale); +} + void View::paintEvent(QPaintEvent *e) { @@ -1838,9 +1847,11 @@ if (repaintCache) { paint.begin(m_cache); rectToPaint = scaledCacheRect; + m_paintScale = dpratio; } else { paint.begin(this); rectToPaint = cacheRect; + m_paintScale = 1; } setPaintFont(paint); diff -r 59e51842cf39 -r f6d9f28f37cb view/View.h --- a/view/View.h Wed Mar 11 13:54:01 2015 +0000 +++ b/view/View.h Wed Mar 11 15:35:20 2015 +0000 @@ -315,6 +315,18 @@ sv_frame_t getModelsStartFrame() const; sv_frame_t getModelsEndFrame() const; + /** + * To be called from a layer, to obtain the extent of the surface + * that the layer is currently painting to. This may be the extent + * of the view (if 1x display scaling is in effect) or of a larger + * cached pixmap (if greater display scaling is in effect). + */ + QRect getPaintRect() const; + + QSize getPaintSize() const { return getPaintRect().size(); } + int getPaintWidth() const { return getPaintRect().width(); } + int getPaintHeight() const { return getPaintRect().height(); } + typedef std::set ModelSet; ModelSet getModels(); @@ -415,6 +427,7 @@ sv_frame_t m_playPointerFrame; bool m_lightBackground; bool m_showProgress; + int m_paintScale; QPixmap *m_cache; sv_frame_t m_cacheCentreFrame;