vcl/headless/CairoCommon.cxx     |   11 +++++++++++
 vcl/headless/svpgdi.cxx          |    7 +++++++
 vcl/inc/headless/CairoCommon.hxx |    1 +
 vcl/inc/headless/svpgdi.hxx      |    3 +++
 vcl/inc/salgdi.hxx               |    4 ++++
 vcl/source/outdev/outdev.cxx     |    5 +++++
 6 files changed, 31 insertions(+)

New commits:
commit 9ea9cd14ffc69e6597996da09943e1ce11a50d6f
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Tue Oct 29 15:57:06 2024 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Thu Oct 31 12:25:26 2024 +0100

    tdf#163457 CairoSDPR: Need to apply 'damage' to gtk
    
    If a CairoSDPR does directly render to a Window the changes
    do not get reliably visualized due to the Cairo backend
    and gtk/QT usage being dependent of being told what
    'damage' is done to refresh the window accordingly.
    The VCLCairoBackend is doing that, but without reach
    from the outside.
    Note that this is a rare case, in fact the 1st one discovered
    where a CairoSDPR is painting to a Window directly, see
    comments in the task. Even this occasion should not do
    that - showing the Comments in Calc on the Overlay would
    be major to just painting to the Window roughly.
    There are other possible workarounds (also see comments in
    the task), but just adding to be able to set the needed
    'damage' in case target is a Window is simplest and
    potentially the fastest way to do this.
    Since usage of CairoSDPR is bound to use GetSystemGfxData
    anyways it is okay to react there and call a method
    ApplyFullDamage that exists on Graphics when the flag
    USE_HEADLESS_CODE is active. That forwards to the
    CairoCommon being responsible for that Window and does
    the minimal necessary to apply 'damage' to the full
    Window.
    This is done when constructing the CairoSDPR, thus
    from the timing that incarnation can then paint anything
    and it seems that at the next occasion something can
    handle the callback from gtk all is painted. If that
    should change it may get necessary to separate
    the usage of ApplyFullDamage from GetSystemGfxData,
    but works as intended for now.
    
    Change-Id: I5442f3413e43418954da29a18d66dea27e25e655
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175794
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index ea0cbdccd206..6a56e343df70 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -491,6 +491,17 @@ void CairoCommon::releaseCairoContext(cairo_t* cr, bool 
bXorModeAllowed,
     }
 }
 
+void CairoCommon::applyFullDamage() const
+{
+    if (nullptr == m_pSurface)
+        return;
+    DamageHandler* pDamage
+        = static_cast<DamageHandler*>(cairo_surface_get_user_data(m_pSurface, 
getDamageKey()));
+    if (nullptr == pDamage)
+        return;
+    pDamage->damaged(pDamage->handle, 0, 0, m_aFrameSize.getX(), 
m_aFrameSize.getY());
+}
+
 void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,
                                  sal_Int32 nExtentsRight, sal_Int32 
nExtentsBottom,
                                  cairo_surface_t* const surface, sal_Int32 
nWidth) const
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 5542fd7c1da6..fb2dc14d1468 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -89,4 +89,11 @@ SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
     return aGraphicsData;
 }
 
+#if USE_HEADLESS_CODE
+void SvpSalGraphics::ApplyFullDamage() const
+{
+    m_aCairoCommon.applyFullDamage();
+}
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx
index ac56d5d05924..a62c2fad73dd 100644
--- a/vcl/inc/headless/CairoCommon.hxx
+++ b/vcl/inc/headless/CairoCommon.hxx
@@ -147,6 +147,7 @@ struct VCL_DLLPUBLIC CairoCommon
     cairo_t* getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const;
     void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed,
                              const basegfx::B2DRange& rExtents) const;
+    void applyFullDamage() const;
 
     cairo_t* createTmpCompatibleCairoContext() const;
 
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 89370154b014..02494ee5ab8a 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -83,6 +83,9 @@ public:
     virtual bool            ShouldDownscaleIconsAtSurface(double& rScaleOut) 
const override;
 
     virtual SystemGraphicsData GetGraphicsData() const override;
+#if USE_HEADLESS_CODE
+    virtual void ApplyFullDamage() const override;
+#endif
 
 #if ENABLE_CAIRO_CANVAS
     SAL_DLLPRIVATE virtual bool            SupportsCairo() const override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 5a8a932ca559..5c4356e5bf62 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -22,6 +22,7 @@
 #include <sal/config.h>
 
 #include <vcl/outdev.hxx>
+#include <config_vclplug.h>
 
 #include "font/FontMetricData.hxx"
 #include "salgdiimpl.hxx"
@@ -393,6 +394,9 @@ public:
     SAL_DLLPRIVATE virtual OUString getRenderBackendName() const;
 
     virtual SystemGraphicsData  GetGraphicsData() const = 0;
+#if USE_HEADLESS_CODE
+    virtual void ApplyFullDamage() const {}
+#endif
 
     // Backends like the svp/gtk ones use cairo and hidpi scale at the surface
     // but bitmaps aren't hidpi, so if this returns true for the case that the
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index f177efab6cdb..954231cf3946 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -228,6 +228,11 @@ SystemGraphicsData OutputDevice::GetSystemGfxData() const
         return SystemGraphicsData();
     assert(mpGraphics);
 
+#if USE_HEADLESS_CODE
+    if (OUTDEV_WINDOW == GetOutDevType())
+        mpGraphics->ApplyFullDamage();
+#endif
+
     return mpGraphics->GetGraphicsData();
 }
 

Reply via email to