aboutsummaryrefslogtreecommitdiffstats
path: root/softwarecontext
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-08-07 21:31:04 +0200
committerLars Knoll <lars.knoll@digia.com>2014-08-08 15:57:27 +0300
commitf2919208964f32efd5d5d9a83bd856d069d070ad (patch)
tree32d5c8450e4a8968480d365b734d9a7c97d507fc /softwarecontext
parent44799792c2b85ee039f18c1f7d1304f4926c1fa3 (diff)
Implement all features required for Image
BorderImage still needs some work. Change-Id: I37616f18ddc15d3071d9f8b40e29bd4b0e2ea0a4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'softwarecontext')
-rw-r--r--softwarecontext/imagenode.cpp27
-rw-r--r--softwarecontext/imagenode.h4
2 files changed, 29 insertions, 2 deletions
diff --git a/softwarecontext/imagenode.cpp b/softwarecontext/imagenode.cpp
index 1dddbaef10..a86b10bc75 100644
--- a/softwarecontext/imagenode.cpp
+++ b/softwarecontext/imagenode.cpp
@@ -300,6 +300,10 @@ static void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const
}
ImageNode::ImageNode()
+ : m_mirror(false)
+ , m_smooth(true)
+ , m_tileHorizontal(false)
+ , m_tileVertical(false)
{
setMaterial((QSGMaterial*)1);
setGeometry((QSGGeometry*)1);
@@ -338,22 +342,26 @@ void ImageNode::setTexture(QSGTexture *texture)
void ImageNode::setMirror(bool mirror)
{
+ m_mirror = mirror;
}
-void ImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
+void ImageNode::setMipmapFiltering(QSGTexture::Filtering /*filtering*/)
{
}
void ImageNode::setFiltering(QSGTexture::Filtering filtering)
{
+ m_smooth = (filtering == QSGTexture::Nearest);
}
void ImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
{
+ m_tileHorizontal = (wrapMode == QSGTexture::Repeat);
}
void ImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
{
+ m_tileVertical = (wrapMode == QSGTexture::Repeat);
}
void ImageNode::update()
@@ -362,5 +370,20 @@ void ImageNode::update()
void ImageNode::paint(QPainter *painter)
{
- painter->drawPixmap(m_targetRect, m_pixmap, m_innerSourceRect);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
+ if (m_tileHorizontal || m_tileVertical) {
+ painter->save();
+ qreal sx = m_targetRect.width()/(m_subSourceRect.width()*m_pixmap.width());
+ qreal sy = m_targetRect.height()/(m_subSourceRect.height()*m_pixmap.height());
+ QMatrix transform(sx, 0, 0, sy, 0, 0);
+ painter->setMatrix(transform, true);
+ painter->drawTiledPixmap(QRectF(m_targetRect.x()/sx, m_targetRect.y()/sy, m_targetRect.width()/sx, m_targetRect.height()/sy),
+ m_pixmap,
+ QPointF(m_subSourceRect.left()*m_pixmap.width(), m_subSourceRect.top()*m_pixmap.height()));
+ painter->restore();
+ } else {
+ QRectF sr(m_subSourceRect.left()*m_pixmap.width(), m_subSourceRect.top()*m_pixmap.height(),
+ m_subSourceRect.width()*m_pixmap.width(), m_subSourceRect.height()*m_pixmap.height());
+ painter->drawPixmap(m_targetRect, m_pixmap, sr);
+ }
}
diff --git a/softwarecontext/imagenode.h b/softwarecontext/imagenode.h
index 956e4f75d8..bfa7447a83 100644
--- a/softwarecontext/imagenode.h
+++ b/softwarecontext/imagenode.h
@@ -30,6 +30,10 @@ private:
QRectF m_subSourceRect;
QPixmap m_pixmap;
+ bool m_mirror;
+ bool m_smooth;
+ bool m_tileHorizontal;
+ bool m_tileVertical;
};
#endif // IMAGENODE_H