diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-05-02 18:24:10 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-03 17:09:08 +0200 |
commit | 8d902026dc45af7b239fc6f68096a3dd31279dc9 (patch) | |
tree | 5108b1ae91de0c590b9f611c1e1c4113812baa16 /vcl | |
parent | f6e663e4bb725102ebcff03cd0fea5ded9d8bc10 (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpgdi.cxx | 29 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 2 |
2 files changed, 8 insertions, 23 deletions
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; |