vcl/headless/CairoCommon.cxx        |   38 +++++++++++++++++++++++
 vcl/headless/SvpGraphicsBackend.cxx |   21 +++++++++++-
 vcl/headless/svpgdi.cxx             |   59 ------------------------------------
 vcl/inc/headless/CairoCommon.hxx    |    4 ++
 vcl/inc/headless/svpgdi.hxx         |    3 -
 5 files changed, 62 insertions(+), 63 deletions(-)

New commits:
commit c14ca07fdcb7dee9b0099ec9c9ec419affe68779
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Nov 26 19:40:51 2021 +0100
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Thu Dec 30 16:20:10 2021 +0100

    vcl: move drawPixel to SvpGraphicsBackend
    
    Includes moving getClippedFillDamage and dependent functions to
    CairoCommon.
    
    Change-Id: Iea7c39377816c3639de1b97cea47efa71ca47315
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127709
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index 37a77d866456..5ba1ebb0edf1 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -53,6 +53,44 @@ void dl_cairo_surface_get_device_scale(cairo_surface_t* 
surface, double* x_scale
 #endif
 }
 
+basegfx::B2DRange getFillDamage(cairo_t* cr)
+{
+    double x1, y1, x2, y2;
+
+    // this is faster than cairo_fill_extents, at the cost of some overdraw
+    cairo_path_extents(cr, &x1, &y1, &x2, &y2);
+
+    // support B2DRange::isEmpty()
+    if (0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2)
+    {
+        return basegfx::B2DRange(x1, y1, x2, y2);
+    }
+
+    return basegfx::B2DRange();
+}
+
+basegfx::B2DRange getClipBox(cairo_t* cr)
+{
+    double x1, y1, x2, y2;
+
+    cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+
+    // support B2DRange::isEmpty()
+    if (0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2)
+    {
+        return basegfx::B2DRange(x1, y1, x2, y2);
+    }
+
+    return basegfx::B2DRange();
+}
+
+basegfx::B2DRange getClippedFillDamage(cairo_t* cr)
+{
+    basegfx::B2DRange aDamageRect(getFillDamage(cr));
+    aDamageRect.intersect(getClipBox(cr));
+    return aDamageRect;
+}
+
 cairo_user_data_key_t* CairoCommon::getDamageKey()
 {
     static cairo_user_data_key_t aDamageKey;
diff --git a/vcl/headless/SvpGraphicsBackend.cxx 
b/vcl/headless/SvpGraphicsBackend.cxx
index 8b318e2737fb..c4bfe42d4844 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -98,9 +98,26 @@ void SvpGraphicsBackend::SetROPFillColor(SalROPColor 
nROPColor)
     }
 }
 
-void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/) {}
+void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY)
+{
+    if (m_rCairoCommon.m_aLineColor != SALCOLOR_NONE)
+    {
+        drawPixel(nX, nY, m_rCairoCommon.m_aLineColor);
+    }
+}
 
