aboutsummaryrefslogtreecommitdiffstats
path: root/softwarecontext
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-08-08 21:06:01 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-08-08 22:39:37 +0300
commit8e7d0905e553c5c42f3caa204a5a160e25ad62f7 (patch)
treedc2187227ca4606068bc768643d5a13aa968d123 /softwarecontext
parent7d516abb39081c7ce58bb78a644f5bb5ff88f98a (diff)
Implement support for BorderImage
Change-Id: Ie49ee5c8debddcc7f2db39bb231f25c78dcd8dbb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'softwarecontext')
-rw-r--r--softwarecontext/imagenode.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/softwarecontext/imagenode.cpp b/softwarecontext/imagenode.cpp
index 869beff5d8..e56bfa7f11 100644
--- a/softwarecontext/imagenode.cpp
+++ b/softwarecontext/imagenode.cpp
@@ -309,6 +309,7 @@ void ImageNode::setTexture(QSGTexture *texture)
void ImageNode::setMirror(bool mirror)
{
+ // ### implement support for mirrored pixmaps
m_mirror = mirror;
}
@@ -335,9 +336,32 @@ void ImageNode::update()
{
}
+static Qt::TileRule getTileRule(qreal factor)
+{
+ int ifactor = qRound(factor);
+ if (qFuzzyCompare(factor, ifactor )) {
+ if (ifactor == 1 || ifactor == 0)
+ return Qt::StretchTile;
+ return Qt::RoundTile;
+ }
+ return Qt::RepeatTile;
+}
+
+
void ImageNode::paint(QPainter *painter)
{
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
+
+ if (m_innerTargetRect != m_targetRect) {
+ // border image
+ QMargins margins(m_innerTargetRect.left() - m_targetRect.left(), m_innerTargetRect.top() - m_targetRect.top(),
+ m_targetRect.right() - m_innerTargetRect.right(), m_targetRect.bottom() - m_innerTargetRect.bottom());
+ QTileRules tilerules(getTileRule(m_subSourceRect.width()), getTileRule(m_subSourceRect.height()));
+ SoftwareContext::qDrawBorderPixmap(painter, m_targetRect.toRect(), margins, m_pixmap, QRect(0, 0, m_pixmap.width(), m_pixmap.height()),
+ margins, tilerules, QDrawBorderPixmap::DrawingHints(0));
+ return;
+ }
+
if (m_tileHorizontal || m_tileVertical) {
painter->save();
qreal sx = m_targetRect.width()/(m_subSourceRect.width()*m_pixmap.width());