diff options
author | Andy Nichols <andy.nichols@theqtcompany.com> | 2016-04-02 23:59:48 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-06 21:27:35 +0000 |
commit | 62df019fc367511da4f949bed5afefcf5f3c0940 (patch) | |
tree | 45946b5054f446ad9ec44e395615cf6701a7ee8e /src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp | |
parent | 8ab2625c42a904681fa95a888aebe87b6b5626ff (diff) |
2DRenderer: Allow clipping when items are rotated
Previously clipping was only possible if items were rotated in
increments of 90 degrees. Now it is possible to clip items that are
rotated at any angle, but there is a performance and accuracy penalty
because QRegion is terrible.
Change-Id: Ibcb57b6d8718458eff718de117d113975cfe26db
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp')
-rw-r--r-- | src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp index 1858ef899c..65cce805a4 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp @@ -157,8 +157,8 @@ void QSGSoftwareRenderableNode::update() m_boundingRect = m_transform.mapRect(boundingRect); - if (m_clipRect.isValid()) { - m_boundingRect = m_boundingRect.intersected(m_clipRect.toRect()); + if (m_clipRegion.rectCount() == 1) { + m_boundingRect = m_boundingRect.intersected(m_clipRegion.rects().first()); } // Overrides @@ -185,6 +185,8 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu // Set clipRegion to m_dirtyRegion (in world coordinates) // as m_dirtyRegion already accounts for clipRegion painter->setClipRegion(m_dirtyRegion, Qt::ReplaceClip); + if (m_clipRegion.rectCount() > 1) + painter->setClipRegion(m_clipRegion, Qt::IntersectClip); painter->setTransform(m_transform, false); //precalculated worldTransform if (forceOpaquePainting || m_isOpaque) @@ -254,12 +256,12 @@ void QSGSoftwareRenderableNode::setTransform(const QTransform &transform) update(); } -void QSGSoftwareRenderableNode::setClipRect(const QRectF &clipRect) +void QSGSoftwareRenderableNode::setClipRegion(const QRegion &clipRect) { - if (m_clipRect == clipRect) + if (m_clipRegion == clipRect) return; - m_clipRect = clipRect; + m_clipRegion = clipRect; update(); } |