summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@theqtcompany.com>2015-09-22 12:40:55 +0200
committerAndy Nichols <andy.nichols@theqtcompany.com>2015-09-23 12:48:25 +0300
commitcae291161f323df54aabf5333f485352a8d84e6e (patch)
tree6aa6b58e98ab606d0bf1d979698563115502c50e /src
parent7895c6ffb026697ea167ead1cb92b79fb559a15f (diff)
Add setTextureSize method to PainterNode
PainterNodes now support having a textureSize property to handle the highDPI scenario. We still have to support both the old and the new case though, so we have logic for both. This fixes the build with the latest Qt 5.6. Change-Id: Ia9c9d65b187956271c98fb19f6e5bb5745273e0d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/scenegraph/softwarecontext/painternode.cpp37
-rw-r--r--src/plugins/scenegraph/softwarecontext/painternode.h4
2 files changed, 33 insertions, 8 deletions
diff --git a/src/plugins/scenegraph/softwarecontext/painternode.cpp b/src/plugins/scenegraph/softwarecontext/painternode.cpp
index 8ff7bee..7e61cfa 100644
--- a/src/plugins/scenegraph/softwarecontext/painternode.cpp
+++ b/src/plugins/scenegraph/softwarecontext/painternode.cpp
@@ -136,7 +136,7 @@ QImage PainterNode::toImage() const
void PainterNode::update()
{
if (m_dirtyGeometry) {
- m_pixmap = QPixmap(m_size);
+ m_pixmap = QPixmap(m_textureSize);
if (!m_opaquePainting)
m_pixmap.fill(Qt::transparent);
@@ -168,18 +168,29 @@ void PainterNode::paint()
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
}
- painter.scale(m_contentsScale, m_contentsScale);
+ QRect clipRect;
- QRect sclip(qFloor(dirtyRect.x()/m_contentsScale),
- qFloor(dirtyRect.y()/m_contentsScale),
- qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)),
- qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale)));
+ if (m_contentsScale == 1) {
+ qreal scaleX = m_textureSize.width() / (qreal) m_size.width();
+ qreal scaleY = m_textureSize.height() / (qreal) m_size.height();
+ painter.scale(scaleX, scaleY);
+ clipRect = dirtyRect;
+ } else {
+ painter.scale(m_contentsScale, m_contentsScale);
+
+ QRect sclip(qFloor(dirtyRect.x()/m_contentsScale),
+ qFloor(dirtyRect.y()/m_contentsScale),
+ qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)),
+ qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale)));
+
+ clipRect = sclip;
+ }
if (!m_dirtyRect.isNull())
- painter.setClipRect(sclip);
+ painter.setClipRect(clipRect);
painter.setCompositionMode(QPainter::CompositionMode_Source);
- painter.fillRect(sclip, m_fillColor);
+ painter.fillRect(clipRect, m_fillColor);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
m_item->paint(&painter);
@@ -187,3 +198,13 @@ void PainterNode::paint()
m_dirtyRect = QRect();
}
+
+
+void PainterNode::setTextureSize(const QSize &size)
+{
+ if (size == m_textureSize)
+ return;
+
+ m_textureSize = size;
+ m_dirtyGeometry = true;
+}
diff --git a/src/plugins/scenegraph/softwarecontext/painternode.h b/src/plugins/scenegraph/softwarecontext/painternode.h
index 5d3ff53..6a2891d 100644
--- a/src/plugins/scenegraph/softwarecontext/painternode.h
+++ b/src/plugins/scenegraph/softwarecontext/painternode.h
@@ -67,6 +67,9 @@ public:
void paint();
+ void setTextureSize(const QSize &size);
+ QSize textureSize() const { return m_textureSize; }
+
private:
QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
@@ -89,6 +92,7 @@ private:
bool m_fastFBOResizing;
QColor m_fillColor;
qreal m_contentsScale;
+ QSize m_textureSize;
bool m_dirtyGeometry;
};