-void SvpGraphicsBackend::drawPixel(tools::Long /*nX*/, tools::Long /*nY*/, 
Color /*aColor*/) {}
+void SvpGraphicsBackend::drawPixel(tools::Long nX, tools::Long nY, Color 
aColor)
+{
+    cairo_t* cr = m_rCairoCommon.getCairoContext(true, getAntiAlias());
+    m_rCairoCommon.clipRegion(cr);
+
+    cairo_rectangle(cr, nX, nY, 1, 1);
+    m_rCairoCommon.applyColor(cr, aColor, 0.0);
+    cairo_fill(cr);
+
+    basegfx::B2DRange extents = getClippedFillDamage(cr);
+    m_rCairoCommon.releaseCairoContext(cr, true, extents);
+}
 
 void SvpGraphicsBackend::drawLine(tools::Long /*nX1*/, tools::Long /*nY1*/, 
tools::Long /*nX2*/,
                                   tools::Long /*nY2*/)
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index d6c7fd16c17e..4c2695b5c999 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -59,44 +59,6 @@
 
 namespace
 {
-    basegfx::B2DRange getClipBox(cairo_t* cr)
-    {
-        double x1, y1, x2, y2;
-
-        cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
-
-        // support B2DRange::isEmpty()
-        if(0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2)
-        {
-            return basegfx::B2DRange(x1, y1, x2, y2);
-        }
-
-        return basegfx::B2DRange();
-    }
-
-    basegfx::B2DRange getFillDamage(cairo_t* cr)
-    {
-        double x1, y1, x2, y2;
-
-        // this is faster than cairo_fill_extents, at the cost of some overdraw
-        cairo_path_extents(cr, &x1, &y1, &x2, &y2);
-
-        // support B2DRange::isEmpty()
-        if(0.0 != x1 || 0.0 != y1 || 0.0 != x2 || 0.0 != y2)
-        {
-            return basegfx::B2DRange(x1, y1, x2, y2);
-        }
-
-        return basegfx::B2DRange();
-    }
-
-    basegfx::B2DRange getClippedFillDamage(cairo_t* cr)
-    {
-        basegfx::B2DRange aDamageRect(getFillDamage(cr));
-        aDamageRect.intersect(getClipBox(cr));
-        return aDamageRect;
-    }
-
     basegfx::B2DRange getStrokeDamage(cairo_t* cr)
     {
         double x1, y1, x2, y2;
@@ -916,27 +878,6 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, 
sal_Int32& rDPIY )
     rDPIX = rDPIY = 96;
 }
 
-void SvpSalGraphics::drawPixel( tools::Long nX, tools::Long nY )
-{
-    if (m_aCairoCommon.m_aLineColor != SALCOLOR_NONE)
-    {
-        drawPixel(nX, nY, m_aCairoCommon.m_aLineColor);
-    }
-}
-
-void SvpSalGraphics::drawPixel( tools::Long nX, tools::Long nY, Color aColor )
-{
-    cairo_t* cr = m_aCairoCommon.getCairoContext(true, getAntiAlias());
-    clipRegion(cr);
-
-    cairo_rectangle(cr, nX, nY, 1, 1);
-    m_aCairoCommon.applyColor(cr, aColor, 0.0);
-    cairo_fill(cr);
-
-    basegfx::B2DRange extents = getClippedFillDamage(cr);
-    m_aCairoCommon.releaseCairoContext(cr, true, extents);
-}
-
 void SvpSalGraphics::drawRect( tools::Long nX, tools::Long nY, tools::Long 
nWidth, tools::Long nHeight )
 {
     // because of the -1 hack we have to do fill and draw separately
diff --git a/vcl/inc/headless/CairoCommon.hxx b/vcl/inc/headless/CairoCommon.hxx
index 6911c545e7a1..3642a2361d84 100644
--- a/vcl/inc/headless/CairoCommon.hxx
+++ b/vcl/inc/headless/CairoCommon.hxx
@@ -68,6 +68,10 @@ VCL_DLLPUBLIC void 
dl_cairo_surface_set_device_scale(cairo_surface_t* surface, d
 VCL_DLLPUBLIC void dl_cairo_surface_get_device_scale(cairo_surface_t* surface, 
double* x_scale,
                                                      double* y_scale);
 
+VCL_DLLPUBLIC basegfx::B2DRange getFillDamage(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getClipBox(cairo_t* cr);
+VCL_DLLPUBLIC basegfx::B2DRange getClippedFillDamage(cairo_t* cr);
+
 enum class PaintMode
 {
     Over,
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 8f58ebd89276..dc042c499e76 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -136,8 +136,7 @@ public:
                             GetTextLayout(int nFallbackLevel) override;
     virtual void            DrawTextLayout( const GenericSalLayout& ) override;
     virtual bool            supportsOperation( OutDevSupportType ) const 
override;
-    virtual void            drawPixel( tools::Long nX, tools::Long nY ) 
override;
-    virtual void            drawPixel( tools::Long nX, tools::Long nY, Color 
nColor ) override;
+
     virtual void            drawLine( tools::Long nX1, tools::Long nY1, 
tools::Long nX2, tools::Long nY2 ) override;
     virtual void            drawRect( tools::Long nX, tools::Long nY, 
tools::Long nWidth, tools::Long nHeight ) override;
 

Reply via email to