diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-12-08 19:05:15 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2009-12-08 19:05:15 +0100 |
commit | 8eeb1400c138e4e1b35c017b228fd358a34d55ed (patch) | |
tree | 27a4d817b2e7efc5aa165ebf2fa138e45f3e2ddf /drawinglayer | |
parent | ef1ec7001a06a6ba0fdbed702bcd7a6fec58eaf9 (diff) |
aw079: #i107360# test code for trapezoid decomposer
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index ede5aee730cf..2866bb292e58 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -77,6 +77,7 @@ // for test, can be removed again #include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/polygon/b2dtrapezoid.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -666,51 +667,70 @@ namespace drawinglayer basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); aLocalPolyPolygon.transform(maCurrentTransformation); - mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - if(mnPolygonStrokePrimitive2D && getOptionsDrawinglayer().IsAntiAliasing()) + static bool bCheckTrapezoidDecomposition(false); + static bool bShowOutlinesThere(false); + if(bCheckTrapezoidDecomposition) { - // when AA is on and this filled polygons are the result of stroked line geometry, - // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons - mpOutputDevice->SetFillColor(); - mpOutputDevice->SetLineColor(Color(aPolygonColor)); - const sal_uInt32 nCount(aLocalPolyPolygon.count()); + // clip against discrete ViewPort + const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport(); + aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange( + aLocalPolyPolygon, rDiscreteViewport, true, false); - for(sal_uInt32 a(0); a < nCount; a++) + if(aLocalPolyPolygon.count()) { - mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0); - } - } + // subdivide + aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance( + aLocalPolyPolygon, 0.5); - static bool bTestPolygonClipping(false); - if(bTestPolygonClipping) - { - static bool bInside(true); - static bool bFilled(false); - static bool bLine(false); + // trapezoidize + const basegfx::B2DTrapezoidVector aB2DTrapezoidVector(basegfx::tools::trapezoidSubdivide( + aLocalPolyPolygon)); - basegfx::B2DRange aRange(aLocalPolyPolygon.getB2DRange()); - aRange.grow(aRange.getWidth() * -0.1); + const sal_uInt32 nCount(aB2DTrapezoidVector.size()); - if(bFilled) - { - basegfx::B2DPolyPolygon aFilledClipped(basegfx::tools::clipPolyPolygonOnRange(aLocalPolyPolygon, aRange, bInside, false)); - basegfx::BColor aRand(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0); - mpOutputDevice->SetFillColor(Color(aRand)); - mpOutputDevice->SetLineColor(); - mpOutputDevice->DrawPolyPolygon(aFilledClipped); + if(nCount) + { + basegfx::BColor aInvPolygonColor(aPolygonColor); + aInvPolygonColor.invert(); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon()); + + if(bShowOutlinesThere) + { + mpOutputDevice->SetFillColor(Color(aPolygonColor)); + mpOutputDevice->SetLineColor(); + } + + mpOutputDevice->DrawPolygon(aTempPolygon); + + if(bShowOutlinesThere) + { + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(Color(aInvPolygonColor)); + mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0); + } + } + } } + } + else + { + mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - if(bLine) + if(mnPolygonStrokePrimitive2D && getOptionsDrawinglayer().IsAntiAliasing()) { - basegfx::B2DPolyPolygon aLineClipped(basegfx::tools::clipPolyPolygonOnRange(aLocalPolyPolygon, aRange, bInside, true)); - basegfx::BColor aRand(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0); + // when AA is on and this filled polygons are the result of stroked line geometry, + // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons mpOutputDevice->SetFillColor(); - mpOutputDevice->SetLineColor(Color(aRand)); + mpOutputDevice->SetLineColor(Color(aPolygonColor)); + const sal_uInt32 nCount(aLocalPolyPolygon.count()); - for(sal_uInt32 a(0); a < aLineClipped.count(); a++) + for(sal_uInt32 a(0); a < nCount; a++) { - mpOutputDevice->DrawPolyLine(aLineClipped.getB2DPolygon(a), 0.0); + mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0); } } } |