diff options
-rw-r--r-- | basegfx/test/basegfx2d.cxx | 2 | ||||
-rw-r--r-- | vcl/inc/vcl/outdev.hxx | 3 | ||||
-rw-r--r-- | vcl/source/gdi/implncvt.cxx | 577 | ||||
-rw-r--r-- | vcl/source/gdi/implncvt.hxx | 78 | ||||
-rw-r--r-- | vcl/source/gdi/makefile.mk | 1 | ||||
-rw-r--r-- | vcl/source/gdi/outdev.cxx | 256 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 3 |
9 files changed, 166 insertions, 759 deletions
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index 8b732e465a51..07d6eb4c54e5 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -483,7 +483,7 @@ public: while ( nIndex >= 0 ); CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", - nCount==18); + nCount==50); const B2DPolygon aRect( tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) )); diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index f4e42846dd5e..f824151737d2 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -577,6 +577,9 @@ public: // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check. SAL_DLLPRIVATE bool ImpTryDrawPolyLineDirect(const basegfx::B2DPolygon& rB2DPolygon, double fLineWidth, basegfx::B2DLineJoin eLineJoin); + // Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area) + void impPaintLineGeometryWithEvtlExpand(const LineInfo& rInfo, basegfx::B2DPolyPolygon aLinePolyPolygon); + protected: OutputDevice(); diff --git a/vcl/source/gdi/implncvt.cxx b/vcl/source/gdi/implncvt.cxx deleted file mode 100644 index e59fde15b5be..000000000000 --- a/vcl/source/gdi/implncvt.cxx +++ /dev/null @@ -1,577 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: implncvt.cxx,v $ - * $Revision: 1.10.136.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_vcl.hxx" -#include <vcl/salbtype.hxx> -#ifndef _SV_IMPLNCVT_HXX -#include "implncvt.hxx" -#endif - -// ----------- -// - Defines - -// ----------- - -#define CURVE_LEFT 1 -#define CURVE_RIGHT 2 -#define CURVE_STRAIGHTON 3 - -// ----------------- -// - ImplFloatPoint -// ----------------- - -struct ImplFloatPoint -{ - double fX; - double fY; - - inline ImplFloatPoint() {} - inline ImplFloatPoint( const Point& rPoint ) { fX = rPoint.X(); fY = rPoint.Y(); } - inline ImplFloatPoint( double _fX, double _fY ) { fX = _fX; fY = _fY; } - inline ImplFloatPoint( const ImplFloatPoint& rPoint ) { fX = rPoint.fX; fY = rPoint.fY; } - inline ~ImplFloatPoint() {} - - void operator+=( const ImplFloatPoint& rPoint ) { fX += rPoint.fX; fY += rPoint.fY; } - void operator-=( const ImplFloatPoint& rPoint ) { fX -= rPoint.fX; fY -= rPoint.fY; } - void operator*=( const double& rD ) { fX *= rD; fY *= rD; } - BOOL operator==( const ImplFloatPoint& rPoint ) const { return ( ( rPoint.fX == fX ) && ( rPoint.fY == fY ) ); } - void operator=( const Point& rPoint ) { fX = rPoint.X(); fY = rPoint.Y(); } - - ImplFloatPoint GetOVec( const ImplFloatPoint& rPoint ) const; - ImplFloatPoint GetNVec( const ImplFloatPoint& rPoint ) const; -}; - -// ----------------------------------------------------------------------------- - -ImplFloatPoint ImplFloatPoint::GetOVec( const ImplFloatPoint& rPoint ) const -{ - double fxt = rPoint.fX - fX; - double fyt = rPoint.fY - fY; - double fL; - - if( fyt != 0.0 ) - { - fyt = -fxt / fyt; - fL = sqrt( 1 + fyt * fyt ); - - return ImplFloatPoint( 1.0 / fL, fyt / fL ); - } - else - return ImplFloatPoint( fyt, ( fxt > 0.0 ) ? 1.0 : -1.0 ); -}; - -// ----------------------------------------------------------------------------- - -ImplFloatPoint ImplFloatPoint::GetNVec( const ImplFloatPoint& rPoint ) const -{ - const double fxt = rPoint.fX - fX; - const double fyt = rPoint.fY - fY; - const double fL = hypot( fxt, fyt ); - - return ImplFloatPoint( fxt / fL, fyt / fL ); -}; - -// -------------------- -// - ImplLineConverter -// -------------------- - -ImplLineConverter::ImplLineConverter( const Polygon& rPolygon, const LineInfo& rLineInfo, const Point* pRefPoint ) : - mbRefPoint ( FALSE ), - mfWidthHalf ( rLineInfo.GetWidth() >> 1 ), - maLineInfo ( rLineInfo ), - mpFloat0 ( new ImplFloatPoint[ 6 ] ), - mpFloat1 ( new ImplFloatPoint[ 6 ] ), - mnLines ( 0 ), - mpFloatPoint ( NULL ) -{ - UINT16 nIndex, nPolySize = rPolygon.GetSize(); - if ( nPolySize ) - { - if( rPolygon.GetFlags( 0 ) == POLY_NORMAL ) - { - mpFloatPoint = new ImplFloatPoint[ nPolySize ]; - mpFloatPoint[ 0 ] = rPolygon[ 0 ]; - - nIndex = 0; - - while( ++nIndex < nPolySize ) // doppelte Punkte eliminieren und ein FloatPointArray anlegen - { - if( rPolygon.GetFlags( nIndex ) == POLY_NORMAL ) - { - double nxt = mpFloatPoint[ mnLines ].fX; - double nyt = mpFloatPoint[ mnLines ].fY; - - if ( ( nxt == rPolygon[ nIndex ].X() ) && ( nyt == rPolygon[ nIndex ].Y() ) ) - continue; - - mpFloatPoint[ ++mnLines ] = rPolygon[ nIndex ]; - } - else - { - DBG_ERROR( "Bezier points not supported!" ); - } - } - mbClosed = ( mpFloatPoint[ 0 ] == mpFloatPoint[ mnLines ] ) ; - - if ( ( mnLines == 1 ) && ( maLineInfo.GetStyle() == LINE_DASH ) ) - { - BOOL bX = mpFloatPoint[ 0 ].fY == mpFloatPoint[ 1 ].fY; - BOOL bY = mpFloatPoint[ 0 ].fX == mpFloatPoint[ 1 ].fX; - mbRefPoint = pRefPoint && ( bX || bY ); - if ( mbRefPoint ) - { - if ( !maLineInfo.GetDashCount() ) - { - maLineInfo.SetDashCount( maLineInfo.GetDotCount() ); - maLineInfo.SetDashLen( maLineInfo.GetDotLen() ); - maLineInfo.SetDotCount( 0 ); - } - INT32 nDistance = maLineInfo.GetDistance(); - INT32 nDashLen = maLineInfo.GetDashCount() * ( maLineInfo.GetDashLen() + nDistance ); - INT32 nDotLen = maLineInfo.GetDotCount() * ( maLineInfo.GetDotLen() + nDistance ); - if ( bX ) - { - if ( mpFloatPoint[ 1 ].fX > mpFloatPoint[ 0 ].fX ) - { - ImplFloatPoint aFloat = mpFloatPoint[ 0 ]; - mpFloatPoint[ 0 ] = mpFloatPoint[ 1 ]; - mpFloatPoint[ 1 ] = aFloat; - } - mnRefDistance = (INT32)mpFloatPoint[ mnLines ].fX - pRefPoint->X(); - } - else - { - if ( mpFloatPoint[ 1 ].fY > mpFloatPoint[ 0 ].fY ) - { - ImplFloatPoint aFloat = mpFloatPoint[ 0 ]; - mpFloatPoint[ 0 ] = mpFloatPoint[ 1 ]; - mpFloatPoint[ 1 ] = aFloat; - } - mnRefDistance = (INT32)mpFloatPoint[ mnLines ].fY - pRefPoint->Y(); - } - -// mnRefDistance = ( (INT32)mpFloatPoint[ mnLines ].fX - pRefPoint->X() ) + -// ( (INT32)mpFloatPoint[ mnLines ].fY - pRefPoint->Y() ); - - mnRefDistance = mnRefDistance % ( nDashLen + nDotLen ); - if ( mnRefDistance < 0 ) - mnRefDistance = ( nDashLen + nDotLen ) + mnRefDistance; - } - } - } - } -}; - -//------------------------------------------------------------------------ - -ImplLineConverter::~ImplLineConverter() -{ - delete[] mpFloat0; - delete[] mpFloat1; - delete[] mpFloatPoint; -}; - -//------------------------------------------------------------------------ - -const Polygon* ImplLineConverter::ImplGetFirst() -{ - mnFloat1Points = 0; - mnLinesAvailable = mnLines; - - if ( mnLines ) - { - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - mfDashDotLenght = mnDashCount ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - - if ( mbRefPoint ) - { - INT32 nDistance = maLineInfo.GetDistance(); - INT32 nDashLen = maLineInfo.GetDashLen() + nDistance; - INT32 nDashesLen = maLineInfo.GetDashCount() * nDashLen; - INT32 nDotLen = maLineInfo.GetDotLen() + nDistance; - - if ( mnRefDistance >= nDashesLen ) - { - // get dotcount - if ( nDotLen ) - { - INT32 nLen = ( mnRefDistance - nDashesLen ) % nDotLen; - if ( nLen >= maLineInfo.GetDotLen() ) - { - mnDotCount -= 1 + ( mnRefDistance - nDashesLen ) / nDotLen; - if ( mnDotCount ) - mnDashCount = 0; - else - mnDotCount = maLineInfo.GetDotCount(); - mfDashDotLenght = 0.0; - mfDistanceLenght = ( maLineInfo.GetDotLen() + nDistance ) - nLen; - } - else - { - mnDashCount = 0; - mfDashDotLenght = maLineInfo.GetDotLen() - nLen; - mnDotCount -= ( mnRefDistance - nDashesLen ) / nDotLen; - } - } - } - else - { - if ( nDashLen ) - { - // get dashcount - INT32 nLen = mnRefDistance % nDashLen; - if ( nLen >= maLineInfo.GetDashLen() ) - { - mfDashDotLenght = 0.0; - mfDistanceLenght = ( maLineInfo.GetDashLen() + nDistance ) - nLen; - mnDashCount -= 1 + ( mnRefDistance / nDashLen ); - } - else - { - mfDashDotLenght = maLineInfo.GetDashLen() - nLen; - mnDashCount -= ( mnRefDistance / nDashLen ); - } - } - } - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - if ( ( mfDashDotLenght == 0.0 ) && ( mfDistanceLenght == 0.0 ) ) - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - } - return ImplGetNext(); -}; - -//------------------------------------------------------------------------ - -const Polygon* ImplLineConverter::ImplGetNext() -{ - while( mnFloat1Points || mnLinesAvailable ) - { - if ( maLineInfo.GetWidth() > 1 ) - { - if ( !mnFloat1Points ) - { - ImplFloatPoint aPointA( mpFloatPoint[ mnLinesAvailable-- ] ); - ImplFloatPoint aPointB( mpFloatPoint[ mnLinesAvailable ] ); - ImplFloatPoint aOVecAB( aPointA.GetOVec( aPointB ) ); - ImplFloatPoint aN1Vec( aPointA.GetNVec( aPointB ) ); - aN1Vec *= mfWidthHalf; - - if ( !mbClosed && ( ( mnLinesAvailable + 1 ) == mnLines ) ) - aPointA -= aN1Vec; - - aOVecAB *= mfWidthHalf; - mpFloat0[ 0 ] = aPointA; - mpFloat0[ 0 ] -= aOVecAB; - mpFloat0[ 3 ] = aPointA; - mpFloat0[ 3 ] += aOVecAB; - mpFloat0[ 1 ] = aPointB; - mpFloat0[ 1 ] -= aOVecAB; - mpFloat0[ 2 ] = aPointB; - mpFloat0[ 2 ] += aOVecAB; - - double f1D = ( aN1Vec.fX == 0 ) ? 1 : ( aN1Vec.fY / aN1Vec.fX ); - double f2D = -f1D; - - mnFloat0Points = 4; - - int nDirection; - - BOOL bContinues = ( mnLinesAvailable || mbClosed ); - if ( bContinues ) - { - ImplFloatPoint aPointC; - - if ( mnLinesAvailable ) - aPointC = mpFloatPoint[ mnLinesAvailable - 1 ]; - else - aPointC = mpFloatPoint[ mnLines - 1 ]; - - ImplFloatPoint aOVecBC( aPointB.GetOVec( aPointC ) ); - aOVecBC *= mfWidthHalf; - ImplFloatPoint aPointR0( aPointB ); - aPointR0 -= aOVecBC; - ImplFloatPoint aPointR1( aPointB ); - aPointR1 += aOVecBC; - ImplFloatPoint aN2Vec( aPointB.GetNVec( aPointC ) ); - aN2Vec *= mfWidthHalf; - - f2D = ( fabs( aN2Vec.fX ) < 0.00000001 ) ? 1 : ( aN2Vec.fY / aN2Vec.fX ); - if ( fabs( f1D - f2D ) < 0.00000001 ) - nDirection = CURVE_STRAIGHTON; - else - { - if ( ( aN1Vec.fX * aN2Vec.fY - aN1Vec.fY * aN2Vec.fX ) > 0 ) - nDirection = CURVE_LEFT; - else - nDirection = CURVE_RIGHT; - } - if ( nDirection != CURVE_STRAIGHTON ) - { - double fWidth; - ImplFloatPoint aDestPoint; - if ( hypot( aPointR0.fX - aPointA.fX, aPointR0.fY - aPointA.fY ) > hypot( aPointR1.fX - aPointA.fX, aPointR1.fY - aPointA.fY ) ) - aDestPoint = aPointR0; - else - aDestPoint = aPointR1; - - UINT16 nFirst = 0; - if ( aN1Vec.fY > 0 ) - { - if ( nDirection != CURVE_RIGHT ) - nFirst++; - } - else - { - if ( nDirection == CURVE_RIGHT ) - nFirst++; - } - fWidth = hypot( mpFloat0[ 1 + nFirst ].fX - aDestPoint.fX, mpFloat0[ 1 + nFirst ].fY - aDestPoint.fY ); - fWidth = sqrt( fWidth * fWidth / 2 ); - if ( fWidth > mfWidthHalf ) - { - // Spitzer Winkel : - mnFloat0Points = 6; - mpFloat0[ (4 + nFirst) ^ 1 ] = aDestPoint; - aDestPoint -= aN2Vec; - mpFloat0[ 4 + nFirst ] = aDestPoint; - mpFloat0[ 1 + nFirst ] += aN1Vec; - } - else - { - // Stumpferwinkel : Schnittpunkt wird berechnet - mnFloat0Points = 5; - ImplFloatPoint aSourcePoint; - double fX = 0; - double fY; - double fBDest = 0; - double fBSource = 0; - aSourcePoint = mpFloat0[ 1 + nFirst ]; - - int nValid = 0; - - if ( fabs( aN2Vec.fX ) < 0.00000001 ) - { - fX = aDestPoint.fX; - nValid = 1; - } - else - fBDest = aDestPoint.fY - ( aN2Vec.fY / aN2Vec.fX * aDestPoint.fX ); - - if ( fabs( aN1Vec.fX ) < 0.000000001 ) - { - fX = aSourcePoint.fX; - nValid = 2; - } - else - fBSource = aSourcePoint.fY - ( aN1Vec.fY / aN1Vec.fX * aSourcePoint.fX ); - - if ( !nValid ) - fX = ( fBSource - fBDest ) / ( aN2Vec.fY / aN2Vec.fX - aN1Vec.fY / aN1Vec.fX ); - if ( nValid < 2 ) - fY = aN1Vec.fY / aN1Vec.fX * fX + fBSource; - else - fY = aN2Vec.fY / aN2Vec.fX * fX + fBDest; - - mpFloat0[ 1 + nFirst ].fX = fX; - mpFloat0[ 1 + nFirst ].fY = fY; - mpFloat0[ 4 ] = aDestPoint; - } - } - else if ( ( aN1Vec.fX - aN2Vec.fX + aN1Vec.fY - aN2Vec.fY ) != 0 ) // besitzt zweiter Richtungsvektor die gleiche Steigung aber andere - bContinues = FALSE; // Richtung, dann wird hinten noch eine halbe Linienbreite angehaengt - } - if ( !bContinues ) - { - mpFloat0[ 1 ] += aN1Vec; - mpFloat0[ 2 ] += aN1Vec; - } - } - else - { - mnFloat0Points = mnFloat1Points; - ImplFloatPoint* pTemp = mpFloat1; - mpFloat1 = mpFloat0; - mpFloat0 = pTemp; - } - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - double fLenghtDone = 0; - double fLenght = ( mfDashDotLenght > 0.0 ) ? mfDashDotLenght : mfDistanceLenght; - - double fDistance; - - fDistance = hypot( mpFloat0[ 0 ].fX - mpFloat0[ 1 ].fX, mpFloat0[ 0 ].fY - mpFloat0[ 1 ].fY ); - if ( mnFloat0Points == 5 ) - { - double fDist = hypot( mpFloat0[ 2 ].fX - mpFloat0[ 3 ].fX, mpFloat0[ 2 ].fY - mpFloat0[ 3 ].fY ); - if ( fDist < fDistance ) - fDistance = fDist; - } - - if ( fDistance > fLenght ) - { - fLenghtDone = fLenght; - - ImplFloatPoint aNVec( mpFloat0[ 0 ].GetNVec( mpFloat0[ 1 ] ) ); - aNVec *= fLenght; - mnFloat1Points = mnFloat0Points; - ImplFloatPoint* pTemp = mpFloat1; - mpFloat1 = mpFloat0; - mpFloat0 = pTemp; - mnFloat0Points = 4; - mpFloat0[ 0 ] = mpFloat0[ 1 ] = mpFloat1[ 0 ]; - mpFloat0[ 1 ] += aNVec; - mpFloat0[ 2 ] = mpFloat0[ 3 ] = mpFloat1[ 3 ]; - mpFloat0[ 2 ] += aNVec; - - mpFloat1[ 0 ] = mpFloat0[ 1 ]; - mpFloat1[ 3 ] = mpFloat0[ 2 ]; - } - else - { - mnFloat1Points = 0; - fLenghtDone = fDistance; - } - - if ( mfDashDotLenght > 0.0 ) - { // Ein Dash oder Dot wurde erzeugt - mfDashDotLenght -= fLenghtDone; - if ( mfDashDotLenght == 0.0 ) - { // Komplett erzeugt - if ( mnDashCount ) - mnDashCount--; - else - mnDotCount--; - - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - else - { // Das erzeugte Polygon muessen wir ignorieren - mfDistanceLenght -= fLenghtDone; - if ( mfDistanceLenght == 0.0 ) - mfDashDotLenght = ( mnDashCount ) ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - continue; - } - } - maPolygon.SetSize( (UINT16)mnFloat0Points ); - UINT16 i = 0; - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 0 ].fX ), FRound( mpFloat0[ 0 ].fY ) ); - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 1 ].fX ), FRound( mpFloat0[ 1 ].fY ) ); - if ( mnFloat0Points > 4 ) - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 4 ].fX ), FRound( mpFloat0[ 4 ].fY ) ); - if ( mnFloat0Points > 5 ) - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 5 ].fX ), FRound( mpFloat0[ 5 ].fY ) ); - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 2 ].fX ), FRound( mpFloat0[ 2 ].fY ) ); - maPolygon[ i ] = Point( FRound( mpFloat0[ 3 ].fX ), FRound( mpFloat0[ 3 ].fY ) ); - - } - else - { - if ( !mnFloat1Points ) - { - mpFloat0[ 0 ] = mpFloatPoint[ mnLinesAvailable-- ]; - mpFloat0[ 1 ] = mpFloatPoint[ mnLinesAvailable ]; - } - else - { - mpFloat0[ 0 ] = mpFloat1[ 0 ]; - mpFloat0[ 1 ] = mpFloat1[ 1 ]; - } - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - double fLenghtDone = 0; - double fLenght = ( mfDashDotLenght > 0.0 ) ? mfDashDotLenght : mfDistanceLenght; - double fDistance; - fDistance = hypot( mpFloat0[ 0 ].fX - mpFloat0[ 1 ].fX, mpFloat0[ 0 ].fY - mpFloat0[ 1 ].fY ); - if ( fDistance > fLenght ) - { - fLenghtDone = fLenght; - ImplFloatPoint aNVec( mpFloat0[ 0 ].GetNVec( mpFloat0[ 1 ] ) ); - aNVec *= fLenght; - mpFloat1[ 1 ] = mpFloat0[ 1 ]; - mpFloat0[ 1 ] = mpFloat0[ 0 ]; - mpFloat0[ 1 ] += aNVec; - mpFloat1[ 0 ] = mpFloat0[ 1 ]; - mnFloat1Points = 2; - } - else - { - mnFloat1Points = 0; - fLenghtDone = fDistance; - } - if ( mfDashDotLenght > 0.0 ) - { // Ein Dash oder Dot wurde erzeugt - mfDashDotLenght -= fLenghtDone; - if ( mfDashDotLenght == 0.0 ) - { // Komplett erzeugt - if ( mnDashCount ) - mnDashCount--; - else - mnDotCount--; - - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - else - { // Das erzeugte Polygon muessen wir ignorieren - mfDistanceLenght -= fLenghtDone; - if ( mfDistanceLenght == 0.0 ) - mfDashDotLenght = ( mnDashCount ) ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - continue; - } - } - maPolygon.SetSize( 2 ); - maPolygon[ 0 ] = Point( (long)mpFloat0[ 0 ].fX, (long)mpFloat0[ 0 ].fY ); - maPolygon[ 1 ] = Point( (long)mpFloat0[ 1 ].fX, (long)mpFloat0[ 1 ].fY ); - } - return &maPolygon; - } - return NULL; -}; diff --git a/vcl/source/gdi/implncvt.hxx b/vcl/source/gdi/implncvt.hxx deleted file mode 100644 index 2d369d12f253..000000000000 --- a/vcl/source/gdi/implncvt.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: implncvt.hxx,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SV_LINECONV_HXX -#define _SV_LINECONV_HXX - -#include <tools/poly.hxx> -#include <vcl/lineinfo.hxx> - -// -------------------- -// - ImplLineConverter -// -------------------- - -struct ImplFloatPoint; - -class ImplLineConverter -{ - BOOL mbClosed; - BOOL mbRefPoint; - INT32 mnRefDistance; - - double mfWidthHalf; - LineInfo maLineInfo; - - double mfDashDotLenght; - double mfDistanceLenght; - - UINT32 mnDashCount; - UINT32 mnDotCount; - - Polygon maPolygon; - UINT32 mnFloat0Points; - ImplFloatPoint* mpFloat0; - UINT32 mnFloat1Points; - ImplFloatPoint* mpFloat1; - - UINT32 mnLinesAvailable; - UINT32 mnLines; - - ImplFloatPoint* mpFloatPoint; - - public: - - ImplLineConverter( const Polygon& rPoly, const LineInfo& rLineInfo, const Point* pRefPoint ); - ~ImplLineConverter(); - - const Polygon* ImplGetFirst(); - const Polygon* ImplGetNext(); -}; - -#endif diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index a09ae92dcb5e..bdc08118979a 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -81,7 +81,6 @@ SLOFILES= $(SLO)$/salmisc.obj \ $(SLO)$/imagerepository.obj \ $(SLO)$/impprn.obj \ $(SLO)$/impvect.obj \ - $(SLO)$/implncvt.obj \ $(SLO)$/jobset.obj \ $(SLO)$/lineinfo.obj \ $(SLO)$/mapmod.obj \ diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index e86256bc4830..7352f5ed45d9 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -56,7 +56,6 @@ #include <vcl/gdimtf.hxx> #include <vcl/outdata.hxx> #include <vcl/print.hxx> -#include <implncvt.hxx> #include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/unowrap.hxx> @@ -77,6 +76,8 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <vcl/unohelp.hxx> +#include <numeric> + using namespace ::com::sun::star; DBG_NAME( OutputDevice ) @@ -2325,6 +2326,130 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt ) // ----------------------------------------------------------------------- +void OutputDevice::impPaintLineGeometryWithEvtlExpand( + const LineInfo& rInfo, + basegfx::B2DPolyPolygon aLinePolyPolygon) +{ + const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) + && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) + && ROP_OVERPAINT == GetRasterOp() + && IsLineColor()); + basegfx::B2DPolyPolygon aFillPolyPolygon; + const bool bDashUsed(LINE_DASH == rInfo.GetStyle()); + const bool bLineWidthUsed(rInfo.GetWidth() > 1); + + if(bDashUsed && aLinePolyPolygon.count()) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(rInfo.GetDashLen()); + const double fDotLen(rInfo.GetDotLen()); + const double fDistance(rInfo.GetDistance()); + + for(sal_uInt16 a(0); a < rInfo.GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } + + for(sal_uInt16 b(0); b < rInfo.GetDotCount(); b++) + { + fDotDashArray.push_back(fDotLen); + fDotDashArray.push_back(fDistance); + } + + const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + + if(fAccumulated > 0.0) + { + basegfx::B2DPolyPolygon aResult; + + for(sal_uInt32 c(0); c < aLinePolyPolygon.count(); c++) + { + basegfx::B2DPolyPolygon aLineTraget; + basegfx::tools::applyLineDashing( + aLinePolyPolygon.getB2DPolygon(c), + fDotDashArray, + &aLineTraget); + aResult.append(aLineTraget); + } + + aLinePolyPolygon = aResult; + } + } + + if(bLineWidthUsed && aLinePolyPolygon.count()) + { + const double fHalfLineWidth((rInfo.GetWidth() * 0.5) + 0.5); + + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + aFillPolyPolygon.append(basegfx::tools::createAreaGeometry( + aLinePolyPolygon.getB2DPolygon(a), + fHalfLineWidth, + rInfo.GetLineJoin())); + } + + aLinePolyPolygon.clear(); + } + + GDIMetaFile* pOldMetaFile = mpMetaFile; + mpMetaFile = NULL; + + if(aLinePolyPolygon.count()) + { + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + bool bDone(false); + + if(bTryAA) + { + bDone = mpGraphics->DrawPolyLine(aCandidate, basegfx::B2DVector(1.0, 1.0), basegfx::B2DLINEJOIN_NONE, this); + } + + if(!bDone) + { + const Polygon aPolygon(aCandidate); + mpGraphics->DrawPolyLine(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this); + } + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor( maLineColor ); + const Color aOldFillColor( maFillColor ); + + SetLineColor(); + ImplInitLineColor(); + SetFillColor( aOldLineColor ); + ImplInitFillColor(); + + bool bDone(false); + + if(bTryAA) + { + bDone = mpGraphics->DrawPolyPolygon(aFillPolyPolygon, 0.0, this); + } + + if(!bDone) + { + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + mpGraphics->DrawPolygon(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this); + } + } + + SetFillColor( aOldFillColor ); + SetLineColor( aOldLineColor ); + } + + mpMetaFile = pOldMetaFile; +} + +// ----------------------------------------------------------------------- + void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, const LineInfo& rLineInfo ) { @@ -2352,47 +2477,22 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, if ( mbOutputClipped ) return; + const Point aStartPt( ImplLogicToDevicePixel( rStartPt ) ); + const Point aEndPt( ImplLogicToDevicePixel( rEndPt ) ); const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); + const bool bDashUsed(LINE_DASH == aInfo.GetStyle()); + const bool bLineWidthUsed(aInfo.GetWidth() > 1); - if( ( aInfo.GetWidth() > 1L ) || ( LINE_DASH == aInfo.GetStyle() ) ) + if(bDashUsed || bLineWidthUsed) { - Polygon aPoly( 2 ); aPoly[ 0 ] = rStartPt; aPoly[ 1 ] = rEndPt; - GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( aPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); - - mpMetaFile = NULL; - - if ( aInfo.GetWidth() > 1 ) - { - const Color aOldLineColor( maLineColor ); - const Color aOldFillColor( maFillColor ); - - SetLineColor(); - ImplInitLineColor(); - SetFillColor( aOldLineColor ); - ImplInitFillColor(); - - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawPolygon( pPoly->GetSize(), (const SalPoint*) pPoly->GetConstPointAry(), this ); + basegfx::B2DPolygon aLinePolygon; + aLinePolygon.append(basegfx::B2DPoint(aStartPt.X(), aStartPt.Y())); + aLinePolygon.append(basegfx::B2DPoint(aEndPt.X(), aEndPt.Y())); - SetFillColor( aOldFillColor ); - SetLineColor( aOldLineColor ); - } - else - { - if ( mbInitLineColor ) - ImplInitLineColor(); - - for ( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawLine( (*pPoly)[ 0 ].X(), (*pPoly)[ 0 ].Y(), (*pPoly)[ 1 ].X(), (*pPoly)[ 1 ].Y(), this ); - } - mpMetaFile = pOldMetaFile; + impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aLinePolygon)); } else { - const Point aStartPt( ImplLogicToDevicePixel( rStartPt ) ); - const Point aEndPt( ImplLogicToDevicePixel( rEndPt ) ); - if ( mbInitLineColor ) ImplInitLineColor(); @@ -2553,7 +2653,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo) { - USHORT nPoints = rPoly.GetSize(); + const USHORT nPoints(rPoly.GetSize()); if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() ) return; @@ -2561,11 +2661,19 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI Polygon aPoly = ImplLogicToDevicePixel( rPoly ); // #100127# LineInfo is not curve-safe, subdivide always - if( aPoly.HasFlags() ) - { - aPoly = ImplSubdivideBezier( aPoly ); - nPoints = aPoly.GetSize(); - } + // + // What shall this mean? It's wrong to subdivide here when the + // polygon is a fat line. In that case, the painted geometry + // WILL be much different. + // I also have no idea how this could be related to the given ID + // which reads 'consolidate boost versions' in the task description. + // Removing. + // + //if( aPoly.HasFlags() ) + //{ + // aPoly = ImplSubdivideBezier( aPoly ); + // nPoints = aPoly.GetSize(); + //} // we need a graphics if ( !mpGraphics && !ImplGetGraphics() ) @@ -2577,67 +2685,20 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI if ( mbOutputClipped ) return; - const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); - const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsLineColor()); - - if( aInfo.GetWidth() > 1L ) - { - const Color aOldLineColor( maLineColor ); - const Color aOldFillColor( maFillColor ); - GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); - - mpMetaFile = NULL; - SetLineColor(); + if ( mbInitLineColor ) ImplInitLineColor(); - SetFillColor( aOldLineColor ); - ImplInitFillColor(); - bool bDone(false); - - if(bTryAA) - { - // #i101491# try AAed version - // Use old on-the-fly geometry preparation, combine with AA - bool bSuccess(true); - - for(const Polygon* pPoly = aLineCvt.ImplGetFirst(); bSuccess && pPoly; pPoly = aLineCvt.ImplGetNext()) - { - bSuccess = mpGraphics->DrawPolyPolygon(basegfx::B2DPolyPolygon(pPoly->getB2DPolygon()), 0.0, this); - } - if(bSuccess) - { - bDone = true; - } - } - - if(!bDone) - { - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - { - mpGraphics->DrawPolygon( pPoly->GetSize(), (const SalPoint*) pPoly->GetConstPointAry(), this ); - } - } + const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); + const bool bDashUsed(LINE_DASH == aInfo.GetStyle()); + const bool bLineWidthUsed(aInfo.GetWidth() > 1); - SetLineColor( aOldLineColor ); - SetFillColor( aOldFillColor ); - mpMetaFile = pOldMetaFile; + if(bDashUsed || bLineWidthUsed) + { + impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aPoly.getB2DPolygon())); } else { - if ( mbInitLineColor ) - ImplInitLineColor(); - if ( LINE_DASH == aInfo.GetStyle() ) - { - ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawPolyLine( pPoly->GetSize(), (const SalPoint*)pPoly->GetConstPointAry(), this ); - } - else - mpGraphics->DrawPolyLine( nPoints, (const SalPoint*) aPoly.GetConstPointAry(), this ); + mpGraphics->DrawPolyLine(nPoints, (const SalPoint*)aPoly.GetConstPointAry(), this); } if( mpAlphaVDev ) @@ -3066,8 +3127,7 @@ void OutputDevice::DrawPolyLine( } else { - // fallback to old polygon drawing if needed. This will really - // use ImplLineConverter, but still try to AA lines + // fallback to old polygon drawing if needed const Polygon aToolsPolygon( rB2DPolygon ); LineInfo aLineInfo; if( fLineWidth != 0.0 ) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2cbebf6f23e2..9d68b13553eb 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -61,11 +61,9 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/URL.hpp> - -#include "implncvt.hxx" - #include "cppuhelper/implbase1.hxx" #include <icc/sRGB-IEC61966-2.1.hxx> +#include <vcl/lineinfo.hxx> using namespace vcl; using namespace rtl; diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 1e9572887e0b..c1f987377c67 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -52,7 +52,6 @@ #include <vcl/gdimtf.hxx> #include <vcl/outdata.hxx> #include <vcl/print.hxx> -#include <implncvt.hxx> #include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/unowrap.hxx> diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index d140610f7875..e128b7d150fa 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1494,6 +1494,9 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : // the used basegfx::tools::createAreaGeometry is simply too // expensive with very big polygons; fallback to caller (who // should use ImplLineConverter normally) + // AW: ImplLineConverter had to be removed since it does not even + // know LineJoins, so the fallback will now prepare the line geometry + // the same way. return false; } const XRenderPeer& rRenderPeer = XRenderPeer::GetInstance(); |