From 3398d9d40cb0dae2dc2a1a4f7dc3b4b9cceae903 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 22 Nov 2016 10:39:26 +0100 Subject: Fix clipping of graphics effects in high dpi mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consider this pseudo code: setSystemClip(region); setSystemTransform( scale 2x ); setSystemTransform( scale 2x ); The second call to setSystemTransform should be a noop. Yet, with the current code in setSystemTransform, the region would be scaled twice by 2x and thus the clipping would be incorrect. Fix that by saving the original untransformed clip and in setSystemTransform recalculate the effective transform. This is also a better fix for QTBUG-44067 / sha: 083a945c166b325298a43ba591b1338d1b0f99b6, since with this patch the order in which system clip, viewport and transform are set does no longer matter. Task-number: QTBUG-57257 Task-number: QTBUG-55698 Change-Id: Ibc232822e97ab116f7173a0cc50bba5a367619d8 Reviewed-by: Qt CI Bot Reviewed-by: Morten Johan Sørvig --- src/gui/painting/qpaintengine_p.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/gui/painting/qpaintengine_p.h') diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h index 9d511f9bad..8ac3fcff5c 100644 --- a/src/gui/painting/qpaintengine_p.h +++ b/src/gui/painting/qpaintengine_p.h @@ -71,6 +71,7 @@ public: QPaintDevice *pdev; QPaintEngine *q_ptr; + QRegion baseSystemClip; QRegion systemClip; QRect systemRect; QRegion systemViewport; @@ -79,8 +80,9 @@ public: uint hasSystemTransform : 1; uint hasSystemViewport : 1; - inline void transformSystemClip() + inline void updateSystemClip() { + systemClip = baseSystemClip; if (systemClip.isEmpty()) return; @@ -104,15 +106,30 @@ public: inline void setSystemTransform(const QTransform &xform) { systemTransform = xform; - if ((hasSystemTransform = !xform.isIdentity()) || hasSystemViewport) - transformSystemClip(); - systemStateChanged(); + hasSystemTransform = !xform.isIdentity(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); } inline void setSystemViewport(const QRegion ®ion) { systemViewport = region; hasSystemViewport = !systemViewport.isEmpty(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); + } + + inline void setSystemTransformAndViewport(const QTransform &xform, const QRegion ®ion) + { + systemTransform = xform; + hasSystemTransform = !xform.isIdentity(); + systemViewport = region; + hasSystemViewport = !systemViewport.isEmpty(); + updateSystemClip(); + if (q_ptr->state) + systemStateChanged(); } virtual void systemStateChanged() { } -- cgit v1.2.3