From 7857f07d09265f58b2c17c4f619f4aad81b1c43d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 22 Sep 2009 18:14:05 +0200 Subject: #i97509# continued matrix tooling and adapting the usages now to all the ooo code --- vcl/aqua/source/gdi/salgdi.cxx | 4 +--- vcl/os2/source/gdi/salgdi3.cxx | 6 ++---- vcl/source/gdi/region.cxx | 9 +++------ vcl/source/gdi/sallayout.cxx | 7 +++---- vcl/source/glyphs/gcach_ftyp.cxx | 4 +--- vcl/unx/source/gdi/salgdi.cxx | 8 ++------ vcl/win/source/gdi/salgdi3.cxx | 6 +++--- 7 files changed, 15 insertions(+), 29 deletions(-) (limited to 'vcl') diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index e0905fe1d377..8d57d56a3667 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -1753,9 +1753,7 @@ BOOL AquaSalGraphics::GetGlyphOutline( long nGlyphId, basegfx::B2DPolyPolygon& r GgoClosePathProc( &aGgoData ); if( mfFontScale != 1.0 ) { - basegfx::B2DHomMatrix aScale; - aScale.scale( +mfFontScale, +mfFontScale ); - rPolyPoly.transform( aScale ); + rPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(+mfFontScale, +mfFontScale)); } return true; } diff --git a/vcl/os2/source/gdi/salgdi3.cxx b/vcl/os2/source/gdi/salgdi3.cxx index 573fa7336fb0..b25feee266e4 100644 --- a/vcl/os2/source/gdi/salgdi3.cxx +++ b/vcl/os2/source/gdi/salgdi3.cxx @@ -1361,10 +1361,8 @@ BOOL Os2SalGraphics::GetGlyphOutline( long nIndex, ::basegfx::B2DPolyPolygon& rB // rescaling needed for the PolyPolygon conversion if( rB2DPolyPoly.count() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( 1.0/256, 1.0/256 ); - aMatrix.scale( mfFontScale, mfFontScale ); - rB2DPolyPoly.transform( aMatrix ); + const double fFactor((1.0/256) * mfFontScale); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor)); } return bRet; diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index b98712419cf1..9cced7de3651 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -49,6 +49,7 @@ #include #include #include +#include // ======================================================================= // @@ -1300,9 +1301,7 @@ void Region::Move( long nHorzMove, long nVertMove ) mpImplRegion->mpPolyPoly->Move( nHorzMove, nVertMove ); else if( mpImplRegion->mpB2DPolyPoly ) { - ::basegfx::B2DHomMatrix aTransform; - aTransform.translate( nHorzMove, nVertMove ); - mpImplRegion->mpB2DPolyPoly->transform( aTransform ); + mpImplRegion->mpB2DPolyPoly->transform(basegfx::tools::createTranslateB2DHomMatrix(nHorzMove, nVertMove)); } else { @@ -1343,9 +1342,7 @@ void Region::Scale( double fScaleX, double fScaleY ) mpImplRegion->mpPolyPoly->Scale( fScaleX, fScaleY ); else if( mpImplRegion->mpB2DPolyPoly ) { - ::basegfx::B2DHomMatrix aTransform; - aTransform.scale( fScaleX, fScaleY ); - mpImplRegion->mpB2DPolyPoly->transform( aTransform ); + mpImplRegion->mpB2DPolyPoly->transform(basegfx::tools::createScaleB2DHomMatrix(fScaleX, fScaleY)); } else { diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 21ac05a498fc..b69a9c365f08 100755 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #ifndef _TL_DEBUG_HXX @@ -891,10 +892,8 @@ bool SalLayout::GetOutline( SalGraphics& rSalGraphics, { if( aPos.X() || aPos.Y() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.translate( aPos.X(), aPos.Y() ); - aGlyphOutline.transform( aMatrix ); - } + aGlyphOutline.transform(basegfx::tools::createTranslateB2DHomMatrix(aPos.X(), aPos.Y())); + } // insert outline at correct position rVector.push_back( aGlyphOutline ); diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index 712c2334b35c..820f3f0d74a9 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -2280,9 +2280,7 @@ bool FreetypeServerFont::GetGlyphOutline( int nGlyphIndex, // convert to basegfx polypolygon // TODO: get rid of the intermediate tools polypolygon rB2DPolyPoly = aToolPolyPolygon.getB2DPolyPolygon(); - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( +1.0/(1<<6), -1.0/(1<<6) ); - rB2DPolyPoly.transform( aMatrix ); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix( +1.0/(1<<6), -1.0/(1<<6) )); return true; } diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 4d3e40840a7b..d140610f7875 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1506,9 +1506,7 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : && !basegfx::fTools::equalZero( rLineWidth.getY() ) ) { // prepare for createAreaGeometry() with anisotropic linewidth - basegfx::B2DHomMatrix aAnisoMatrix; - aAnisoMatrix.scale( 1.0, rLineWidth.getX() / rLineWidth.getY() ); - aPolygon.transform( aAnisoMatrix ); + aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getX() / rLineWidth.getY())); } // AW: reSegment no longer needed; new createAreaGeometry will remove exteme positions @@ -1523,9 +1521,7 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : && !basegfx::fTools::equalZero( rLineWidth.getX() ) ) { // postprocess createAreaGeometry() for anisotropic linewidth - basegfx::B2DHomMatrix aAnisoMatrix; - aAnisoMatrix.scale( 1.0, rLineWidth.getY() / rLineWidth.getX() ); - aPolygon.transform( aAnisoMatrix ); + aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX())); } // temporarily adjust brush color to pen color diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 73f4d8320acc..0da51ccc2de9 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -65,6 +65,7 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolypolygon.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "sft.hxx" @@ -2480,9 +2481,8 @@ BOOL WinSalGraphics::GetGlyphOutline( long nIndex, // rescaling needed for the PolyPolygon conversion if( rB2DPolyPoly.count() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( mfFontScale/256, mfFontScale/256 ); - rB2DPolyPoly.transform( aMatrix ); + const double fFactor(mfFontScale/256); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor)); } return bRet; -- cgit From a6d693d98547c8aa172b5044c36b71160f8ad8f7 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 7 Oct 2009 14:25:40 +0200 Subject: #i105323# added FastPath for 3D scene HitTest for 3d CustomShapes by re-using the buffered last render result from the ScenePrimitive2D --- vcl/inc/vcl/bitmapex.hxx | 13 ++++++++ vcl/source/gdi/bitmapex.cxx | 73 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) (limited to 'vcl') diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx index 3da80ce8c2f1..e5ddf50f1efa 100644 --- a/vcl/inc/vcl/bitmapex.hxx +++ b/vcl/inc/vcl/bitmapex.hxx @@ -381,6 +381,19 @@ public: const BmpFilterParam* pFilterParam = NULL, const Link* pProgress = NULL ); + /** Get transparency at given position + + @param nX + integer X-Position in Bitmap + + @param nY + integer Y-Position in Bitmap + + @return transparency value in the range of [0 .. 255] where + 0 is not transparent, 255 is fully transparent + */ + sal_uInt8 GetTransparency(sal_Int32 nX, sal_Int32 nY) const; + public: friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ); diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index cfcac8851089..6626a12d29a2 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -47,6 +47,7 @@ #include #endif #include +#include // ------------ // - BitmapEx - @@ -761,6 +762,78 @@ void BitmapEx::Draw( OutputDevice* pOutDev, // ------------------------------------------------------------------ +sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const +{ + sal_uInt8 nTransparency(0xff); + + if(!aBitmap.IsEmpty()) + { + if(nX >= 0 && nX < aBitmapSize.Width() && nY >= 0 && nY < aBitmapSize.Height()) + { + switch(eTransparent) + { + case TRANSPARENT_NONE: + { + // not transparent, ergo all covered + nTransparency = 0x00; + break; + } + case TRANSPARENT_COLOR: + { + Bitmap aTestBitmap(aBitmap); + BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + + if(pRead) + { + const Color aColor(Color(pRead->GetColor(nY, nX))); + + // if color is not equal to TransparentColor, we are not transparent + if(aColor != aTransparentColor) + { + nTransparency = 0x00; + } + + aTestBitmap.ReleaseAccess(pRead); + } + break; + } + case TRANSPARENT_BITMAP: + { + if(!aMask.IsEmpty()) + { + Bitmap aTestBitmap(aMask); + BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + + if(pRead) + { + const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX)); + + if(bAlpha) + { + nTransparency = aBitmapColor.GetIndex(); + } + else + { + if(0x00 != aBitmapColor.GetIndex()) + { + nTransparency = 0x00; + } + } + + aTestBitmap.ReleaseAccess(pRead); + } + } + break; + } + } + } + } + + return nTransparency; +} + +// ------------------------------------------------------------------ + SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ) { rBitmapEx.aBitmap.Write( rOStm ); -- cgit From 727411be78c3ac7300caa688f8085a9952e7c85d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 14 Oct 2009 13:55:31 +0200 Subject: #i105655# commiting changes so far for preparing linux version --- vcl/inc/vcl/cvtsvm.hxx | 2 + vcl/inc/vcl/lineinfo.hxx | 23 ++++++----- vcl/source/gdi/cvtsvm.cxx | 38 +++++++++++++++++- vcl/source/gdi/lineinfo.cxx | 30 +++++++++++++-- vcl/source/gdi/outdev.cxx | 27 ++++++++----- vcl/win/source/gdi/salgdi_gdiplus.cxx | 72 ++++++++++++++++++++++++++++++++--- 6 files changed, 163 insertions(+), 29 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/vcl/cvtsvm.hxx b/vcl/inc/vcl/cvtsvm.hxx index 8a17015d99cf..cf4f3117a6ed 100644 --- a/vcl/inc/vcl/cvtsvm.hxx +++ b/vcl/inc/vcl/cvtsvm.hxx @@ -85,6 +85,8 @@ #define GDI_COMMENT_COMMENT 1031 #define GDI_UNICODE_COMMENT 1032 +#define GDI_LINEJOIN_ACTION 1033 + // ---------------- // - SVMConverter - // ---------------- diff --git a/vcl/inc/vcl/lineinfo.hxx b/vcl/inc/vcl/lineinfo.hxx index 60fdc3a3a0b0..a57513b2826b 100644 --- a/vcl/inc/vcl/lineinfo.hxx +++ b/vcl/inc/vcl/lineinfo.hxx @@ -32,9 +32,9 @@ #define _SV_LINEINFO_HXX #include - #include #include +#include // ---------------- // - ImplLineInfo - @@ -44,14 +44,16 @@ class SvStream; struct ImplLineInfo { - ULONG mnRefCount; - LineStyle meStyle; - long mnWidth; - USHORT mnDashCount; - long mnDashLen; - USHORT mnDotCount; - long mnDotLen; - long mnDistance; + ULONG mnRefCount; + LineStyle meStyle; + long mnWidth; + USHORT mnDashCount; + long mnDashLen; + USHORT mnDotCount; + long mnDotLen; + long mnDistance; + + basegfx::B2DLineJoin meLineJoin; ImplLineInfo(); ImplLineInfo( const ImplLineInfo& rImplLineInfo ); @@ -107,6 +109,9 @@ public: void SetDistance( long nDistance ); long GetDistance() const { return mpImplLineInfo->mnDistance; } + void SetLineJoin(basegfx::B2DLineJoin eLineJoin); + basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; } + BOOL IsDefault() const { return( !mpImplLineInfo->mnWidth && ( LINE_SOLID == mpImplLineInfo->meStyle ) ); } friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo ); diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index c1c02b673658..86d7d6bb39ee 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -483,6 +483,14 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } break; + case (GDI_LINEJOIN_ACTION) : + { + INT16 nLineJoin(0); + rIStm >> nLineJoin; + aLineInfo.SetLineJoin((basegfx::B2DLineJoin)nLineJoin); + } + break; + case( GDI_RECT_ACTION ): { ImplReadRect( rIStm, aRect ); @@ -1247,12 +1255,20 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { MetaLineAction* pAct = (MetaLineAction*) pAction; const LineInfo& rInfo = pAct->GetLineInfo(); - const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) ); + const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); + const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); if( bFatLine ) { ImplWritePushAction( rOStm ); ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() ); + + if(bLineJoin) + { + rOStm << (INT16) GDI_LINEJOIN_ACTION; + rOStm << (INT32) 6; + rOStm << (INT16) rInfo.GetLineJoin(); + } } rOStm << (INT16) GDI_LINE_ACTION; @@ -1265,6 +1281,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { ImplWritePopAction( rOStm ); nCount += 3; + + if(bLineJoin) + { + nCount += 1; + } } } break; @@ -1356,12 +1377,20 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, const Polygon& rPoly = pAct->GetPolygon(); const LineInfo& rInfo = pAct->GetLineInfo(); const USHORT nPoints = rPoly.GetSize(); - const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) ); + const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); + const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); if( bFatLine ) { ImplWritePushAction( rOStm ); ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() ); + + if(bLineJoin) + { + rOStm << (INT16) GDI_LINEJOIN_ACTION; + rOStm << (INT32) 6; + rOStm << (INT16) rInfo.GetLineJoin(); + } } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1377,6 +1406,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { ImplWritePopAction( rOStm ); nCount += 3; + + if(bLineJoin) + { + nCount += 1; + } } } break; diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx index 98f16713a145..85a48f2b0f5e 100644 --- a/vcl/source/gdi/lineinfo.cxx +++ b/vcl/source/gdi/lineinfo.cxx @@ -49,7 +49,8 @@ ImplLineInfo::ImplLineInfo() : mnDashLen ( 0 ), mnDotCount ( 0 ), mnDotLen ( 0 ), - mnDistance ( 0 ) + mnDistance ( 0 ), + meLineJoin ( basegfx::B2DLINEJOIN_ROUND ) { } @@ -63,7 +64,8 @@ ImplLineInfo::ImplLineInfo( const ImplLineInfo& rImplLineInfo ) : mnDashLen ( rImplLineInfo.mnDashLen ), mnDotCount ( rImplLineInfo.mnDotCount ), mnDotLen ( rImplLineInfo.mnDotLen ), - mnDistance ( rImplLineInfo.mnDistance ) + mnDistance ( rImplLineInfo.mnDistance ), + meLineJoin ( rImplLineInfo.meLineJoin ) { } @@ -209,6 +211,19 @@ void LineInfo::SetDistance( long nDistance ) // ----------------------------------------------------------------------- +void LineInfo::SetLineJoin(basegfx::B2DLineJoin eLineJoin) +{ + DBG_CHKTHIS( LineInfo, NULL ); + + if(eLineJoin != mpImplLineInfo->meLineJoin) + { + ImplMakeUnique(); + mpImplLineInfo->meLineJoin = eLineJoin; + } +} + +// ----------------------------------------------------------------------- + SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) { VersionCompat aCompat( rIStm, STREAM_READ ); @@ -225,6 +240,12 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) rIStm >> rImplLineInfo.mnDistance; } + if( aCompat.GetVersion() >= 3 ) + { + // version 3 + rIStm >> nTmp16; rImplLineInfo.meLineJoin = (basegfx::B2DLineJoin) nTmp16; + } + return rIStm; } @@ -232,7 +253,7 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo ) { - VersionCompat aCompat( rOStm, STREAM_WRITE, 2 ); + VersionCompat aCompat( rOStm, STREAM_WRITE, 3 ); // version 1 rOStm << (UINT16) rImplLineInfo.meStyle << rImplLineInfo.mnWidth; @@ -242,6 +263,9 @@ SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo ) rOStm << rImplLineInfo.mnDotCount << rImplLineInfo.mnDotLen; rOStm << rImplLineInfo.mnDistance; + // since version3 + rOStm << (UINT16) rImplLineInfo.meLineJoin; + return rOStm; } diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 5b543258cb0b..e86256bc4830 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2541,7 +2541,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && LINE_SOLID == rLineInfo.GetStyle()) { - DrawPolyLine(rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), basegfx::B2DLINEJOIN_ROUND); + DrawPolyLine(rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin()); return; } @@ -3042,7 +3042,12 @@ void OutputDevice::DrawPolyLine( SetFillColor(aOldLineColor); ImplInitFillColor(); - ImpDrawPolyPolygonWithB2DPolyPolygon(aAreaPolyPolygon); + // draw usig a loop; else the topology will paint a PolyPolygon + for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++) + { + ImpDrawPolyPolygonWithB2DPolyPolygon( + basegfx::B2DPolyPolygon(aAreaPolyPolygon.getB2DPolygon(a))); + } SetLineColor(aOldLineColor); ImplInitLineColor(); @@ -3059,14 +3064,16 @@ void OutputDevice::DrawPolyLine( } } } - - // fallback to old polygon drawing if needed. This will really - // use ImplLineConverter, but still try to AA lines - const Polygon aToolsPolygon( rB2DPolygon ); - LineInfo aLineInfo; - if( fLineWidth != 0.0 ) - aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); - ImpDrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo ); + else + { + // fallback to old polygon drawing if needed. This will really + // use ImplLineConverter, but still try to AA lines + const Polygon aToolsPolygon( rB2DPolygon ); + LineInfo aLineInfo; + if( fLineWidth != 0.0 ) + aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); + ImpDrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo ); + } } // ----------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salgdi_gdiplus.cxx b/vcl/win/source/gdi/salgdi_gdiplus.cxx index 5c00c786e22d..a9d346e74476 100644 --- a/vcl/win/source/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/source/gdi/salgdi_gdiplus.cxx @@ -62,9 +62,9 @@ // ----------------------------------------------------------------------- -void impAddB2DPolygonToGDIPlusGraphicsPath(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon) +void impAddB2DPolygonToGDIPlusGraphicsPathReal(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon, bool bNoLineJoin) { - const sal_uInt32 nCount(rPolygon.count()); + sal_uInt32 nCount(rPolygon.count()); if(nCount) { @@ -97,8 +97,58 @@ void impAddB2DPolygonToGDIPlusGraphicsPath(Gdiplus::GraphicsPath& rPath, const b if(a + 1 < nEdgeCount) { - aCurr = aNext; aFCurr = aFNext; + + if(bNoLineJoin) + { + rPath.StartFigure(); + } + } + } + } +} + +void impAddB2DPolygonToGDIPlusGraphicsPathInteger(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon, bool bNoLineJoin) +{ + sal_uInt32 nCount(rPolygon.count()); + + if(nCount) + { + const sal_uInt32 nEdgeCount(rPolygon.isClosed() ? nCount : nCount - 1); + const bool bControls(rPolygon.areControlPointsUsed()); + basegfx::B2DPoint aCurr(rPolygon.getB2DPoint(0)); + Gdiplus::Point aICurr(INT(aCurr.getX()), INT(aCurr.getY())); + + for(sal_uInt32 a(0); a < nEdgeCount; a++) + { + const sal_uInt32 nNextIndex((a + 1) % nCount); + const basegfx::B2DPoint aNext(rPolygon.getB2DPoint(nNextIndex)); + const Gdiplus::Point aINext(INT(aNext.getX()), INT(aNext.getY())); + + if(bControls && (rPolygon.isNextControlPointUsed(a) || rPolygon.isPrevControlPointUsed(nNextIndex))) + { + const basegfx::B2DPoint aCa(rPolygon.getNextControlPoint(a)); + const basegfx::B2DPoint aCb(rPolygon.getPrevControlPoint(nNextIndex)); + + rPath.AddBezier( + aICurr, + Gdiplus::Point(INT(aCa.getX()), INT(aCa.getY())), + Gdiplus::Point(INT(aCb.getX()), INT(aCb.getY())), + aINext); + } + else + { + rPath.AddLine(aICurr, aINext); + } + + if(a + 1 < nEdgeCount) + { + aICurr = aINext; + + if(bNoLineJoin) + { + rPath.StartFigure(); + } } } } @@ -123,7 +173,7 @@ bool WinSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly aPath.StartFigure(); // #i101491# not needed for first run } - impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolyPolygon.getB2DPolygon(a)); + impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolyPolygon.getB2DPolygon(a), false); aPath.CloseFigure(); } @@ -152,11 +202,16 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas Gdiplus::Color aTestColor(255, SALCOLOR_RED(maLineColor), SALCOLOR_GREEN(maLineColor), SALCOLOR_BLUE(maLineColor)); Gdiplus::Pen aTestPen(aTestColor, Gdiplus::REAL(rLineWidths.getX())); Gdiplus::GraphicsPath aPath; + bool bNoLineJoin(false); switch(eLineJoin) { default : // basegfx::B2DLINEJOIN_NONE : { + if(basegfx::fTools::more(rLineWidths.getX(), 0.0)) + { + bNoLineJoin = true; + } break; } case basegfx::B2DLINEJOIN_BEVEL : @@ -179,7 +234,14 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas } } - impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolygon); + if(nCount > 250 && basegfx::fTools::more(rLineWidths.getX(), 1.5)) + { + impAddB2DPolygonToGDIPlusGraphicsPathInteger(aPath, rPolygon, bNoLineJoin); + } + else + { + impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolygon, bNoLineJoin); + } if(rPolygon.isClosed()) { -- cgit From 5b2480b968b3f375e0d9e43becb54c6897d0820d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 15 Oct 2009 14:27:12 +0200 Subject: #i105655# commiting changes2 so far for preparing linux version --- vcl/inc/vcl/outdev.hxx | 3 + vcl/source/gdi/implncvt.cxx | 577 -------------------------------------- vcl/source/gdi/implncvt.hxx | 78 ------ vcl/source/gdi/makefile.mk | 1 - vcl/source/gdi/outdev.cxx | 256 ++++++++++------- vcl/source/gdi/pdfwriter_impl.cxx | 4 +- vcl/source/gdi/salgdilayout.cxx | 1 - vcl/unx/source/gdi/salgdi.cxx | 3 + 8 files changed, 165 insertions(+), 758 deletions(-) delete mode 100644 vcl/source/gdi/implncvt.cxx delete mode 100644 vcl/source/gdi/implncvt.hxx (limited to 'vcl') 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_vcl.hxx" -#include -#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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SV_LINECONV_HXX -#define _SV_LINECONV_HXX - -#include -#include - -// -------------------- -// - 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 #include #include -#include #include #include #include @@ -77,6 +76,8 @@ #include #include +#include + 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 #include #include - -#include "implncvt.hxx" - #include "cppuhelper/implbase1.hxx" #include +#include 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 #include #include -#include #include #include #include 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(); -- cgit From 88355430b706d2a16fef7ec237e22de946c869ae Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 22 Oct 2009 11:10:27 +0200 Subject: #i105655# most changes for MetaFile consumers done --- vcl/inc/vcl/cvtsvm.hxx | 2 + vcl/inc/vcl/lineinfo.hxx | 14 ++ vcl/source/gdi/cvtsvm.cxx | 310 +++++++++++++++++++++++++++++++--- vcl/source/gdi/lineinfo.cxx | 79 +++++++++ vcl/win/source/gdi/salgdi_gdiplus.cxx | 2 +- 5 files changed, 381 insertions(+), 26 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/vcl/cvtsvm.hxx b/vcl/inc/vcl/cvtsvm.hxx index cf4f3117a6ed..c6f4f2c9a126 100644 --- a/vcl/inc/vcl/cvtsvm.hxx +++ b/vcl/inc/vcl/cvtsvm.hxx @@ -86,6 +86,8 @@ #define GDI_UNICODE_COMMENT 1032 #define GDI_LINEJOIN_ACTION 1033 +#define GDI_EXTENDEDPOLYGON_ACTION 1034 +#define GDI_LINEDASHDOT_ACTION 1035 // ---------------- // - SVMConverter - diff --git a/vcl/inc/vcl/lineinfo.hxx b/vcl/inc/vcl/lineinfo.hxx index a57513b2826b..33758046c41e 100644 --- a/vcl/inc/vcl/lineinfo.hxx +++ b/vcl/inc/vcl/lineinfo.hxx @@ -41,6 +41,7 @@ // ---------------- class SvStream; +namespace basegfx { class B2DPolyPolygon; } struct ImplLineInfo { @@ -116,6 +117,19 @@ public: friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo ); friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo ); + + // helper to check if line width or DashDot is used + bool isDashDotOrFatLineUsed() const; + + // helper to get decomposed polygon data with the LineInfo applied. The source + // hairline polygon is given in io_rLinePolyPolygon. Both given polygons may + // contain results; e.g. when no fat line but DasDot is defined, the resut will + // be in io_rLinePolyPolygon while o_rFillPolyPolygon will be empty. When fat line + // is defined, it will be vice-versa. If none is defined, io_rLinePolyPolygon will + // not be changed (but o_rFillPolyPolygon will be freed) + void applyToB2DPolyPolygon( + basegfx::B2DPolyPolygon& io_rLinePolyPolygon, + basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const; }; #endif // _SV_LINEINFO_HXX diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 86d7d6bb39ee..27ce6630116c 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -88,18 +88,6 @@ void ImplReadPoly( SvStream& rIStm, Polygon& rPoly ) // ------------------------------------------------------------------------ -void ImplWritePoly( SvStream& rOStm, const Polygon& rPoly ) -{ - INT32 nSize = rPoly.GetSize(); - - rOStm << nSize; - - for( INT32 i = 0; i < nSize; i++ ) - rOStm << rPoly[ (USHORT) i ]; -} - -// ------------------------------------------------------------------------ - void ImplReadPolyPoly( SvStream& rIStm, PolyPolygon& rPolyPoly ) { Polygon aPoly; @@ -131,13 +119,15 @@ void ImplWritePolyPolyAction( SvStream& rOStm, const PolyPolygon& rPolyPoly ) for( n = 0; n < nPoly; n++ ) { - const Polygon& rPoly = rPolyPoly[ n ]; - const USHORT nSize = rPoly.GetSize(); + // #i102224# + Polygon aSimplePoly; + rPolyPoly[n].AdaptiveSubdivide(aSimplePoly); + const USHORT nSize(aSimplePoly.GetSize()); rOStm << (INT32) nSize; for( USHORT j = 0; j < nSize; j++ ) - rOStm << rPoly[ j ]; + rOStm << aSimplePoly[ j ]; } } @@ -378,6 +368,128 @@ void ImplSkipActions( SvStream& rIStm, ULONG nSkipCount ) } } +// ------------------------------------------------------------------------ + +bool ImplWriteExtendedPolyPolygonAction(SvStream& rOStm, const PolyPolygon& rPolyPolygon, bool bOnlyWhenCurve) +{ + const sal_uInt16 nPolygonCount(rPolyPolygon.Count()); + + if(nPolygonCount) + { + sal_uInt32 nAllPolygonCount(0); + sal_uInt32 nAllPointCount(0); + sal_uInt32 nAllFlagCount(0); + sal_uInt16 a(0); + + for(a = 0; a < nPolygonCount; a++) + { + const Polygon& rCandidate = rPolyPolygon.GetObject(a); + const sal_uInt16 nPointCount(rCandidate.GetSize()); + + if(nPointCount) + { + nAllPolygonCount++; + nAllPointCount += nPointCount; + + if(rCandidate.HasFlags()) + { + nAllFlagCount += nPointCount; + } + } + } + + if((bOnlyWhenCurve && nAllFlagCount) || (!bOnlyWhenCurve && nAllPointCount)) + { + rOStm << (INT16) GDI_EXTENDEDPOLYGON_ACTION; + + const sal_Int32 nActionSize( + 4 + // Action size + 2 + // PolygonCount + (nAllPolygonCount * 2) + // Points per polygon + (nAllPointCount << 3) + // Points themselves + nAllPolygonCount + // Bool if (when poly has points) it has flags, too + nAllFlagCount); // Flags themselves + + rOStm << nActionSize; + rOStm << (sal_uInt16)nAllPolygonCount; + + for(a = 0; a < nPolygonCount; a++) + { + const Polygon& rCandidate = rPolyPolygon.GetObject(a); + const sal_uInt16 nPointCount(rCandidate.GetSize()); + + if(nPointCount) + { + rOStm << nPointCount; + + for(sal_uInt16 b(0); b < nPointCount; b++) + { + rOStm << rCandidate[b]; + } + + if(rCandidate.HasFlags()) + { + rOStm << (BYTE)true; + + for(sal_uInt16 c(0); c < nPointCount; c++) + { + rOStm << (BYTE)rCandidate.GetFlags(c); + } + } + else + { + rOStm << (BYTE)false; + } + } + } + + return true; + } + } + + return false; +} + +// ------------------------------------------------------------------------ + +void ImplReadExtendedPolyPolygonAction(SvStream& rIStm, PolyPolygon& rPolyPoly) +{ + rPolyPoly.Clear(); + sal_uInt16 nPolygonCount(0); + rIStm >> nPolygonCount; + + for(sal_uInt16 a(0); a < nPolygonCount; a++) + { + sal_uInt16 nPointCount(0); + rIStm >> nPointCount; + Polygon aCandidate(nPointCount); + + if(nPointCount) + { + for(sal_uInt16 b(0); b < nPointCount; b++) + { + rIStm >> aCandidate[b]; + } + + BYTE bHasFlags(false); + rIStm >> bHasFlags; + + if(bHasFlags) + { + BYTE aPolyFlags(0); + + for(sal_uInt16 c(0); c < nPointCount; c++) + { + rIStm >> aPolyFlags; + aCandidate.SetFlags(c, (PolyFlags)aPolyFlags); + } + } + } + + rPolyPoly.Insert(aCandidate); + } +} + // ---------------- // - SVMConverter - // ---------------- @@ -450,6 +562,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.SetPrefSize( aPrefSz ); rMtf.SetPrefMapMode( aMapMode ); + sal_uInt32 nLastPolygonAction(0); for( INT32 i = 0L; i < nActions; i++ ) { @@ -491,6 +604,91 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } break; + case (GDI_LINEDASHDOT_ACTION) : + { + INT16 a(0); + INT32 b(0); + + rIStm >> a; aLineInfo.SetDashCount(a); + rIStm >> b; aLineInfo.SetDashLen(b); + rIStm >> a; aLineInfo.SetDotCount(a); + rIStm >> b; aLineInfo.SetDotLen(b); + rIStm >> b; aLineInfo.SetDistance(b); + + if(((aLineInfo.GetDashCount() && aLineInfo.GetDashLen()) + || (aLineInfo.GetDotCount() && aLineInfo.GetDotLen())) + && aLineInfo.GetDistance()) + { + aLineInfo.SetStyle(LINE_DASH); + } + } + break; + + case (GDI_EXTENDEDPOLYGON_ACTION) : + { + // read the PolyPolygon in every case + PolyPolygon aInputPolyPolygon; + ImplReadExtendedPolyPolygonAction(rIStm, aInputPolyPolygon); + + // now check if it can be set somewhere + if(nLastPolygonAction < rMtf.GetActionCount()) + { + MetaPolyLineAction* pPolyLineAction = dynamic_cast< MetaPolyLineAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolyLineAction) + { + // replace MetaPolyLineAction when we have a single polygon. Do not rely on the + // same point count; the originally written GDI_POLYLINE_ACTION may have been + // Subdivided for better quality for older usages + if(1 == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolyLineAction( + aInputPolyPolygon.GetObject(0), + pPolyLineAction->GetLineInfo()), + nLastPolygonAction); + pPolyLineAction->Delete(); + } + } + else + { + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast< MetaPolyPolygonAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolyPolygonAction) + { + // replace MetaPolyPolygonAction when we have a curved polygon. Do rely on the + // same sub-polygon count + if(pPolyPolygonAction->GetPolyPolygon().Count() == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolyPolygonAction( + aInputPolyPolygon), + nLastPolygonAction); + pPolyPolygonAction->Delete(); + } + } + else + { + MetaPolygonAction* pPolygonAction = dynamic_cast< MetaPolygonAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolygonAction) + { + // replace MetaPolygonAction + if(1 == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolygonAction( + aInputPolyPolygon.GetObject(0)), + nLastPolygonAction); + pPolygonAction->Delete(); + } + } + } + } + } + } + break; + case( GDI_RECT_ACTION ): { ImplReadRect( rIStm, aRect ); @@ -581,6 +779,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) case( GDI_POLYLINE_ACTION ): { ImplReadPoly( rIStm, aActionPoly ); + nLastPolygonAction = rMtf.GetActionCount(); if( bFatLine ) rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) ); @@ -602,7 +801,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) ); } else + { + nLastPolygonAction = rMtf.GetActionCount(); rMtf.AddAction( new MetaPolygonAction( aActionPoly ) ); + } } break; @@ -623,7 +825,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPolyLineAction( aPolyPoly[ nPoly ], aLineInfo ) ); } else + { + nLastPolygonAction = rMtf.GetActionCount(); rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) ); + } } break; @@ -1257,6 +1462,7 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, const LineInfo& rInfo = pAct->GetLineInfo(); const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); + const bool bLineDashDot(LINE_DASH == rInfo.GetStyle()); if( bFatLine ) { @@ -1269,6 +1475,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); + } } rOStm << (INT16) GDI_LINE_ACTION; @@ -1286,6 +1503,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + + if(bLineDashDot) + { + nCount += 1; + } } } break; @@ -1366,19 +1588,21 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, for( USHORT n = 0; n < nPoints; n++ ) rOStm << aChordPoly[ n ]; - nCount++; } break; case( META_POLYLINE_ACTION ): { + // #i102224# MetaPolyLineAction* pAct = (MetaPolyLineAction*) pAction; - const Polygon& rPoly = pAct->GetPolygon(); - const LineInfo& rInfo = pAct->GetLineInfo(); - const USHORT nPoints = rPoly.GetSize(); + Polygon aSimplePoly; + pAct->GetPolygon().AdaptiveSubdivide(aSimplePoly); + const LineInfo& rInfo = pAct->GetLineInfo(); + const USHORT nPoints(aSimplePoly.GetSize()); const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); + const bool bLineDashDot(LINE_DASH == rInfo.GetStyle()); if( bFatLine ) { @@ -1391,6 +1615,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); + } } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1398,10 +1633,18 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) nPoints; for( USHORT n = 0; n < nPoints; n++ ) - rOStm << rPoly[ n ]; + { + rOStm << aSimplePoly[ n ]; + } nCount++; + const PolyPolygon aPolyPolygon(pAct->GetPolygon()); + if(ImplWriteExtendedPolyPolygonAction(rOStm, aPolyPolygon, true)) + { + nCount++; + } + if( bFatLine ) { ImplWritePopAction( rOStm ); @@ -1411,24 +1654,36 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + + if(bLineDashDot) + { + nCount += 1; + } } } break; case( META_POLYGON_ACTION ): { - MetaPolygonAction* pAct = (MetaPolygonAction*) pAction; - const Polygon& rPoly = pAct->GetPolygon(); - const USHORT nPoints = rPoly.GetSize(); + // #i102224# + MetaPolygonAction* pAct = (MetaPolygonAction*)pAction; + Polygon aSimplePoly; + pAct->GetPolygon().AdaptiveSubdivide(aSimplePoly); + const USHORT nPoints(aSimplePoly.GetSize()); rOStm << (INT16) GDI_POLYGON_ACTION; rOStm << (INT32) ( 8 + ( nPoints << 3 ) ); rOStm << (INT32) nPoints; for( USHORT n = 0; n < nPoints; n++ ) - rOStm << rPoly[ n ]; - + rOStm << aSimplePoly[ n ]; nCount++; + + const PolyPolygon aPolyPolygon(pAct->GetPolygon()); + if(ImplWriteExtendedPolyPolygonAction(rOStm, aPolyPolygon, true)) + { + nCount++; + } } break; @@ -1437,6 +1692,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, MetaPolyPolygonAction* pAct = (MetaPolyPolygonAction*) pAction; ImplWritePolyPolyAction( rOStm, pAct->GetPolyPolygon() ); nCount++; + + if(ImplWriteExtendedPolyPolygonAction(rOStm, pAct->GetPolyPolygon(), true)) + { + nCount++; + } } break; diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx index 85a48f2b0f5e..7aa50811106b 100644 --- a/vcl/source/gdi/lineinfo.cxx +++ b/vcl/source/gdi/lineinfo.cxx @@ -34,6 +34,10 @@ #include #include #include +#include +#include +#include +#include DBG_NAME( LineInfo ) @@ -283,3 +287,78 @@ SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo ) { return( rOStm << *rLineInfo.mpImplLineInfo ); } + +// ----------------------------------------------------------------------- + +bool LineInfo::isDashDotOrFatLineUsed() const +{ + return (LINE_DASH == GetStyle() || GetWidth() > 1); +} + +// ----------------------------------------------------------------------- + +void LineInfo::applyToB2DPolyPolygon( + basegfx::B2DPolyPolygon& io_rLinePolyPolygon, + basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const +{ + o_rFillPolyPolygon.clear(); + + if(io_rLinePolyPolygon.count()) + { + if(LINE_DASH == GetStyle()) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(GetDashLen()); + const double fDotLen(GetDotLen()); + const double fDistance(GetDistance()); + + for(sal_uInt16 a(0); a < GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } + + for(sal_uInt16 b(0); b < 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 < io_rLinePolyPolygon.count(); c++) + { + basegfx::B2DPolyPolygon aLineTraget; + basegfx::tools::applyLineDashing( + io_rLinePolyPolygon.getB2DPolygon(c), + fDotDashArray, + &aLineTraget); + aResult.append(aLineTraget); + } + + io_rLinePolyPolygon = aResult; + } + } + + if(GetWidth() > 1 && io_rLinePolyPolygon.count()) + { + const double fHalfLineWidth((GetWidth() * 0.5) + 0.5); + + for(sal_uInt32 a(0); a < io_rLinePolyPolygon.count(); a++) + { + o_rFillPolyPolygon.append(basegfx::tools::createAreaGeometry( + io_rLinePolyPolygon.getB2DPolygon(a), + fHalfLineWidth, + GetLineJoin())); + } + + io_rLinePolyPolygon.clear(); + } + } +} + +// ----------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salgdi_gdiplus.cxx b/vcl/win/source/gdi/salgdi_gdiplus.cxx index a9d346e74476..29e4ff1d801e 100644 --- a/vcl/win/source/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/source/gdi/salgdi_gdiplus.cxx @@ -243,7 +243,7 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolygon, bNoLineJoin); } - if(rPolygon.isClosed()) + if(rPolygon.isClosed() && !bNoLineJoin) { // #i101491# needed to create the correct line joins aPath.CloseFigure(); -- cgit From 5de3269dcd48cd653837de3d576d7be3df679927 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 22 Oct 2009 13:19:51 +0200 Subject: #i105655# Last MetaFile changes; moved GDI_LINEDASHDOT_ACTION to the more common part in SVM export to also have it available for non-fat lines --- vcl/source/gdi/cvtsvm.cxx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'vcl') diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 27ce6630116c..07b1a391adf4 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -1615,17 +1615,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + } - if(bLineDashDot) - { - rOStm << (INT16) GDI_LINEDASHDOT_ACTION; - rOStm << (INT32) 4 + 16; - rOStm << (INT16)rInfo.GetDashCount(); - rOStm << (INT32)rInfo.GetDashLen(); - rOStm << (INT16)rInfo.GetDotCount(); - rOStm << (INT32)rInfo.GetDotLen(); - rOStm << (INT32)rInfo.GetDistance(); - } + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1654,11 +1654,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + } - if(bLineDashDot) - { - nCount += 1; - } + if(bLineDashDot) + { + nCount += 1; } } break; -- cgit From d12dff9041a47602e6a655a67dacddcfd9cbe86b Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 12 Nov 2009 11:26:43 +0100 Subject: aw078 #i106541# commited in-between stable version with already advanced metafile decomposition for security reasons --- vcl/source/gdi/metaact.cxx | 77 ++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 33 deletions(-) (limited to 'vcl') diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 4fe9a41be797..0587e661b7e8 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -52,14 +52,6 @@ inline void ImplScalePoint( Point& rPt, double fScaleX, double fScaleY ) // ------------------------------------------------------------------------ -inline void ImplScaleSize( Size& rSz, double fScaleX, double fScaleY ) -{ - rSz.Width() = FRound( fScaleX * rSz.Width() ); - rSz.Height() = FRound( fScaleY * rSz.Height() ); -} - -// ------------------------------------------------------------------------ - inline void ImplScaleRect( Rectangle& rRect, double fScaleX, double fScaleY ) { Point aTL( rRect.TopLeft() ); @@ -69,6 +61,7 @@ inline void ImplScaleRect( Rectangle& rRect, double fScaleX, double fScaleY ) ImplScalePoint( aBR, fScaleX, fScaleY ); rRect = Rectangle( aTL, aBR ); + rRect.Justify(); } // ------------------------------------------------------------------------ @@ -85,7 +78,7 @@ inline void ImplScaleLineInfo( LineInfo& rLineInfo, double fScaleX, double fScal { if( !rLineInfo.IsDefault() ) { - const double fScale = ( fScaleX + fScaleY ) * 0.5; + const double fScale = ( fabs(fScaleX) + fabs(fScaleY) ) * 0.5; rLineInfo.SetWidth( FRound( fScale * rLineInfo.GetWidth() ) ); rLineInfo.SetDashLen( FRound( fScale * rLineInfo.GetDashLen() ) ); @@ -598,8 +591,8 @@ void MetaRoundRectAction::Move( long nHorzMove, long nVertMove ) void MetaRoundRectAction::Scale( double fScaleX, double fScaleY ) { ImplScaleRect( maRect, fScaleX, fScaleY ); - mnHorzRound = FRound( mnHorzRound * fScaleX ); - mnVertRound = FRound( mnVertRound * fScaleY ); + mnHorzRound = FRound( mnHorzRound * fabs(fScaleX) ); + mnVertRound = FRound( mnVertRound * fabs(fScaleY) ); } // ------------------------------------------------------------------------ @@ -1396,7 +1389,7 @@ void MetaTextArrayAction::Scale( double fScaleX, double fScaleY ) if ( mpDXAry && mnLen ) { for ( USHORT i = 0, nCount = mnLen; i < nCount; i++ ) - mpDXAry[ i ] = FRound( mpDXAry[ i ] * fScaleX ); + mpDXAry[ i ] = FRound( mpDXAry[ i ] * fabs(fScaleX) ); } } @@ -1524,7 +1517,7 @@ void MetaStretchTextAction::Move( long nHorzMove, long nVertMove ) void MetaStretchTextAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPt, fScaleX, fScaleY ); - mnWidth = (ULONG)FRound( mnWidth * fScaleX ); + mnWidth = (ULONG)FRound( mnWidth * fabs(fScaleX) ); } // ------------------------------------------------------------------------ @@ -1717,7 +1710,7 @@ void MetaTextLineAction::Move( long nHorzMove, long nVertMove ) void MetaTextLineAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPos, fScaleX, fScaleY ); - mnWidth = FRound( mnWidth * fScaleX ); + mnWidth = FRound( mnWidth * fabs(fScaleX) ); } // ------------------------------------------------------------------------ @@ -1876,8 +1869,10 @@ void MetaBmpScaleAction::Move( long nHorzMove, long nVertMove ) void MetaBmpScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -1953,8 +1948,10 @@ void MetaBmpScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaBmpScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2099,8 +2096,10 @@ void MetaBmpExScaleAction::Move( long nHorzMove, long nVertMove ) void MetaBmpExScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2176,8 +2175,10 @@ void MetaBmpExScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaBmpExScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2328,8 +2329,10 @@ void MetaMaskScaleAction::Move( long nHorzMove, long nVertMove ) void MetaMaskScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2408,8 +2411,10 @@ void MetaMaskScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaMaskScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -3486,9 +3491,9 @@ MetaAction* MetaFontAction::Clone() void MetaFontAction::Scale( double fScaleX, double fScaleY ) { - Size aSize( maFont.GetSize() ); - - ImplScaleSize( aSize, fScaleX, fScaleY ); + const Size aSize( + FRound(maFont.GetSize().Width() * fabs(fScaleX)), + FRound(maFont.GetSize().Height() * fabs(fScaleY))); maFont.SetSize( aSize ); } @@ -3766,14 +3771,18 @@ MetaAction* MetaFloatTransparentAction::Clone() void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove ) { maPoint.Move( nHorzMove, nVertMove ); + maMtf.Move(nHorzMove, nVertMove); } // ------------------------------------------------------------------------ void MetaFloatTransparentAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPoint, fScaleX, fScaleY ); - ImplScaleSize( maSize, fScaleX, fScaleY ); + Rectangle aRectangle(maPoint, maSize); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPoint = aRectangle.TopLeft(); + maSize = aRectangle.GetSize(); + maMtf.Scale(fScaleX, fScaleY); } // ------------------------------------------------------------------------ @@ -3847,8 +3856,10 @@ void MetaEPSAction::Move( long nHorzMove, long nVertMove ) void MetaEPSAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPoint, fScaleX, fScaleY ); - ImplScaleSize( maSize, fScaleX, fScaleY ); + Rectangle aRectangle(maPoint, maSize); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPoint = aRectangle.TopLeft(); + maSize = aRectangle.GetSize(); } // ------------------------------------------------------------------------ -- cgit From d1eb6b5cb7482385397f03b56ef396905c5490e5 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 18 Nov 2009 13:08:25 +0100 Subject: aw078: changes after resync to DEV300m64 --- vcl/aqua/source/gdi/salgdi.cxx | 1 + vcl/source/gdi/bitmapex.cxx | 2 +- vcl/source/glyphs/gcach_ftyp.cxx | 1 + vcl/unx/source/gdi/salgdi.cxx | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 8d57d56a3667..f38b9852e57e 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -54,6 +54,7 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolygontools.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include using namespace vcl; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 6626a12d29a2..4e2ed20a7966 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -785,7 +785,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if(pRead) { - const Color aColor(Color(pRead->GetColor(nY, nX))); + const Color aColor = pRead->GetColor(nY, nX); // if color is not equal to TransparentColor, we are not transparent if(aColor != aTransparentColor) diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index 820f3f0d74a9..c782366928db 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -43,6 +43,7 @@ #include "tools/poly.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "basegfx/polygon/b2dpolypolygon.hxx" #include "osl/file.hxx" diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index bfc5aa9d66f4..5bf8b63dc6e2 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -50,6 +50,7 @@ #include "basegfx/polygon/b2dpolygonclipper.hxx" #include "basegfx/polygon/b2dlinegeometry.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "basegfx/polygon/b2dpolypolygoncutter.hxx" #include -- cgit From a3235d7e7a5b59fc8af646867766ad807da0c78e Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 23 Nov 2009 12:30:29 +0100 Subject: aw078: #i106541# MetaTextRectAction implementation added, corrected/changed FontHandling when no FontSize is given --- vcl/inc/vcl/outdev.hxx | 7 ++++++- vcl/source/gdi/outdev6.cxx | 14 +++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'vcl') diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index f824151737d2..464b129fdb64 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -1104,7 +1104,12 @@ public: */ BOOL HasAlpha(); - void DrawEPS( const Point& rPt, const Size& rSz, + /** Added return value to see if EPS could be painted directly. + Theoreticaly, handing over a matrix would be needed to handle + painting rotated EPS files (e.g. contained mín Metafiles). This + would then need to be supported for Mac and PS printers, but + that's too much for now, wrote #i107046# for this */ + bool DrawEPS( const Point& rPt, const Size& rSz, const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL ); /// request XCanvas render interface for this OutputDevice diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index 79986988afd7..2d436ea43659 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -1158,9 +1158,11 @@ void OutputDevice::ImplDraw2ColorFrame( const Rectangle& rRect, // ----------------------------------------------------------------------- -void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, +bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, const GfxLink& rGfxLink, GDIMetaFile* pSubst ) { + bool bDrawn(true); + if ( mpMetaFile ) { GDIMetaFile aSubst; @@ -1172,20 +1174,20 @@ void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, } if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) - return; + return bDrawn; if( mbOutputClipped ) - return; + return bDrawn; Rectangle aRect( ImplLogicToDevicePixel( Rectangle( rPoint, rSize ) ) ); + if( !aRect.IsEmpty() ) { // draw the real EPS graphics - bool bDrawn = FALSE; if( rGfxLink.GetData() && rGfxLink.GetDataSize() ) { if( !mpGraphics && !ImplGetGraphics() ) - return; + return bDrawn; if( mbInitClipRegion ) ImplInitClipRegion(); @@ -1208,4 +1210,6 @@ void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, if( mpAlphaVDev ) mpAlphaVDev->DrawEPS( rPoint, rSize, rGfxLink, pSubst ); + + return bDrawn; } -- cgit From 3b790d2e0926c75a8a919e02bfad05d1b1aff800 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 3 Dec 2009 12:33:17 +0100 Subject: aw078: corrected small VCL Linux error for non-AA cases --- vcl/source/gdi/outdev.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 7352f5ed45d9..8b20c8e384f7 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2653,7 +2653,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo) { - const USHORT nPoints(rPoly.GetSize()); + USHORT nPoints(rPoly.GetSize()); if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() ) return; @@ -2698,6 +2698,15 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI } else { + // #100127# the subdivision HAS to be done here since only a pointer + // to an array of points is given to the DrawPolyLine method, there is + // NO way to find out there that it's a curve. + if( aPoly.HasFlags() ) + { + aPoly = ImplSubdivideBezier( aPoly ); + nPoints = aPoly.GetSize(); + } + mpGraphics->DrawPolyLine(nPoints, (const SalPoint*)aPoly.GetConstPointAry(), this); } -- cgit From 9afae518759e5d6ecb32dacd76a1aa746ae2cef6 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 28 Dec 2009 20:17:11 +0100 Subject: aw078: changes after resync --- vcl/source/gdi/makefile.mk | 1 - 1 file changed, 1 deletion(-) (limited to 'vcl') diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index ae90d5bd1461..e253f83b25ab 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -100,7 +100,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/impbmp.obj \ $(SLO)$/imagerepository.obj \ $(SLO)$/impvect.obj \ - $(SLO)$/jobset.obj \ $(SLO)$/lineinfo.obj \ $(SLO)$/mapmod.obj \ $(SLO)$/metaact.obj \ -- cgit