aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-10-07 10:17:56 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-08 08:47:47 +0200
commit48e32cfabed8527ac788142393226ad931d29420 (patch)
tree56dea39df23e23c26f632216ec0c9e72ab415356 /src/quick
parentaeb8416d948b69d55dda45ed4ebe85585325fedc (diff)
All matrices in a batch need to be 2D safe when merging.
If we merge geometry nodes that make actual use of the z-coordinate, this information becomes lost when merging and the result is that we end up with an arbitrary wrongfully applied transformation to the merged element. Task-number: QTBUG-33897 Change-Id: I6129243e9bb890949023c35dc6b7bce30d31709a Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp19
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h2
2 files changed, 18 insertions, 3 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index ab67dc5ba9..f25e144674 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -648,6 +648,21 @@ bool Batch::isTranslateOnlyToRoot() const {
return only;
}
+/*
+ * Iterates through all the nodes in the batch and returns true if the
+ * nodes are all "2D safe" meaning that they can be merged and that
+ * the value in the z coordinate is of no consequence.
+ */
+bool Batch::allMatricesAre2DSafe() const {
+ Element *e = first;
+ while (e) {
+ if (!QMatrix4x4_Accessor::is2DSafe(*e->node->matrix()))
+ return false;
+ e = e->nextInBatch;
+ }
+ return true;
+}
+
static int qsg_countNodesInBatch(const Batch *batch)
{
int sum = 0;
@@ -1597,11 +1612,11 @@ void Renderer::uploadBatch(Batch *b)
bool canMerge = (g->drawingMode() == GL_TRIANGLES || g->drawingMode() == GL_TRIANGLE_STRIP)
&& b->positionAttribute >= 0
&& g->indexType() == GL_UNSIGNED_SHORT
- && QMatrix4x4_Accessor::is2DSafe(*gn->matrix())
&& (gn->activeMaterial()->flags() & QSGMaterial::CustomCompileStep) == 0
&& (((gn->activeMaterial()->flags() & QSGMaterial::RequiresDeterminant) == 0)
|| (((gn->activeMaterial()->flags() & QSGMaterial_RequiresFullMatrixBit) == 0) && b->isTranslateOnlyToRoot())
- );
+ )
+ && b->allMatricesAre2DSafe();
b->merged = canMerge;
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 6e9bd750e2..94e8ba5d96 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -57,7 +57,6 @@ struct Vec;
struct Rect;
struct Buffer;
struct Chunk;
-struct AlphaChunk;
struct Batch;
struct Node;
class Updater;
@@ -243,6 +242,7 @@ struct Batch
void cleanupRemovedElements();
bool isTranslateOnlyToRoot() const;
+ bool allMatricesAre2DSafe() const;
// pseudo-constructor...
void init() {