summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-10-14 13:55:31 +0200
committerArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-10-14 13:55:31 +0200
commit727411be78c3ac7300caa688f8085a9952e7c85d (patch)
tree935aec152a28cd6e9eadebb303c33736c0a9b560 /canvas
parentf678fbae66d80e762faa29e7ab0fe3703f005275 (diff)
#i105655# commiting changes so far for preparing linux version
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx50
-rw-r--r--canvas/source/cairo/cairo_canvashelper.hxx1
-rwxr-xr-xcanvas/source/directx/dx_canvashelper.cxx11
-rwxr-xr-xcanvas/source/directx/dx_impltools.cxx67
-rwxr-xr-xcanvas/source/directx/dx_impltools.hxx15
-rwxr-xr-xcanvas/source/directx/dx_linepolypolygon.cxx4
-rwxr-xr-xcanvas/source/directx/dx_linepolypolygon.hxx2
7 files changed, 123 insertions, 27 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 9cf2dd978759..5469010f2745 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -958,6 +958,7 @@ namespace cairocanvas
void CanvasHelper::doPolyPolygonPath( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
Operation aOperation,
+ bool bNoLineJoin,
const uno::Sequence< rendering::Texture >* pTextures,
Cairo* pCairo ) const
{
@@ -967,10 +968,46 @@ namespace cairocanvas
if( !pCairo )
pCairo = mpCairo.get();
- doPolyPolygonImplementation( rPolyPoly, aOperation,
- pCairo, pTextures,
- mpSurfaceProvider,
- xPolyPolygon->getFillRule() );
+ if(bNoLineJoin && Stroke == aOperation)
+ {
+ // emulate rendering::PathJoinType::NONE by painting single edges
+ for(sal_uInt32 a(0); a < rPolyPoly.count(); a++)
+ {
+ const basegfx::B2DPolygon aCandidate(rPolyPoly.getB2DPolygon(a));
+ const sal_uInt32 nPointCount(aCandidate.count());
+
+ if(nPointCount)
+ {
+ const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount + 1: nPointCount);
+ basegfx::B2DPolygon aEdge;
+ aEdge.append(aCandidate.getB2DPoint(0));
+ aEdge.append(basegfx::B2DPoint(0.0, 0.0));
+
+ for(sal_uInt32 a(0); a < nEdgeCount; a++)
+ {
+ const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+ aEdge.setB2DPoint(1, aCandidate.getB2DPoint(nNextIndex));
+ aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a));
+ aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex));
+
+ doPolyPolygonImplementation( aEdge, aOperation,
+ pCairo, pTextures,
+ mpSurfaceProvider,
+ xPolyPolygon->getFillRule() );
+
+ // prepare next step
+ aEdge.setB2DPoint(0, aEdge.getB2DPoint(1));
+ }
+ }
+ }
+ }
+ else
+ {
+ doPolyPolygonImplementation( rPolyPoly, aOperation,
+ pCairo, pTextures,
+ mpSurfaceProvider,
+ xPolyPolygon->getFillRule() );
+ }
}
uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* ,
@@ -1039,9 +1076,12 @@ namespace cairocanvas
break;
}
+ bool bNoLineJoin(false);
+
switch( strokeAttributes.JoinType ) {
// cairo doesn't have join type NONE so we use MITER as it's pretty close
case rendering::PathJoinType::NONE:
+ bNoLineJoin = true;
case rendering::PathJoinType::MITER:
cairo_set_line_join( mpCairo.get(), CAIRO_LINE_JOIN_MITER );
break;
@@ -1063,7 +1103,7 @@ namespace cairocanvas
// TODO(rodo) use LineArray of strokeAttributes
- doPolyPolygonPath( xPolyPolygon, Stroke );
+ doPolyPolygonPath( xPolyPolygon, Stroke, bNoLineJoin );
cairo_restore( mpCairo.get() );
} else
diff --git a/canvas/source/cairo/cairo_canvashelper.hxx b/canvas/source/cairo/cairo_canvashelper.hxx
index 1e69a9f41e5b..90d365d63b3c 100644
--- a/canvas/source/cairo/cairo_canvashelper.hxx
+++ b/canvas/source/cairo/cairo_canvashelper.hxx
@@ -276,6 +276,7 @@ namespace cairocanvas
void doPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
Operation aOperation,
+ bool bNoLineJoin = false,
const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL,
::cairo::Cairo* pCairo=NULL ) const;
diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx
index dcb65c94ae3c..607f7c076e21 100755
--- a/canvas/source/directx/dx_canvashelper.cxx
+++ b/canvas/source/directx/dx_canvashelper.cxx
@@ -368,7 +368,11 @@ namespace dxcanvas
pGraphics->GetPixelOffsetMode() );
pGraphics->SetPixelOffsetMode( Gdiplus::PixelOffsetModeNone );
- aPen.SetMiterLimit( static_cast< Gdiplus::REAL >(strokeAttributes.MiterLimit) );
+ const bool bIsMiter(rendering::PathJoinType::MITER == strokeAttributes.JoinType);
+ const bool bIsNone(rendering::PathJoinType::NONE == strokeAttributes.JoinType);
+
+ if(bIsMiter)
+ aPen.SetMiterLimit( static_cast< Gdiplus::REAL >(strokeAttributes.MiterLimit) );
const ::std::vector< Gdiplus::REAL >& rDashArray(
::comphelper::sequenceToContainer< ::std::vector< Gdiplus::REAL > >(
@@ -381,9 +385,10 @@ namespace dxcanvas
aPen.SetLineCap( gdiCapFromCap(strokeAttributes.StartCapType),
gdiCapFromCap(strokeAttributes.EndCapType),
Gdiplus::DashCapFlat );
- aPen.SetLineJoin( gdiJoinFromJoin(strokeAttributes.JoinType) );
+ if(!bIsNone)
+ aPen.SetLineJoin( gdiJoinFromJoin(strokeAttributes.JoinType) );
- GraphicsPathSharedPtr pPath( tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon ) );
+ GraphicsPathSharedPtr pPath( tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon, bIsNone ) );
// TODO(E1): Return value
Gdiplus::Status hr = pGraphics->DrawPath( &aPen, pPath.get() );
diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 40164c9a1d87..4f5b92d6bcb5 100755
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -194,7 +194,8 @@ namespace dxcanvas
void graphicsPathFromB2DPolygon( GraphicsPathSharedPtr& rOutput,
::std::vector< Gdiplus::PointF >& rPoints,
- const ::basegfx::B2DPolygon& rPoly )
+ const ::basegfx::B2DPolygon& rPoly,
+ bool bNoLineJoin)
{
const sal_uInt32 nPoints( rPoly.count() );
@@ -241,7 +242,18 @@ namespace dxcanvas
rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast<Gdiplus::REAL>(rPoint.getX()),
static_cast<Gdiplus::REAL>(rPoint.getY()) );
- rOutput->AddBeziers( &rPoints[0], nCurrOutput );
+ if(bNoLineJoin && nCurrOutput > 7)
+ {
+ for(sal_uInt32 a(3); a < nCurrOutput; a+=3)
+ {
+ rOutput->StartFigure();
+ rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]);
+ }
+ }
+ else
+ {
+ rOutput->AddBeziers( &rPoints[0], nCurrOutput );
+ }
}
else
{
@@ -251,7 +263,20 @@ namespace dxcanvas
// Therefore, simply don't pass the last two
// points here.
if( nCurrOutput > 3 )
- rOutput->AddBeziers( &rPoints[0], nCurrOutput-2 );
+ {
+ if(bNoLineJoin && nCurrOutput > 7)
+ {
+ for(sal_uInt32 a(3); a < nCurrOutput; a+=3)
+ {
+ rOutput->StartFigure();
+ rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]);
+ }
+ }
+ else
+ {
+ rOutput->AddBeziers( &rPoints[0], nCurrOutput-2 );
+ }
+ }
}
}
else
@@ -267,10 +292,27 @@ namespace dxcanvas
static_cast<Gdiplus::REAL>(rPoint.getY()) );
}
- rOutput->AddLines( &rPoints[0], nPoints );
+ if(bNoLineJoin && nPoints > 2)
+ {
+ for(sal_uInt32 a(1); a < nPoints; a++)
+ {
+ rOutput->StartFigure();
+ rOutput->AddLine(rPoints[a - 1], rPoints[a]);
+ }
+
+ if(bClosedPolygon)
+ {
+ rOutput->StartFigure();
+ rOutput->AddLine(rPoints[nPoints - 1], rPoints[0]);
+ }
+ }
+ else
+ {
+ rOutput->AddLines( &rPoints[0], nPoints );
+ }
}
- if( bClosedPolygon )
+ if( bClosedPolygon && !bNoLineJoin )
rOutput->CloseFigure();
}
}
@@ -426,17 +468,17 @@ namespace dxcanvas
return pRes;
}
- GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly )
+ GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly, bool bNoLineJoin )
{
GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() );
::std::vector< Gdiplus::PointF > aPoints;
- graphicsPathFromB2DPolygon( pRes, aPoints, rPoly );
+ graphicsPathFromB2DPolygon( pRes, aPoints, rPoly, bNoLineJoin );
return pRes;
}
- GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly )
+ GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly, bool bNoLineJoin )
{
GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() );
::std::vector< Gdiplus::PointF > aPoints;
@@ -446,24 +488,25 @@ namespace dxcanvas
{
graphicsPathFromB2DPolygon( pRes,
aPoints,
- rPoly.getB2DPolygon( nCurrPoly ) );
+ rPoly.getB2DPolygon( nCurrPoly ),
+ bNoLineJoin);
}
return pRes;
}
- GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
+ GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly, bool bNoLineJoin )
{
LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() );
if( pPolyImpl )
{
- return pPolyImpl->getGraphicsPath();
+ return pPolyImpl->getGraphicsPath( bNoLineJoin );
}
else
{
return tools::graphicsPathFromB2DPolyPolygon(
- polyPolygonFromXPolyPolygon2D( xPoly ) );
+ polyPolygonFromXPolyPolygon2D( xPoly ), bNoLineJoin );
}
}
diff --git a/canvas/source/directx/dx_impltools.hxx b/canvas/source/directx/dx_impltools.hxx
index 072d1063235d..222b1a927305 100755
--- a/canvas/source/directx/dx_impltools.hxx
+++ b/canvas/source/directx/dx_impltools.hxx
@@ -107,11 +107,18 @@ namespace dxcanvas
GraphicsPathSharedPtr graphicsPathFromRealPoint2DSequence( const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& );
- GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly );
- GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly );
+ GraphicsPathSharedPtr graphicsPathFromB2DPolygon(
+ const ::basegfx::B2DPolygon& rPoly,
+ bool bNoLineJoin = false);
+
+ GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon(
+ const ::basegfx::B2DPolyPolygon& rPoly,
+ bool bNoLineJoin = false);
+
+ GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >&,
+ bool bNoLineJoin = false );
- GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& );
bool drawGdiPlusBitmap( const GraphicsSharedPtr& rGraphics,
const BitmapSharedPtr& rBitmap );
bool drawDIBits( const ::boost::shared_ptr< Gdiplus::Graphics >& rGraphics,
diff --git a/canvas/source/directx/dx_linepolypolygon.cxx b/canvas/source/directx/dx_linepolypolygon.cxx
index e63adc3dc613..9a5569384eae 100755
--- a/canvas/source/directx/dx_linepolypolygon.cxx
+++ b/canvas/source/directx/dx_linepolypolygon.cxx
@@ -46,14 +46,14 @@ namespace dxcanvas
{
}
- GraphicsPathSharedPtr LinePolyPolygon::getGraphicsPath() const
+ GraphicsPathSharedPtr LinePolyPolygon::getGraphicsPath( bool bNoLineJoin ) const
{
// generate GraphicsPath only on demand (gets deleted as soon
// as any of the modifying methods above touches the
// B2DPolyPolygon).
if( !mpPath )
{
- mpPath = tools::graphicsPathFromB2DPolyPolygon( getPolyPolygonUnsafe() );
+ mpPath = tools::graphicsPathFromB2DPolyPolygon( getPolyPolygonUnsafe(), bNoLineJoin );
mpPath->SetFillMode( const_cast<LinePolyPolygon*>(this)->getFillRule() == rendering::FillRule_EVEN_ODD ?
Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding );
}
diff --git a/canvas/source/directx/dx_linepolypolygon.hxx b/canvas/source/directx/dx_linepolypolygon.hxx
index 431cd1b87b4f..3e061d76e768 100755
--- a/canvas/source/directx/dx_linepolypolygon.hxx
+++ b/canvas/source/directx/dx_linepolypolygon.hxx
@@ -45,7 +45,7 @@ namespace dxcanvas
public:
explicit LinePolyPolygon( const ::basegfx::B2DPolyPolygon& );
- GraphicsPathSharedPtr getGraphicsPath() const;
+ GraphicsPathSharedPtr getGraphicsPath( bool bNoLineJoin = false) const;
private:
// overridden, to clear mpPath