aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-08-17 11:56:05 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-17 13:19:47 +0200
commitdc5644758a2cdbe67111e3471488b89b1ddddd8c (patch)
tree9d025624131de29122fb9273907e1fcbaf8c6e78 /src
parentf9990c90e1c6d212b66017a0d6dd485b550b26c4 (diff)
Use scissor clip if element is rotated a multiple of 90 degrees.
Change-Id: I16706049f0ff5a371b5fa95430ca6c2d2f1add96 Reviewed-on: http://codereview.qt.nokia.com/3086 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/scenegraph/coreapi/qsgrenderer.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/declarative/scenegraph/coreapi/qsgrenderer.cpp b/src/declarative/scenegraph/coreapi/qsgrenderer.cpp
index 73d660b710..67575597ff 100644
--- a/src/declarative/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/declarative/scenegraph/coreapi/qsgrenderer.cpp
@@ -397,17 +397,32 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip)
m *= *clip->matrix();
// TODO: Check for multisampling and pixel grid alignment.
- bool canUseScissor = clip->isRectangular()
- && qFuzzyIsNull(m(0, 1)) && qFuzzyIsNull(m(1, 0))
- && qFuzzyIsNull(m(3, 0)) && qFuzzyIsNull(m(3, 1));
+ bool isRectangleWithNoPerspective = clip->isRectangular()
+ && qFuzzyIsNull(m(3, 0)) && qFuzzyIsNull(m(3, 1));
+ bool noRotate = qFuzzyIsNull(m(0, 1)) && qFuzzyIsNull(m(1, 0));
+ bool isRotate90 = qFuzzyIsNull(m(0, 0)) && qFuzzyIsNull(m(1, 1));
- if (canUseScissor) {
+ if (isRectangleWithNoPerspective && (noRotate || isRotate90)) {
QRectF bbox = clip->clipRect();
qreal invW = 1 / m(3, 3);
- qreal fx1 = (bbox.left() * m(0, 0) + m(0, 3)) * invW;
- qreal fy1 = (bbox.bottom() * m(1, 1) + m(1, 3)) * invW;
- qreal fx2 = (bbox.right() * m(0, 0) + m(0, 3)) * invW;
- qreal fy2 = (bbox.top() * m(1, 1) + m(1, 3)) * invW;
+ qreal fx1, fy1, fx2, fy2;
+ if (noRotate) {
+ fx1 = (bbox.left() * m(0, 0) + m(0, 3)) * invW;
+ fy1 = (bbox.bottom() * m(1, 1) + m(1, 3)) * invW;
+ fx2 = (bbox.right() * m(0, 0) + m(0, 3)) * invW;
+ fy2 = (bbox.top() * m(1, 1) + m(1, 3)) * invW;
+ } else {
+ Q_ASSERT(isRotate90);
+ fx1 = (bbox.bottom() * m(0, 1) + m(0, 3)) * invW;
+ fy1 = (bbox.left() * m(1, 0) + m(1, 3)) * invW;
+ fx2 = (bbox.top() * m(0, 1) + m(0, 3)) * invW;
+ fy2 = (bbox.right() * m(1, 0) + m(1, 3)) * invW;
+ }
+
+ if (fx1 > fx2)
+ qSwap(fx1, fx2);
+ if (fy1 > fy2)
+ qSwap(fy1, fy2);
GLint ix1 = qRound((fx1 + 1) * m_device_rect.width() * qreal(0.5));
GLint iy1 = qRound((fy1 + 1) * m_device_rect.height() * qreal(0.5));
@@ -422,7 +437,6 @@ QSGRenderer::ClipType QSGRenderer::updateStencilClip(const QSGClipNode *clip)
clipRect &= QRect(ix1, iy1, ix2 - ix1, iy2 - iy1);
}
- clipRect = clipRect.normalized();
glScissor(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
} else {
if (!stencilEnabled) {