Mercurial > hg > svgui
comparison view/View.cpp @ 919:a5488775f880 osx-retina
Pass proxy to layer for painting
author | Chris Cannam |
---|---|
date | Wed, 18 Mar 2015 13:52:07 +0000 |
parents | f6d9f28f37cb |
children | 43888f891733 |
comparison
equal
deleted
inserted
replaced
918:4fe7a09be0fe | 919:a5488775f880 |
---|---|
18 #include "data/model/Model.h" | 18 #include "data/model/Model.h" |
19 #include "base/ZoomConstraint.h" | 19 #include "base/ZoomConstraint.h" |
20 #include "base/Profiler.h" | 20 #include "base/Profiler.h" |
21 #include "base/Pitch.h" | 21 #include "base/Pitch.h" |
22 #include "base/Preferences.h" | 22 #include "base/Preferences.h" |
23 #include "ViewProxy.h" | |
23 | 24 |
24 #include "layer/TimeRulerLayer.h" | 25 #include "layer/TimeRulerLayer.h" |
25 #include "layer/SingleColourLayer.h" | 26 #include "layer/SingleColourLayer.h" |
26 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" | 27 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" |
27 #include "data/model/RangeSummarisableTimeValueModel.h" | 28 #include "data/model/RangeSummarisableTimeValueModel.h" |
56 m_followZoom(true), | 57 m_followZoom(true), |
57 m_followPlay(PlaybackScrollPageWithCentre), | 58 m_followPlay(PlaybackScrollPageWithCentre), |
58 m_followPlayIsDetached(false), | 59 m_followPlayIsDetached(false), |
59 m_playPointerFrame(0), | 60 m_playPointerFrame(0), |
60 m_showProgress(showProgress), | 61 m_showProgress(showProgress), |
61 m_paintScale(1), | |
62 m_cache(0), | 62 m_cache(0), |
63 m_cacheCentreFrame(0), | 63 m_cacheCentreFrame(0), |
64 m_cacheZoomLevel(1024), | 64 m_cacheZoomLevel(1024), |
65 m_selectionCached(false), | 65 m_selectionCached(false), |
66 m_deleting(false), | 66 m_deleting(false), |
1660 } | 1660 } |
1661 | 1661 |
1662 QRect | 1662 QRect |
1663 View::getPaintRect() const | 1663 View::getPaintRect() const |
1664 { | 1664 { |
1665 QRect r(rect()); | 1665 return rect(); |
1666 return QRect(r.x() * m_paintScale, r.y() * m_paintScale, | |
1667 r.width() * m_paintScale, r.height() * m_paintScale); | |
1668 } | 1666 } |
1669 | 1667 |
1670 void | 1668 void |
1671 View::paintEvent(QPaintEvent *e) | 1669 View::paintEvent(QPaintEvent *e) |
1672 { | 1670 { |
1838 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; | 1836 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl; |
1839 #endif | 1837 #endif |
1840 | 1838 |
1841 // Scrollable (cacheable) items first | 1839 // Scrollable (cacheable) items first |
1842 | 1840 |
1841 ViewProxy proxy(this, dpratio); | |
1842 | |
1843 if (!paintedCacheRect) { | 1843 if (!paintedCacheRect) { |
1844 | 1844 |
1845 QRect rectToPaint; | 1845 QRect rectToPaint; |
1846 | 1846 |
1847 if (repaintCache) { | 1847 if (repaintCache) { |
1848 paint.begin(m_cache); | 1848 paint.begin(m_cache); |
1849 rectToPaint = scaledCacheRect; | 1849 rectToPaint = scaledCacheRect; |
1850 m_paintScale = dpratio; | |
1851 } else { | 1850 } else { |
1852 paint.begin(this); | 1851 paint.begin(this); |
1853 rectToPaint = cacheRect; | 1852 rectToPaint = cacheRect; |
1854 m_paintScale = 1; | |
1855 } | 1853 } |
1856 | 1854 |
1857 setPaintFont(paint); | 1855 setPaintFont(paint); |
1858 paint.setClipRect(rectToPaint); | 1856 paint.setClipRect(rectToPaint); |
1859 | 1857 |
1865 paint.setBrush(Qt::NoBrush); | 1863 paint.setBrush(Qt::NoBrush); |
1866 | 1864 |
1867 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { | 1865 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { |
1868 paint.setRenderHint(QPainter::Antialiasing, false); | 1866 paint.setRenderHint(QPainter::Antialiasing, false); |
1869 paint.save(); | 1867 paint.save(); |
1870 (*i)->paint(this, paint, rectToPaint); | 1868 (*i)->paint(&proxy, paint, rectToPaint); |
1871 paint.restore(); | 1869 paint.restore(); |
1872 } | 1870 } |
1873 | 1871 |
1874 if (haveSelections && selectionCacheable) { | 1872 if (haveSelections && selectionCacheable) { |
1875 drawSelections(paint); | 1873 drawSelections(paint); |
1904 paint.setPen(getForeground()); | 1902 paint.setPen(getForeground()); |
1905 paint.setBrush(Qt::NoBrush); | 1903 paint.setBrush(Qt::NoBrush); |
1906 | 1904 |
1907 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { | 1905 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { |
1908 // Profiler profiler2("View::paintEvent non-cacheable"); | 1906 // Profiler profiler2("View::paintEvent non-cacheable"); |
1909 (*i)->paint(this, paint, nonCacheRect); | 1907 (*i)->paint(&proxy, paint, nonCacheRect); |
1910 } | 1908 } |
1911 | 1909 |
1912 paint.end(); | 1910 paint.end(); |
1913 | 1911 |
1914 paint.begin(this); | 1912 paint.begin(this); |
2419 paint.setPen(getForeground()); | 2417 paint.setPen(getForeground()); |
2420 paint.setBrush(Qt::NoBrush); | 2418 paint.setBrush(Qt::NoBrush); |
2421 | 2419 |
2422 for (LayerList::iterator i = m_layerStack.begin(); | 2420 for (LayerList::iterator i = m_layerStack.begin(); |
2423 i != m_layerStack.end(); ++i) { | 2421 i != m_layerStack.end(); ++i) { |
2424 if(!((*i)->isLayerDormant(this))){ | 2422 if (!((*i)->isLayerDormant(this))){ |
2425 | 2423 |
2426 paint.setRenderHint(QPainter::Antialiasing, false); | 2424 paint.setRenderHint(QPainter::Antialiasing, false); |
2427 | 2425 |
2428 paint.save(); | 2426 paint.save(); |
2429 paint.translate(xorigin + x, 0); | 2427 paint.translate(xorigin + x, 0); |
2430 | 2428 |
2431 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; | 2429 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl; |
2432 | 2430 |
2433 (*i)->setSynchronousPainting(true); | 2431 (*i)->setSynchronousPainting(true); |
2434 | 2432 |
2435 (*i)->paint(this, paint, chunk); | 2433 (*i)->paint(this, paint, chunk); |
2436 | 2434 |
2437 (*i)->setSynchronousPainting(false); | 2435 (*i)->setSynchronousPainting(false); |
2438 | 2436 |
2439 paint.restore(); | 2437 paint.restore(); |
2440 } | 2438 } |
2441 } | 2439 } |
2442 } | 2440 } |
2443 | 2441 |
2444 m_centreFrame = origCentreFrame; | 2442 m_centreFrame = origCentreFrame; |
2445 update(); | 2443 update(); |