From: Tero Tiittanen Date: Thu, 17 Nov 2011 09:00:07 +0000 (+0200) Subject: Performance optimization in transform node traversal. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=396c26d56dd141265f08d2e18456c57d5d62f256;p=konrad%2Fqtdeclarative.git Performance optimization in transform node traversal. Transform node matrix calculation was modified to use the combined matrix stack instead of matrix stack. Combined matrix stack has already been used by clip and geometry nodes. This improves performance because combined matrix stack stores pointers (matrix stack stored objects). It also removes duplication of information. Change-Id: I1a5a2546fa9aa5a4823328dd8a321ddc42fd15a0 Reviewed-by: Gunnar Sletta --- diff --git a/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp b/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp index 7bf03fd..a7e5b08 100644 --- a/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnodeupdater.cpp @@ -46,14 +46,12 @@ QT_BEGIN_NAMESPACE // #define QSG_UPDATER_DEBUG QSGNodeUpdater::QSGNodeUpdater() - : m_matrix_stack(64) - , m_combined_matrix_stack(64) + : m_combined_matrix_stack(64) , m_opacity_stack(64) , m_current_clip(0) , m_force_update(0) { m_opacity_stack.add(1); - m_matrix_stack.add(QMatrix4x4()); } void QSGNodeUpdater::updateStates(QSGNode *n) @@ -124,11 +122,19 @@ void QSGNodeUpdater::enterTransformNode(QSGTransformNode *t) #endif if (!t->matrix().isIdentity()) { + if (!m_combined_matrix_stack.isEmpty()) { + t->setCombinedMatrix(*m_combined_matrix_stack.last() * t->matrix()); + } else { + t->setCombinedMatrix(t->matrix()); + } m_combined_matrix_stack.add(&t->combinedMatrix()); - m_matrix_stack.add(m_matrix_stack.last() * t->matrix()); + } else { + if (!m_combined_matrix_stack.isEmpty()) { + t->setCombinedMatrix(*m_combined_matrix_stack.last()); + } else { + t->setCombinedMatrix(QMatrix4x4()); + } } - - t->setCombinedMatrix(m_matrix_stack.last()); } @@ -142,7 +148,6 @@ void QSGNodeUpdater::leaveTransformNode(QSGTransformNode *t) --m_force_update; if (!t->matrix().isIdentity()) { - m_matrix_stack.pop_back(); m_combined_matrix_stack.pop_back(); } diff --git a/src/declarative/scenegraph/coreapi/qsgnodeupdater_p.h b/src/declarative/scenegraph/coreapi/qsgnodeupdater_p.h index 4d2e6be..25d7c11 100644 --- a/src/declarative/scenegraph/coreapi/qsgnodeupdater_p.h +++ b/src/declarative/scenegraph/coreapi/qsgnodeupdater_p.h @@ -72,7 +72,6 @@ protected: void visitChildren(QSGNode *n); - QDataBuffer m_matrix_stack; QDataBuffer m_combined_matrix_stack; QDataBuffer m_opacity_stack; const QSGClipNode *m_current_clip;