diff options
author | Thorsten Behrens <thb@openoffice.org> | 2002-06-19 10:43:25 +0000 |
---|---|---|
committer | Thorsten Behrens <thb@openoffice.org> | 2002-06-19 10:43:25 +0000 |
commit | 90c9aa2b5c6f0e12ab4f612f14da137ebff60b6b (patch) | |
tree | f2269c3b7d019507ca8d47246766c29f74719eba | |
parent | 11c0431dacf124c650bcb9fb924c591859439114 (diff) |
#100127# Added bezier render support for PolyLine, Polygon and PolyPolygon on OutputDevice and SalGraphics
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 26 | ||||
-rw-r--r-- | vcl/os2/source/gdi/salgdi.cxx | 26 | ||||
-rw-r--r-- | vcl/source/gdi/outdev.cxx | 274 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 26 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi.cxx | 26 |
5 files changed, 309 insertions, 69 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 96ca37aa36d5..6883944a32a6 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -2,8 +2,8 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.55 $ - * last change: $Author: hdu $ $Date: 2001-07-09 16:09:25 $ + * $Revision: 1.56 $ + * last change: $Author: thb $ $Date: 2002-06-19 11:38:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -669,6 +669,28 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly, // ----------------------------------------------------------------------- +sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, + const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + void SalGraphics::CopyBits( const SalTwoRect *pPosAry, SalGraphics *pSrcGraphics ) diff --git a/vcl/os2/source/gdi/salgdi.cxx b/vcl/os2/source/gdi/salgdi.cxx index f501f8da303e..7c1be5c8088b 100644 --- a/vcl/os2/source/gdi/salgdi.cxx +++ b/vcl/os2/source/gdi/salgdi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $ + * last change: $Author: thb $ $Date: 2002-06-19 11:39:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -647,6 +647,28 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly, const ULONG* pPoints, delete [] aPolygonAry; } +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, + const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) +{ + return sal_False; +} + // ======================================================================= // MAXIMUM BUFSIZE EQ 0xFFFF diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 86d324af4a80..22bda1d77371 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2,9 +2,9 @@ * * $RCSfile: outdev.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: ka $ $Date: 2002-05-29 12:53:04 $ + * last change: $Author: thb $ $Date: 2002-06-19 11:43:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -281,6 +281,118 @@ BOOL OutputDevice::ImplSelectClipRegion( SalGraphics* pGraphics, const Region& r // ======================================================================= +Polygon ImplSubdivideBezier( const Polygon& rPoly ) +{ + Polygon aPoly; + + rPoly.GetSimple( aPoly ); + + return aPoly; +} + +// ======================================================================= + +PolyPolygon ImplSubdivideBezier( const PolyPolygon& rPolyPoly ) +{ + USHORT i, nPoints = rPolyPoly.Count(); + PolyPolygon aPolyPoly( nPoints ); + for( i=0; i<nPoints; ++i ) + aPolyPoly.Insert( ImplSubdivideBezier( rPolyPoly.GetObject(i) ) ); + + return aPolyPoly; +} + +// ======================================================================= + +#ifndef REMOTE_APPSERVER +// #100127# Extracted from OutputDevice::DrawPolyPolygon() +void OutputDevice::ImplDrawPolyPolygon( USHORT nPoly, const PolyPolygon& rPolyPoly ) +{ + ULONG aStackAry1[OUTDEV_POLYPOLY_STACKBUF]; + PCONSTSALPOINT aStackAry2[OUTDEV_POLYPOLY_STACKBUF]; + BYTE* aStackAry3[OUTDEV_POLYPOLY_STACKBUF]; + ULONG* pPointAry; + PCONSTSALPOINT* pPointAryAry; + const BYTE** pFlagAryAry; + USHORT i = 0, last = 0; + BOOL bHaveBezier = sal_False; + if ( nPoly > OUTDEV_POLYPOLY_STACKBUF ) + { + pPointAry = new ULONG[nPoly]; + pPointAryAry = new PCONSTSALPOINT[nPoly]; + pFlagAryAry = new const BYTE*[nPoly]; + } + else + { + pPointAry = aStackAry1; + pPointAryAry = aStackAry2; + pFlagAryAry = (const BYTE**)aStackAry3; + } + do + { + const Polygon& rPoly = rPolyPoly.GetObject( i ); + USHORT nSize = rPoly.GetSize(); + if ( nSize ) + { + pPointAry[i] = nSize; + pPointAryAry[i] = (PCONSTSALPOINT)rPoly.ImplGetConstPointAry(); + pFlagAryAry[i] = rPoly.ImplGetConstFlagAry(); + last = i; + + if( pFlagAryAry[i] ) + bHaveBezier = sal_True; + + i++; + } + else + nPoly--; + } + while ( i < nPoly ); + + if ( nPoly == 1 ) + { + // #100127# Forward beziers to sal, if any + if( bHaveBezier ) + { + if( !mpGraphics->DrawPolygonBezier( *pPointAry, *pPointAryAry, *pFlagAryAry ) ) + { + Polygon aPoly = ImplSubdivideBezier( rPolyPoly.GetObject( last ) ); + mpGraphics->DrawPolygon( aPoly.GetSize(), (const SalPoint*)aPoly.ImplGetConstPointAry() ); + } + } + else + { + mpGraphics->DrawPolygon( *pPointAry, *pPointAryAry ); + } + } + else + { + // #100127# Forward beziers to sal, if any + if( bHaveBezier ) + { + if( !mpGraphics->DrawPolyPolygonBezier( nPoly, pPointAry, pPointAryAry, pFlagAryAry ) ) + { + PolyPolygon aPolyPoly = ImplSubdivideBezier( rPolyPoly ); + ImplDrawPolyPolygon( aPolyPoly.Count(), aPolyPoly ); + } + } + else + { + mpGraphics->DrawPolyPolygon( nPoly, pPointAry, pPointAryAry ); + } + } + + if ( pPointAry != aStackAry1 ) + { + delete[] pPointAry; + delete[] pPointAryAry; + delete[] pFlagAryAry; + } +} +#endif + +// ======================================================================= + OutputDevice::OutputDevice() : maRegion( REGION_NULL ), maSettings( Application::GetSettings() ), @@ -1433,16 +1545,37 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) ImplInitLineColor(); Polygon aPoly = ImplLogicToDevicePixel( rPoly ); - const SalPoint* pPtAry = (const SalPoint*)aPoly.ImplGetConstPointAry(); - mpGraphics->DrawPolyLine( nPoints, pPtAry ); + + // #100127# Forward beziers to sal, if any + if( aPoly.HasFlags() ) + { + const BYTE* pFlgAry = aPoly.ImplGetConstFlagAry(); + if( !mpGraphics->DrawPolyLineBezier( nPoints, pPtAry, pFlgAry ) ) + { + aPoly = ImplSubdivideBezier(aPoly); + pPtAry = (const SalPoint*)aPoly.ImplGetConstPointAry(); + mpGraphics->DrawPolyLine( aPoly.GetSize(), pPtAry ); + } + } + else + { + mpGraphics->DrawPolyLine( nPoints, pPtAry ); + } #else ImplServerGraphics* pGraphics = ImplGetServerGraphics(); if ( pGraphics ) { if ( mbInitLineColor ) ImplInitLineColor(); - pGraphics->DrawPolyLine( ImplLogicToDevicePixel( rPoly ) ); + + Polygon aPoly = ImplLogicToDevicePixel( rPoly ); + + // #100127# TODO: maybe extend Polygon::operator>> + if( aPoly.HasFlags() ) + aPoly = ImplSubdivideBezier( aPoly ); + + pGraphics->DrawPolyLine( aPoly ); } #endif } @@ -1469,6 +1602,15 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) ) return; + Polygon aPoly = ImplLogicToDevicePixel( rPoly ); + + // #100127# LineInfo is not curve-safe, subdivide always + if( aPoly.HasFlags() ) + { + aPoly = ImplSubdivideBezier( aPoly ); + nPoints = aPoly.GetSize(); + } + #ifndef REMOTE_APPSERVER // we need a graphics if ( !mpGraphics && !ImplGetGraphics() ) @@ -1487,7 +1629,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo const Color aOldLineColor( maLineColor ); const Color aOldFillColor( maFillColor ); GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( rPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); + ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); mpMetaFile = NULL; SetLineColor(); @@ -1508,12 +1650,12 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo ImplInitLineColor(); if ( LINE_DASH == aInfo.GetStyle() ) { - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( rPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); + ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) mpGraphics->DrawPolyLine( pPoly->GetSize(), (const SalPoint*)pPoly->ImplGetConstPointAry() ); } else - mpGraphics->DrawPolyLine( nPoints, (const SalPoint*) ImplLogicToDevicePixel( rPoly ).ImplGetConstPointAry() ); + mpGraphics->DrawPolyLine( nPoints, (const SalPoint*) aPoly.ImplGetConstPointAry() ); } #else ImplServerGraphics* pGraphics = ImplGetServerGraphics(); @@ -1527,7 +1669,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo const Color aOldLineColor( maLineColor ); const Color aOldFillColor( maFillColor ); GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( rPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); + ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); mpMetaFile = NULL; SetLineColor(); @@ -1548,12 +1690,12 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo ImplInitLineColor(); if ( LINE_DASH == aInfo.GetStyle() ) { - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( rPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); + ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) pGraphics->DrawPolyLine( *pPoly ); } else - pGraphics->DrawPolyLine( ImplLogicToDevicePixel( rPoly ) ); + pGraphics->DrawPolyLine( aPoly ); } } #endif @@ -1594,9 +1736,23 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly ) ImplInitFillColor(); Polygon aPoly = ImplLogicToDevicePixel( rPoly ); - const SalPoint* pPtAry = (const SalPoint*)aPoly.ImplGetConstPointAry(); - mpGraphics->DrawPolygon( nPoints, pPtAry ); + + // #100127# Forward beziers to sal, if any + if( aPoly.HasFlags() ) + { + const BYTE* pFlgAry = aPoly.ImplGetConstFlagAry(); + if( !mpGraphics->DrawPolygonBezier( nPoints, pPtAry, pFlgAry ) ) + { + aPoly = ImplSubdivideBezier(aPoly); + pPtAry = (const SalPoint*)aPoly.ImplGetConstPointAry(); + mpGraphics->DrawPolygon( aPoly.GetSize(), pPtAry ); + } + } + else + { + mpGraphics->DrawPolygon( nPoints, pPtAry ); + } #else ImplServerGraphics* pGraphics = ImplGetServerGraphics(); if ( pGraphics ) @@ -1605,7 +1761,14 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly ) ImplInitLineColor(); if ( mbInitFillColor ) ImplInitFillColor(); - pGraphics->DrawPolygon( ImplLogicToDevicePixel( rPoly ) ); + + Polygon aPoly = ImplLogicToDevicePixel( rPoly ); + + // #100127# TODO: maybe extend Polygon::operator>> + if( aPoly.HasFlags() ) + aPoly = ImplSubdivideBezier( aPoly ); + + pGraphics->DrawPolygon( aPoly ); } #endif } @@ -1646,57 +1809,24 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) if ( nPoly == 1 ) { - Polygon aPoly = ImplLogicToDevicePixel( rPolyPoly.GetObject( 0 ) ); - USHORT nSize = aPoly.GetSize(); - if ( nSize >= 2 ) + // #100127# Map to DrawPolygon + Polygon aPoly = rPolyPoly.GetObject( 0 ); + if( aPoly.GetSize() >= 2 ) { - const SalPoint* pPtAry = (const SalPoint*)aPoly.ImplGetConstPointAry(); - mpGraphics->DrawPolygon( nSize, pPtAry ); + GDIMetaFile* pOldMF = mpMetaFile; + mpMetaFile = NULL; + + DrawPolygon( aPoly ); + + mpMetaFile = mpMetaFile; } } else { - PolyPolygon aPolyPoly = ImplLogicToDevicePixel( rPolyPoly ); - ULONG aStackAry1[OUTDEV_POLYPOLY_STACKBUF]; - PCONSTSALPOINT aStackAry2[OUTDEV_POLYPOLY_STACKBUF]; - ULONG* pPointAry; - PCONSTSALPOINT* pPointAryAry; - USHORT i = 0; - if ( nPoly > OUTDEV_POLYPOLY_STACKBUF ) - { - pPointAry = new ULONG[nPoly]; - pPointAryAry = new PCONSTSALPOINT[nPoly]; - } - else - { - pPointAry = aStackAry1; - pPointAryAry = aStackAry2; - } - do - { - const Polygon& rPoly = aPolyPoly.GetObject( i ); - USHORT nSize = rPoly.GetSize(); - if ( nSize ) - { - pPointAry[i] = nSize; - pPointAryAry[i] = (PCONSTSALPOINT)rPoly.ImplGetConstPointAry(); - i++; - } - else - nPoly--; - } - while ( i < nPoly ); - - if ( nPoly == 1 ) - mpGraphics->DrawPolygon( *pPointAry, *pPointAryAry ); - else - mpGraphics->DrawPolyPolygon( nPoly, pPointAry, pPointAryAry ); - - if ( pPointAry != aStackAry1 ) - { - delete[] pPointAry; - delete[] pPointAryAry; - } + // #100127# moved real PolyPolygon draw to separate method, + // have to call recursively, avoiding duplicate + // ImplLogicToDevicePixel calls + ImplDrawPolyPolygon( nPoly, ImplLogicToDevicePixel( rPolyPoly ) ); } #else ImplServerGraphics* pGraphics = ImplGetServerGraphics(); @@ -1704,6 +1834,7 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) { if ( mbInitLineColor ) ImplInitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); if ( nPoly == 1 ) @@ -1711,10 +1842,31 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) Polygon aPoly = ImplLogicToDevicePixel( rPolyPoly.GetObject( 0 ) ); USHORT nSize = aPoly.GetSize(); if ( nSize >= 2 ) + { + // #100127# TODO: maybe extend Polygon::operator>> + if( aPoly.HasFlags() ) + aPoly = ImplSubdivideBezier( aPoly ); + pGraphics->DrawPolygon( aPoly ); + } } else - pGraphics->DrawPolyPolygon( ImplLogicToDevicePixel( rPolyPoly ) ); + { + PolyPolygon aPolyPoly = ImplLogicToDevicePixel( rPolyPoly ); + + USHORT i, nPoints = aPolyPoly.Count(); + for( i=0; i<nPoints; ++i ) + { + if( aPolyPoly.GetObject( i ).HasFlags() ) + { + // #100127# TODO: maybe extend Polygon::operator>> + aPolyPoly = ImplSubdivideBezier( aPolyPoly ); + break; + } + } + + pGraphics->DrawPolyPolygon( aPolyPoly ); + } } #endif } diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index eb16ca3abcec..69dd17427722 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: pl $ $Date: 2002-06-18 11:26:23 $ + * last change: $Author: thb $ $Date: 2002-06-19 11:39:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1152,6 +1152,28 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly, // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +sal_Bool SalGraphics::DrawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, + const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) +{ + return sal_False; +} + +// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + void SalGraphics::Invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags ) diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index 3118f91a9099..cca318aa53fe 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: thb $ $Date: 2002-06-19 11:26:33 $ + * last change: $Author: thb $ $Date: 2002-06-19 11:40:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1300,6 +1300,28 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly, const ULONG* pPoints, // ----------------------------------------------------------------------- +sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + +sal_Bool SalGraphics::DrawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, + const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) +{ + return sal_False; +} + +// ----------------------------------------------------------------------- + #define POSTSCRIPT_BUFSIZE 0x4000 // MAXIMUM BUFSIZE EQ 0xFFFF #define POSTSCRIPT_BOUNDINGSEARCH 0x1000 // we only try to get the BoundingBox // in the first 4096 bytes |