[Libreoffice-commits] core.git: vcl/headless vcl/inc

Katarina Behrens (via logerrit) logerrit at kemper.freedesktop.org
Fri May 3 15:10:28 UTC 2019


 vcl/headless/svpgdi.cxx     |   29 +++++++----------------------
 vcl/inc/headless/svpgdi.hxx |    2 +-
 2 files changed, 8 insertions(+), 23 deletions(-)

New commits:
commit 8d902026dc45af7b239fc6f68096a3dd31279dc9
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Thu May 2 18:24:10 2019 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 3 17:09:08 2019 +0200

    tdf#120585: use applyColor and make it transparency-aware
    
    An overloaded drawPolyPolygon for zero transparency case used to
    exist and it used applyColor to fill cairo path. It was removed
    by commit 7034311dce663c895577267110baadbec312d491 and the new
    transparency-aware drawPolyPolygon missed cairo_set_operator call
    that is present in applyColor. This works OK most of the time
    but breaks sometimes when no transparency (~no antialiasing)
    is involved.
    
    To fix that add transparency argument to applyColor and use it
    where applicable
    
    Change-Id: Ib1b077e38e7f5d30778434d45be67284407a7d16
    Reviewed-on: https://gerrit.libreoffice.org/71700
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 6f70ec6edaa0..74c27e9ba960 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -548,7 +548,7 @@ bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight,
     cairo_t* cr = getCairoContext(false);
     clipRegion(cr);
 
-    const double fTransparency = (100 - nTransparency) * (1.0/100);
+    const double fTransparency = nTransparency * (1.0/100);
 
     // To make releaseCairoContext work, use empty extents
     basegfx::B2DRange extents;
@@ -557,10 +557,7 @@ bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight,
 
     if (bHasFill)
     {
-        cairo_set_source_rgba(cr, m_aFillColor.GetRed()/255.0,
-                                  m_aFillColor.GetGreen()/255.0,
-                                  m_aFillColor.GetBlue()/255.0,
-                                  fTransparency);
+        applyColor(cr, m_aFillColor, fTransparency);
 
         // set FillDamage
         extents = getClippedFillDamage(cr);
@@ -576,10 +573,7 @@ bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight,
         cairo_matrix_init_translate(&aMatrix, 0.5, 0.5);
         cairo_set_matrix(cr, &aMatrix);
 
-        cairo_set_source_rgba(cr, m_aLineColor.GetRed()/255.0,
-                                  m_aLineColor.GetGreen()/255.0,
-                                  m_aLineColor.GetBlue()/255.0,
-                                  fTransparency);
+        applyColor(cr, m_aLineColor, fTransparency);
 
         // expand with possible StrokeDamage
         extents.expand(getClippedStrokeDamage(cr));
@@ -1451,11 +1445,7 @@ bool SvpSalGraphics::drawPolyPolygon(
 
     if (bHasFill)
     {
-        cairo_set_source_rgba(cr, m_aFillColor.GetRed()/255.0,
-                                  m_aFillColor.GetGreen()/255.0,
-                                  m_aFillColor.GetBlue()/255.0,
-                                  1.0-fTransparency);
-
+        applyColor(cr, m_aFillColor, fTransparency);
         // Get FillDamage (will be extended for LineDamage below)
         extents = getClippedFillDamage(cr);
 
@@ -1469,12 +1459,7 @@ bool SvpSalGraphics::drawPolyPolygon(
         cairo_matrix_init_translate(&aMatrix, 0.5, 0.5);
         cairo_set_matrix(cr, &aMatrix);
 
-        // Note: Other methods use applyColor(...) to set the Color. That
-        // seems to do some more. Maybe it should be used here, too (?)
-        cairo_set_source_rgba(cr, m_aLineColor.GetRed()/255.0,
-                                  m_aLineColor.GetGreen()/255.0,
-                                  m_aLineColor.GetBlue()/255.0,
-                                  1.0-fTransparency);
+        applyColor(cr, m_aLineColor, fTransparency);
 
         // expand with possible StrokeDamage
         extents.expand(getClippedStrokeDamage(cr));
@@ -1490,14 +1475,14 @@ bool SvpSalGraphics::drawPolyPolygon(
     return true;
 }
 
-void SvpSalGraphics::applyColor(cairo_t *cr, Color aColor)
+void SvpSalGraphics::applyColor(cairo_t *cr, Color aColor, double fTransparency)
 {
     if (cairo_surface_get_content(m_pSurface) == CAIRO_CONTENT_COLOR_ALPHA)
     {
         cairo_set_source_rgba(cr, aColor.GetRed()/255.0,
                                   aColor.GetGreen()/255.0,
                                   aColor.GetBlue()/255.0,
-                                  1.0);
+                                  1.0 - fTransparency);
     }
     else
     {
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 51b53f794cc9..73d80da6deb8 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -126,7 +126,7 @@ public:
 
 private:
     void invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags);
-    void applyColor(cairo_t *cr, Color rColor);
+    void applyColor(cairo_t *cr, Color rColor, double fTransparency = 0.0);
 
 protected:
     vcl::Region                         m_aClipRegion;


More information about the Libreoffice-commits mailing list