[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/headless vcl/inc
Katarina Behrens (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 4 08:31:30 UTC 2019
vcl/headless/svpgdi.cxx | 29 +++++++----------------------
vcl/inc/headless/svpgdi.hxx | 2 +-
2 files changed, 8 insertions(+), 23 deletions(-)
New commits:
commit 7f3b76ab45b70fe8465a432cd82e0d9d2a4c3eb6
Author: Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Thu May 2 18:24:10 2019 +0200
Commit: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Sat May 4 10:30:58 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/71759
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 2e29518a7dac..c8f179bd0066 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -550,7 +550,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;
@@ -559,10 +559,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);
@@ -578,10 +575,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));
@@ -1450,11 +1444,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);
@@ -1468,12 +1458,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));
@@ -1489,14 +1474,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 855421d671d3..c33dd9dfb827 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