From 6e019f2ad5a5d6341d14762fba5a245da46ebeb3 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Tue, 19 Jun 2018 15:54:17 +0200
Subject: Fix mismatch of updated scenegraphs when clipping

Regenerate the tree when different nodes are clipped.

Task-number: QTBUG-68699
Change-Id: Ib59a0b92463c47f89b7a6c662abe532fb4130c3c
Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
---
 src/core/delegated_frame_node.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index c0f515ad..7f791df2 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -810,6 +810,16 @@ static bool areRenderPassStructuresEqual(viz::CompositorFrame *frameData,
 #endif // QT_NO_OPENGL
             if (!areSharedQuadStatesEqual(quad->shared_quad_state, prevQuad->shared_quad_state))
                 return false;
+            if (quad->shared_quad_state->is_clipped && quad->visible_rect != prevQuad->visible_rect) {
+                gfx::Rect targetRect1 =
+                        cc::MathUtil::MapEnclosingClippedRect(quad->shared_quad_state->quad_to_target_transform, quad->visible_rect);
+                gfx::Rect targetRect2 =
+                        cc::MathUtil::MapEnclosingClippedRect(quad->shared_quad_state->quad_to_target_transform, prevQuad->visible_rect);
+                targetRect1.Intersect(quad->shared_quad_state->clip_rect);
+                targetRect2.Intersect(quad->shared_quad_state->clip_rect);
+                if (targetRect1.IsEmpty() != targetRect2.IsEmpty())
+                    return false;
+            }
         }
     }
     return true;
-- 
cgit v1.2.1

