[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/headless vcl/inc vcl/unx

Katarina Behrens Katarina.Behrens at cib.de
Thu Jun 28 11:45:06 UTC 2018


 vcl/headless/svpgdi.cxx          |   29 +++++++++++++++++++----------
 vcl/inc/headless/svpgdi.hxx      |    6 +++++-
 vcl/unx/kde5/KDE5SalGraphics.cxx |    2 +-
 3 files changed, 25 insertions(+), 12 deletions(-)

New commits:
commit 96f6aaa4e80a27edfc5fe3c141eb984effc9f1a7
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Jun 28 13:42:00 2018 +0200

    Use cairo's OVER operator to preserve transparency
    
    Change-Id: I1afae266a5308fa0dbf2488777ddb963e99199c7

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 9163d8cf8133..de1145a6cc7c 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -35,8 +35,6 @@
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 
-#include <cairo.h>
-
 #if ENABLE_CAIRO_CANVAS
 #   if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0)
 #      define CAIRO_OPERATOR_DIFFERENCE (static_cast<cairo_operator_t>(23))
@@ -1134,8 +1132,8 @@ void SvpSalGraphics::copyArea( long nDestX,
     copyBits(aTR, this);
 }
 
-static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
-                                          cairo_surface_t* source)
+static basegfx::B2DRange renderWithOperator(cairo_t* cr, const SalTwoRect& rTR,
+                                          cairo_surface_t* source, cairo_operator_t eOperator = CAIRO_OPERATOR_SOURCE)
 {
     cairo_rectangle(cr, rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight);
 
@@ -1160,24 +1158,35 @@ static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
         cairo_pattern_set_extend(sourcepattern, CAIRO_EXTEND_REPEAT);
         cairo_pattern_set_filter(sourcepattern, CAIRO_FILTER_NEAREST);
     }
-    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+    cairo_set_operator(cr, eOperator);
     cairo_paint(cr);
     cairo_restore(cr);
 
     return extents;
 }
 
-void SvpSalGraphics::copySource( const SalTwoRect& rTR,
-                                 cairo_surface_t* source )
+static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR,
+                                          cairo_surface_t* source)
+{
+    return renderWithOperator(cr, rTR, source, CAIRO_OPERATOR_SOURCE);
+}
+
+void SvpSalGraphics::copyWithOperator( const SalTwoRect& rTR, cairo_surface_t* source,
+                                 cairo_operator_t eOp )
 {
     cairo_t* cr = getCairoContext(false);
     clipRegion(cr);
 
-    basegfx::B2DRange extents = renderSource(cr, rTR, source);
+    basegfx::B2DRange extents = renderWithOperator(cr, rTR, source, eOp);
 
     releaseCairoContext(cr, false, extents);
 }
 
+void SvpSalGraphics::copySource( const SalTwoRect& rTR, cairo_surface_t* source )
+{
+   copyWithOperator(rTR, source, CAIRO_OPERATOR_SOURCE);
+}
+
 void SvpSalGraphics::copyBits( const SalTwoRect& rTR,
                                SalGraphics*      pSrcGraphics )
 {
@@ -1224,10 +1233,10 @@ void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, const SalBitmap& rSourceB
     copySource(rTR, source);
 }
 
-void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, BitmapBuffer* pBuffer)
+void SvpSalGraphics::drawBitmap(const SalTwoRect& rTR, BitmapBuffer* pBuffer, cairo_operator_t eOp)
 {
     cairo_surface_t* source = createCairoSurface( pBuffer );
-    copySource(rTR, source);
+    copyWithOperator(rTR, source, eOp);
 }
 
 void SvpSalGraphics::drawBitmap( const SalTwoRect& rTR,
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 860eacec7cbf..6571d21cf89d 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -24,6 +24,7 @@
 #include <vcl/sysdata.hxx>
 #include <vcl/metric.hxx>
 #include <config_cairo_canvas.h>
+#include <cairo.h>
 
 #include <salgdi.hxx>
 #include <sallayout.hxx>
@@ -111,6 +112,8 @@ public:
 private:
     void invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags);
     void copySource(const SalTwoRect& rTR, cairo_surface_t* source);
+    void copyWithOperator(const SalTwoRect& rTR, cairo_surface_t* source,
+                          cairo_operator_t eOp = CAIRO_OPERATOR_SOURCE);
     void setupPolyPolygon(cairo_t* cr, const basegfx::B2DPolyPolygon& rPolyPoly);
     void applyColor(cairo_t *cr, Color rColor);
     void drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly);
@@ -225,7 +228,8 @@ public:
     virtual void            drawBitmap( const SalTwoRect& rPosAry,
                                         const SalBitmap& rSalBitmap ) override;
     void                    drawBitmap( const SalTwoRect& rPosAry,
-                                        BitmapBuffer* pBuffer );
+                                        BitmapBuffer* pBuffer,
+                                        cairo_operator_t eOp );
     virtual void            drawBitmap( const SalTwoRect& rPosAry,
                                         const SalBitmap& rSalBitmap,
                                         const SalBitmap& rTransparentBitmap ) override;
diff --git a/vcl/unx/kde5/KDE5SalGraphics.cxx b/vcl/unx/kde5/KDE5SalGraphics.cxx
index 6ec1e6e385ea..75e7c8664ab4 100644
--- a/vcl/unx/kde5/KDE5SalGraphics.cxx
+++ b/vcl/unx/kde5/KDE5SalGraphics.cxx
@@ -622,7 +622,7 @@ bool KDE5SalGraphics::drawNativeControl(ControlType type, ControlPart part,
     QImage2BitmapBuffer(m_image.get(), pBuffer);
     SalTwoRect aTR(0, 0, m_image.get()->width(), m_image.get()->height(), rControlRegion.getX(),
                    rControlRegion.getY(), rControlRegion.GetWidth(), rControlRegion.GetHeight());
-    drawBitmap(aTR, pBuffer);
+    drawBitmap(aTR, pBuffer, CAIRO_OPERATOR_OVER);
 
     delete localClipRegion;
     return returnVal;


More information about the Libreoffice-commits mailing list