diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-01-11 15:48:26 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-01-18 11:34:07 +0000 |
commit | f8a1a768ca8a4e43afe128b0947fcec74c86b7f3 (patch) | |
tree | e5bc873aa07704c02408c433cfebcd3b5c3ecd7b | |
parent | f8fa52d2d35df796c47c9a56d71df1b7fdc11b8e (diff) |
svp: improve cairo polygon drawing now that more routes through it
taking the quartz tweaks for cairo
Change-Id: Ifbbf994b19dda632d5535bf6a9ab29ed3c1b76ef
-rw-r--r-- | vcl/headless/svpgdi.cxx | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 374a03f08bd2..aeda80f93954 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -849,7 +849,10 @@ void SvpSalGraphics::drawPolyPolygon(sal_uInt32 nPoly, drawPolyPolygon(aPolyPoly, 0); } -static void AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, bool bClosePath) +static const basegfx::B2DPoint aHalfPointOfs(0.5, 0.5); + +static void AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, bool bClosePath, + bool bPixelSnap, bool bLineDraw) { // short circuit if there is nothing to do const int nPointCount = rPolygon.count(); @@ -877,6 +880,18 @@ static void AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, b basegfx::B2DPoint aPoint = rPolygon.getB2DPoint( nClosedIdx ); + if( bPixelSnap) + { + // snap device coordinates to full pixels + aPoint.setX( basegfx::fround( aPoint.getX() ) ); + aPoint.setY( basegfx::fround( aPoint.getY() ) ); + } + + if( bLineDraw ) + { + aPoint += aHalfPointOfs; + } + if( !nPointIdx ) { // first point => just move there @@ -899,6 +914,11 @@ static void AddPolygonToPath(cairo_t* cr, const basegfx::B2DPolygon& rPolygon, b { basegfx::B2DPoint aCP1 = rPolygon.getNextControlPoint( nPrevIdx ); basegfx::B2DPoint aCP2 = rPolygon.getPrevControlPoint( nClosedIdx ); + if( bLineDraw ) + { + aCP1 += aHalfPointOfs; + aCP2 += aHalfPointOfs; + } cairo_curve_to(cr, aCP1.getX(), aCP1.getY(), aCP2.getX(), aCP2.getY(), aPoint.getX(), aPoint.getY()); } @@ -988,7 +1008,7 @@ bool SvpSalGraphics::drawPolyLine( } } - AddPolygonToPath(cr, rPolyLine, rPolyLine.isClosed()); + AddPolygonToPath(cr, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true); cairo_set_source_rgba(cr, m_aLineColor.getRed()/255.0, m_aLineColor.getGreen()/255.0, @@ -1041,7 +1061,7 @@ bool SvpSalGraphics::drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly, d ApplyPaintMode(cr, m_ePaintMode); for (const basegfx::B2DPolygon* pPoly = rPolyPoly.begin(); pPoly != rPolyPoly.end(); ++pPoly) - AddPolygonToPath(cr, *pPoly, true); + AddPolygonToPath(cr, *pPoly, true, !getAntiAliasB2DDraw(), m_bUseLineColor); cairo_rectangle_int_t extents = {0, 0, 0, 0}; @@ -1237,7 +1257,7 @@ void SvpSalGraphics::invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags) cairo_rectangle_int_t extents = {0, 0, 0, 0}; - AddPolygonToPath(cr, rPoly, true); + AddPolygonToPath(cr, rPoly, true, !getAntiAliasB2DDraw(), false); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |