diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-04-27 05:07:47 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-04-27 05:08:13 -0500 |
commit | 5994d609392b34b185daab53a99be1a16f2ee143 (patch) | |
tree | 679f728da4f7bc68f680177210d7693d86ec8bfd /vcl/source/outdev | |
parent | f5fb361df94449850a83be3b412f68e1f9b949c5 (diff) |
vcl/outdev/*.cxx cosmetic clean-up
Change-Id: I967a50cf4fdde87efbcec990eab4f68570f27b94
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r-- | vcl/source/outdev/pixel.cxx | 43 | ||||
-rw-r--r-- | vcl/source/outdev/polygon.cxx | 180 | ||||
-rw-r--r-- | vcl/source/outdev/polyline.cxx | 130 | ||||
-rw-r--r-- | vcl/source/outdev/rect.cxx | 33 | ||||
-rw-r--r-- | vcl/source/outdev/textline.cxx | 537 | ||||
-rw-r--r-- | vcl/source/outdev/transparent.cxx | 178 | ||||
-rw-r--r-- | vcl/source/outdev/wallpaper.cxx | 148 |
7 files changed, 659 insertions, 590 deletions
diff --git a/vcl/source/outdev/pixel.cxx b/vcl/source/outdev/pixel.cxx index edb828007934..aeb34e8810ca 100644 --- a/vcl/source/outdev/pixel.cxx +++ b/vcl/source/outdev/pixel.cxx @@ -16,16 +16,15 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> +#include <boost/scoped_array.hpp> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> #include <vcl/window.hxx> -#include <salgdi.hxx> - -#include <outdata.hxx> - -#include <boost/scoped_array.hpp> +#include "outdata.hxx" +#include "salgdi.hxx" extern const sal_uLong nVCLRLut[ 6 ]; extern const sal_uLong nVCLGLut[ 6 ]; @@ -45,9 +44,9 @@ Color OutputDevice::GetPixel( const Point& rPt ) const if ( !mbOutputClipped ) { - const long nX = ImplLogicXToDevicePixel( rPt.X() ); - const long nY = ImplLogicYToDevicePixel( rPt.Y() ); - const SalColor aSalCol = mpGraphics->GetPixel( nX, nY, this ); + const long nX = ImplLogicXToDevicePixel( rPt.X() ); + const long nY = ImplLogicYToDevicePixel( rPt.Y() ); + const SalColor aSalCol = mpGraphics->GetPixel( nX, nY, this ); aColor.SetRed( SALCOLOR_RED( aSalCol ) ); aColor.SetGreen( SALCOLOR_GREEN( aSalCol ) ); aColor.SetBlue( SALCOLOR_BLUE( aSalCol ) ); @@ -67,14 +66,12 @@ void OutputDevice::DrawPixel( const Point& rPt ) Point aPt = ImplLogicToDevicePixel( rPt ); - if ( !mpGraphics ) - { - if ( !AcquireGraphics() ) - return; - } + if ( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; @@ -100,14 +97,12 @@ void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor ) Point aPt = ImplLogicToDevicePixel( rPt ); - if ( !mpGraphics ) - { - if ( !AcquireGraphics() ) - return; - } + if ( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; @@ -120,7 +115,9 @@ void OutputDevice::DrawPixel( const Point& rPt, const Color& rColor ) void OutputDevice::DrawPixel( const Polygon& rPts, const Color* pColors ) { if ( !pColors ) + { DrawPixel( rPts, GetLineColor() ); + } else { DBG_ASSERT( pColors, "OutputDevice::DrawPixel: No color array specified" ); @@ -130,9 +127,12 @@ void OutputDevice::DrawPixel( const Polygon& rPts, const Color* pColors ) if ( nSize ) { if ( mpMetaFile ) + { for ( sal_uInt16 i = 0; i < nSize; i++ ) + { mpMetaFile->AddAction( new MetaPixelAction( rPts[ i ], pColors[ i ] ) ); - + } + } if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) return; @@ -161,12 +161,13 @@ void OutputDevice::DrawPixel( const Polygon& rPts, const Color& rColor ) { if( rColor != COL_TRANSPARENT && ! ImplIsRecordLayout() ) { - const sal_uInt16 nSize = rPts.GetSize(); + const sal_uInt16 nSize = rPts.GetSize(); boost::scoped_array<Color> pColArray(new Color[ nSize ]); for( sal_uInt16 i = 0; i < nSize; i++ ) + { pColArray[ i ] = rColor; - + } DrawPixel( rPts, pColArray.get() ); } diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx index 894c4e3cd6d5..5dc154e50751 100644 --- a/vcl/source/outdev/polygon.cxx +++ b/vcl/source/outdev/polygon.cxx @@ -16,19 +16,18 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <boost/scoped_array.hpp> #include <tools/poly.hxx> - -#include <vcl/virdev.hxx> #include <vcl/outdev.hxx> +#include <vcl/virdev.hxx> #include "salgdi.hxx" -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> - -#include <boost/scoped_array.hpp> #define OUTDEV_POLYPOLY_STACKBUF 32 @@ -44,25 +43,26 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) return; // we need a graphics - if ( !mpGraphics ) - if ( !AcquireGraphics() ) + if ( !mpGraphics && !AcquireGraphics() ) return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; if ( mbInitLineColor ) InitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); // use b2dpolygon drawing if possible - if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && (IsLineColor() || IsFillColor())) + if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + (IsLineColor() || IsFillColor())) { const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPoly.getB2DPolyPolygon()); @@ -88,13 +88,12 @@ void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly ) for(sal_uInt32 a(0); bSuccess && a < aB2DPolyPolygon.count(); a++) { - bSuccess = mpGraphics->DrawPolyLine( - aB2DPolyPolygon.getB2DPolygon(a), - 0.0, - aB2DLineWidth, - basegfx::B2DLINEJOIN_NONE, - css::drawing::LineCap_BUTT, - this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), + 0.0, + aB2DLineWidth, + basegfx::B2DLINEJOIN_NONE, + css::drawing::LineCap_BUTT, + this); } } @@ -151,25 +150,26 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly ) return; // we need a graphics - if ( !mpGraphics ) - if ( !AcquireGraphics() ) - return; + if ( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; if ( mbInitLineColor ) InitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); // use b2dpolygon drawing if possible - if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && (IsLineColor() || IsFillColor())) + if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + (IsLineColor() || IsFillColor())) { const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); basegfx::B2DPolygon aB2DPolygon(rPoly.getB2DPolygon()); @@ -193,13 +193,12 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly ) aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon); } - bSuccess = mpGraphics->DrawPolyLine( - aB2DPolygon, - 0.0, - aB2DLineWidth, - basegfx::B2DLINEJOIN_NONE, - css::drawing::LineCap_BUTT, - this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolygon, + 0.0, + aB2DLineWidth, + basegfx::B2DLINEJOIN_NONE, + css::drawing::LineCap_BUTT, + this); } if(bSuccess) @@ -251,24 +250,25 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP return; // we need a graphics - if( !mpGraphics ) - if( !AcquireGraphics() ) - return; + if( !mpGraphics && !AcquireGraphics() ) + return; if( mbInitClipRegion ) InitClipRegion(); + if( mbOutputClipped ) return; if( mbInitLineColor ) InitLineColor(); + if( mbInitFillColor ) ImplInitFillColor(); - if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && (IsLineColor() || IsFillColor())) + if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + (IsLineColor() || IsFillColor())) { const basegfx::B2DHomMatrix aTransform(ImplGetDeviceTransformation()); basegfx::B2DPolyPolygon aB2DPolyPolygon(rB2DPolyPoly); @@ -294,13 +294,12 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP for(sal_uInt32 a(0);bSuccess && a < aB2DPolyPolygon.count(); a++) { - bSuccess = mpGraphics->DrawPolyLine( - aB2DPolyPolygon.getB2DPolygon(a), - 0.0, - aB2DLineWidth, - basegfx::B2DLINEJOIN_NONE, - css::drawing::LineCap_BUTT, - this); + bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), + 0.0, + aB2DLineWidth, + basegfx::B2DLINEJOIN_NONE, + css::drawing::LineCap_BUTT, + this); } } @@ -323,14 +322,16 @@ void OutputDevice::ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPo if(!nPoly) return; - sal_uInt32 aStackAry1[OUTDEV_POLYPOLY_STACKBUF]; - PCONSTSALPOINT aStackAry2[OUTDEV_POLYPOLY_STACKBUF]; - sal_uInt8* aStackAry3[OUTDEV_POLYPOLY_STACKBUF]; - sal_uInt32* pPointAry; + sal_uInt32 aStackAry1[OUTDEV_POLYPOLY_STACKBUF]; + PCONSTSALPOINT aStackAry2[OUTDEV_POLYPOLY_STACKBUF]; + sal_uInt8* aStackAry3[OUTDEV_POLYPOLY_STACKBUF]; + sal_uInt32* pPointAry; PCONSTSALPOINT* pPointAryAry; - const sal_uInt8** pFlagAryAry; - sal_uInt16 i = 0, j = 0, last = 0; - bool bHaveBezier = false; + const sal_uInt8** pFlagAryAry; + sal_uInt16 i = 0; + sal_uInt16 j = 0; + sal_uInt16 last = 0; + bool bHaveBezier = false; if ( nPoly > OUTDEV_POLYPOLY_STACKBUF ) { pPointAry = new sal_uInt32[nPoly]; @@ -343,23 +344,23 @@ void OutputDevice::ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPo pPointAryAry = aStackAry2; pFlagAryAry = (const sal_uInt8**)aStackAry3; } + do { - const Polygon& rPoly = rPolyPoly.GetObject( i ); - sal_uInt16 nSize = rPoly.GetSize(); + const Polygon& rPoly = rPolyPoly.GetObject( i ); + sal_uInt16 nSize = rPoly.GetSize(); if ( nSize ) { - pPointAry[j] = nSize; + pPointAry[j] = nSize; pPointAryAry[j] = (PCONSTSALPOINT)rPoly.GetConstPointAry(); - pFlagAryAry[j] = rPoly.GetConstFlagAry(); - last = i; + pFlagAryAry[j] = rPoly.GetConstFlagAry(); + last = i; if( pFlagAryAry[j] ) bHaveBezier = true; ++j; } - ++i; } while ( i < nPoly ); @@ -408,7 +409,9 @@ void OutputDevice::ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPo void OutputDevice::ImplDrawPolygon( const Polygon& rPoly, const PolyPolygon* pClipPolyPoly ) { if( pClipPolyPoly ) + { ImplDrawPolyPolygon( rPoly, pClipPolyPoly ); + } else { sal_uInt16 nPoints = rPoly.GetSize(); @@ -431,12 +434,13 @@ void OutputDevice::ImplDrawPolyPolygon( const PolyPolygon& rPolyPoly, const Poly rPolyPoly.GetIntersection( *pClipPolyPoly, *pPolyPoly ); } else + { pPolyPoly = (PolyPolygon*) &rPolyPoly; - + } if( pPolyPoly->Count() == 1 ) { - const Polygon rPoly = pPolyPoly->GetObject( 0 ); - sal_uInt16 nSize = rPoly.GetSize(); + const Polygon rPoly = pPolyPoly->GetObject( 0 ); + sal_uInt16 nSize = rPoly.GetSize(); if( nSize >= 2 ) { @@ -446,17 +450,17 @@ void OutputDevice::ImplDrawPolyPolygon( const PolyPolygon& rPolyPoly, const Poly } else if( pPolyPoly->Count() ) { - sal_uInt16 nCount = pPolyPoly->Count(); + sal_uInt16 nCount = pPolyPoly->Count(); boost::scoped_array<sal_uInt32> pPointAry(new sal_uInt32[nCount]); boost::scoped_array<PCONSTSALPOINT> pPointAryAry(new PCONSTSALPOINT[nCount]); - sal_uInt16 i = 0; + sal_uInt16 i = 0; do { - const Polygon& rPoly = pPolyPoly->GetObject( i ); - sal_uInt16 nSize = rPoly.GetSize(); + const Polygon& rPoly = pPolyPoly->GetObject( i ); + sal_uInt16 nSize = rPoly.GetSize(); if ( nSize ) { - pPointAry[i] = nSize; + pPointAry[i] = nSize; pPointAryAry[i] = (PCONSTSALPOINT)rPoly.GetConstPointAry(); i++; } @@ -493,28 +497,30 @@ void OutputDevice::DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLon if( mbOutputClipped ) return; - const long nDistX = std::max( rDist.Width(), 1L ); - const long nDistY = std::max( rDist.Height(), 1L ); - long nX = ( rRect.Left() >= aDstRect.Left() ) ? rRect.Left() : ( rRect.Left() + ( ( aDstRect.Left() - rRect.Left() ) / nDistX ) * nDistX ); - long nY = ( rRect.Top() >= aDstRect.Top() ) ? rRect.Top() : ( rRect.Top() + ( ( aDstRect.Top() - rRect.Top() ) / nDistY ) * nDistY ); - const long nRight = aDstRect.Right(); - const long nBottom = aDstRect.Bottom(); - const long nStartX = ImplLogicXToDevicePixel( nX ); - const long nEndX = ImplLogicXToDevicePixel( nRight ); - const long nStartY = ImplLogicYToDevicePixel( nY ); - const long nEndY = ImplLogicYToDevicePixel( nBottom ); - long nHorzCount = 0L; - long nVertCount = 0L; - - ::com::sun::star::uno::Sequence< sal_Int32 > aVertBuf; - ::com::sun::star::uno::Sequence< sal_Int32 > aHorzBuf; + const long nDistX = std::max( rDist.Width(), 1L ); + const long nDistY = std::max( rDist.Height(), 1L ); + long nX = ( rRect.Left() >= aDstRect.Left() ) ? rRect.Left() : ( rRect.Left() + ( ( aDstRect.Left() - rRect.Left() ) / nDistX ) * nDistX ); + long nY = ( rRect.Top() >= aDstRect.Top() ) ? rRect.Top() : ( rRect.Top() + ( ( aDstRect.Top() - rRect.Top() ) / nDistY ) * nDistY ); + const long nRight = aDstRect.Right(); + const long nBottom = aDstRect.Bottom(); + const long nStartX = ImplLogicXToDevicePixel( nX ); + const long nEndX = ImplLogicXToDevicePixel( nRight ); + const long nStartY = ImplLogicYToDevicePixel( nY ); + const long nEndY = ImplLogicYToDevicePixel( nBottom ); + long nHorzCount = 0L; + long nVertCount = 0L; + + css::uno::Sequence< sal_Int32 > aVertBuf; + css::uno::Sequence< sal_Int32 > aHorzBuf; if( ( nFlags & GRID_DOTS ) || ( nFlags & GRID_HORZLINES ) ) { aVertBuf.realloc( aDstRect.GetHeight() / nDistY + 2L ); aVertBuf[ nVertCount++ ] = nStartY; while( ( nY += nDistY ) <= nBottom ) + { aVertBuf[ nVertCount++ ] = ImplLogicYToDevicePixel( nY ); + } } if( ( nFlags & GRID_DOTS ) || ( nFlags & GRID_VERTLINES ) ) @@ -522,7 +528,9 @@ void OutputDevice::DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLon aHorzBuf.realloc( aDstRect.GetWidth() / nDistX + 2L ); aHorzBuf[ nHorzCount++ ] = nStartX; while( ( nX += nDistX ) <= nRight ) + { aHorzBuf[ nHorzCount++ ] = ImplLogicXToDevicePixel( nX ); + } } if( mbInitLineColor ) @@ -537,8 +545,12 @@ void OutputDevice::DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLon if( nFlags & GRID_DOTS ) { for( long i = 0L; i < nVertCount; i++ ) + { for( long j = 0L, Y = aVertBuf[ i ]; j < nHorzCount; j++ ) + { mpGraphics->DrawPixel( aHorzBuf[ j ], Y, this ); + } + } } else { diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx index e54dd0089dd0..2ddb191aa749 100644 --- a/vcl/source/outdev/polyline.cxx +++ b/vcl/source/outdev/polyline.cxx @@ -16,17 +16,18 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include <vcl/virdev.hxx> -#include <vcl/outdev.hxx> -#include <vcl/settings.hxx> - -#include <salgdi.hxx> +#include <sal/types.h> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dlinegeometry.hxx> +#include <vcl/outdev.hxx> +#include <vcl/virdev.hxx> +#include <vcl/settings.hxx> + +#include "salgdi.hxx" + void OutputDevice::DrawPolyLine( const Polygon& rPoly ) { @@ -39,22 +40,22 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) return; // we need a graphics - if ( !mpGraphics ) - if ( !AcquireGraphics() ) - return; + if ( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; if ( mbInitLineColor ) InitLineColor(); - const bool bTryAA( (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsLineColor()); + const bool bTryAA( (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + IsLineColor()); // use b2dpolygon drawing if possible if(bTryAA) @@ -73,7 +74,8 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) aB2DPolyLine = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyLine); } - if(mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, css::drawing::LineCap_BUTT, this)) + if(mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, + basegfx::B2DLINEJOIN_NONE, css::drawing::LineCap_BUTT, this)) { return; } @@ -114,8 +116,8 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo // #i101491# // Try direct Fallback to B2D-Version of DrawPolyLine - if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && LINE_SOLID == rLineInfo.GetStyle()) + if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + LINE_SOLID == rLineInfo.GetStyle()) { DrawPolyLine( rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin(), rLineInfo.GetLineCap()); return; @@ -127,11 +129,10 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo DrawPolyLineWithLineInfo(rPoly, rLineInfo); } -void OutputDevice::DrawPolyLine( - const basegfx::B2DPolygon& rB2DPolygon, - double fLineWidth, - basegfx::B2DLineJoin eLineJoin, - css::drawing::LineCap eLineCap) +void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, + double fLineWidth, + basegfx::B2DLineJoin eLineJoin, + css::drawing::LineCap eLineCap) { if( mpMetaFile ) @@ -139,6 +140,7 @@ void OutputDevice::DrawPolyLine( LineInfo aLineInfo; if( fLineWidth != 0.0 ) aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) ); + const Polygon aToolsPolygon( rB2DPolygon ); mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) ); } @@ -148,22 +150,22 @@ void OutputDevice::DrawPolyLine( return; // we need a graphics - if( !mpGraphics ) - if( !AcquireGraphics() ) - return; + if( !mpGraphics && !AcquireGraphics() ) + return; if( mbInitClipRegion ) InitClipRegion(); + if( mbOutputClipped ) return; if( mbInitLineColor ) InitLineColor(); - const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsLineColor()); + const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + IsLineColor()); // use b2dpolygon drawing if possible if(bTryAA) @@ -176,17 +178,16 @@ void OutputDevice::DrawPolyLine( // no output yet; fallback to geometry decomposition and use filled polygon paint // when line is fat and not too complex. ImplDrawPolyPolygonWithB2DPolyPolygon // will do internal needed AA checks etc. - if(fLineWidth >= 2.5 - && rB2DPolygon.count() - && rB2DPolygon.count() <= 1000) + if(fLineWidth >= 2.5 && + rB2DPolygon.count() && + rB2DPolygon.count() <= 1000) { const double fHalfLineWidth((fLineWidth * 0.5) + 0.5); const basegfx::B2DPolyPolygon aAreaPolyPolygon( - basegfx::tools::createAreaGeometry( - rB2DPolygon, - fHalfLineWidth, - eLineJoin, - eLineCap)); + basegfx::tools::createAreaGeometry( rB2DPolygon, + fHalfLineWidth, + eLineJoin, + eLineCap)); const Color aOldLineColor(maLineColor); const Color aOldFillColor(maFillColor); @@ -224,6 +225,7 @@ void OutputDevice::DrawPolyLine( LineInfo aLineInfo; if( fLineWidth != 0.0 ) aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) ); + DrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo ); } } @@ -276,12 +278,11 @@ void OutputDevice::DrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo ); } -bool OutputDevice::TryDrawPolyLineDirectNoAA( - const basegfx::B2DPolygon& rB2DPolygon, - double fLineWidth, - double fTransparency, - basegfx::B2DLineJoin eLineJoin, - css::drawing::LineCap eLineCap) +bool OutputDevice::TryDrawPolyLineDirectNoAA( const basegfx::B2DPolygon& rB2DPolygon, + double fLineWidth, + double fTransparency, + basegfx::B2DLineJoin eLineJoin, + css::drawing::LineCap eLineCap) { const basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); basegfx::B2DVector aB2DLineWidth(1.0, 1.0); @@ -296,8 +297,8 @@ bool OutputDevice::TryDrawPolyLineDirectNoAA( basegfx::B2DPolygon aB2DPolygon(rB2DPolygon); aB2DPolygon.transform(aTransform); - if((mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE) - && aB2DPolygon.count() < 1000) + if((mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE) && + aB2DPolygon.count() < 1000) { // #i98289#, #i101491# // better to remove doubles on device coordinates. Also assume from a given amount @@ -307,30 +308,27 @@ bool OutputDevice::TryDrawPolyLineDirectNoAA( } // draw the polyline - return mpGraphics->DrawPolyLine( - aB2DPolygon, - fTransparency, - aB2DLineWidth, - eLineJoin, - eLineCap, - this); + return mpGraphics->DrawPolyLine( aB2DPolygon, + fTransparency, + aB2DLineWidth, + eLineJoin, + eLineCap, + this); } -bool OutputDevice::TryDrawPolyLineDirect( - const basegfx::B2DPolygon& rB2DPolygon, - double fLineWidth, - double fTransparency, - basegfx::B2DLineJoin eLineJoin, - css::drawing::LineCap eLineCap) +bool OutputDevice::TryDrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon, + double fLineWidth, + double fTransparency, + basegfx::B2DLineJoin eLineJoin, + css::drawing::LineCap eLineCap) { // AW: Do NOT paint empty PolyPolygons if(!rB2DPolygon.count()) return true; // we need a graphics - if( !mpGraphics ) - if( !AcquireGraphics() ) - return false; + if( !mpGraphics && !AcquireGraphics() ) + return false; if( mbInitClipRegion ) InitClipRegion(); @@ -341,10 +339,10 @@ bool OutputDevice::TryDrawPolyLineDirect( if( mbInitLineColor ) InitLineColor(); - const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsLineColor()); + const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + ROP_OVERPAINT == GetRasterOp() && + IsLineColor()); if(bTryAA) { @@ -356,16 +354,14 @@ bool OutputDevice::TryDrawPolyLineDirect( LineInfo aLineInfo; if( fLineWidth != 0.0 ) aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) ); + const Polygon aToolsPolygon( rB2DPolygon ); mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) ); } - return true; } } - return false; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index d9d39b9fa9dc..8a5d884f2264 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -16,6 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> #include <tools/poly.hxx> #include <tools/helpers.hxx> @@ -23,7 +24,7 @@ #include <vcl/virdev.hxx> #include <vcl/outdev.hxx> -#include <salgdi.hxx> +#include "salgdi.hxx" void OutputDevice::DrawRect( const Rectangle& rRect ) { @@ -38,21 +39,21 @@ void OutputDevice::DrawRect( const Rectangle& rRect ) if ( aRect.IsEmpty() ) return; + aRect.Justify(); - if ( !mpGraphics ) - { - if ( !AcquireGraphics() ) - return; - } + if ( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; if ( mbInitLineColor ) InitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); @@ -89,16 +90,20 @@ void OutputDevice::DrawRect( const Rectangle& rRect, if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; if ( mbInitLineColor ) InitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); if ( !nHorzRound && !nVertRound ) + { mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this ); + } else { const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound ); @@ -145,16 +150,18 @@ sal_uLong AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) { const Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); - Rectangle aCropRect( aSourceRect ); + Rectangle aCropRect( aSourceRect ); aCropRect.Intersection( Rectangle( Point(), rSizePix ) ); if( aCropRect.IsEmpty() ) + { rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; + } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); @@ -184,16 +191,18 @@ void AdjustTwoRect( SalTwoRect& rTwoRect, const Rectangle& rValidSrcRect ) { const Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); - Rectangle aCropRect( aSourceRect ); + Rectangle aCropRect( aSourceRect ); aCropRect.Intersection( rValidSrcRect ); if( aCropRect.IsEmpty() ) + { rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; + } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index a2a3beda06e0..11e325080f50 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -16,6 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> @@ -32,12 +33,6 @@ #include "graphite_features.hxx" #endif -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::rtl; -using namespace ::vcl; -using namespace ::utl; - #define UNDERLINE_LAST UNDERLINE_BOLDWAVE #define STRIKEOUT_LAST STRIKEOUT_X @@ -46,11 +41,12 @@ bool OutputDevice::ImplIsUnderlineAbove( const Font& rFont ) if ( !rFont.IsVertical() ) return false; - if( (LANGUAGE_JAPANESE == rFont.GetLanguage()) - || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()) ) + if( (LANGUAGE_JAPANESE == rFont.GetLanguage()) || + (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()) ) + { // the underline is right for Japanese only return true; - + } return false; } @@ -70,7 +66,6 @@ static void ImplDrawWavePixel( long nOriginX, long nOriginY, SalGraphics* pGraphics, OutputDevice* pOutDev, bool bDrawPixAsRect, - long nPixWidth, long nPixHeight ) { if ( nOrientation ) @@ -205,7 +200,6 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, } } } - } } @@ -231,13 +225,17 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, } if ( (eTextLine == UNDERLINE_SMALLWAVE) && (nLineHeight > 3) ) nLineHeight = 3; - long nLineWidth = (mnDPIX/300); + + long nLineWidth = (mnDPIX / 300); if ( !nLineWidth ) nLineWidth = 1; + if ( eTextLine == UNDERLINE_BOLDWAVE ) nLineWidth *= 2; + nLinePos += nDistY - (nLineHeight / 2); - long nLineWidthHeight = ((nLineWidth*mnDPIX)+(mnDPIY/2))/mnDPIY; + + long nLineWidthHeight = ((nLineWidth * mnDPIX) + (mnDPIY / 2)) / mnDPIY; if ( eTextLine == UNDERLINE_DOUBLEWAVE ) { long nOrgLineHeight = nLineHeight; @@ -249,9 +247,11 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, else nLineHeight = 1; } + long nLineDY = nOrgLineHeight-(nLineHeight*2); if ( nLineDY < nLineWidthHeight ) nLineDY = nLineWidthHeight; + long nLineDY2 = nLineDY/2; if ( !nLineDY2 ) nLineDY2 = 1; @@ -289,56 +289,56 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, switch ( eTextLine ) { - case UNDERLINE_SINGLE: - case UNDERLINE_DOTTED: - case UNDERLINE_DASH: - case UNDERLINE_LONGDASH: - case UNDERLINE_DASHDOT: - case UNDERLINE_DASHDOTDOT: - if ( bIsAbove ) - { - nLineHeight = pFontEntry->maMetric.mnAboveUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnAboveUnderlineOffset; - } - else - { - nLineHeight = pFontEntry->maMetric.mnUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnUnderlineOffset; - } - break; - case UNDERLINE_BOLD: - case UNDERLINE_BOLDDOTTED: - case UNDERLINE_BOLDDASH: - case UNDERLINE_BOLDLONGDASH: - case UNDERLINE_BOLDDASHDOT: - case UNDERLINE_BOLDDASHDOTDOT: - if ( bIsAbove ) - { - nLineHeight = pFontEntry->maMetric.mnAboveBUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnAboveBUnderlineOffset; - } - else - { - nLineHeight = pFontEntry->maMetric.mnBUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnBUnderlineOffset; - } - break; - case UNDERLINE_DOUBLE: - if ( bIsAbove ) - { - nLineHeight = pFontEntry->maMetric.mnAboveDUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnAboveDUnderlineOffset1; - nLinePos2 = nY + pFontEntry->maMetric.mnAboveDUnderlineOffset2; - } - else - { - nLineHeight = pFontEntry->maMetric.mnDUnderlineSize; - nLinePos = nY + pFontEntry->maMetric.mnDUnderlineOffset1; - nLinePos2 = nY + pFontEntry->maMetric.mnDUnderlineOffset2; - } - break; - default: - break; + case UNDERLINE_SINGLE: + case UNDERLINE_DOTTED: + case UNDERLINE_DASH: + case UNDERLINE_LONGDASH: + case UNDERLINE_DASHDOT: + case UNDERLINE_DASHDOTDOT: + if ( bIsAbove ) + { + nLineHeight = pFontEntry->maMetric.mnAboveUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnAboveUnderlineOffset; + } + else + { + nLineHeight = pFontEntry->maMetric.mnUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnUnderlineOffset; + } + break; + case UNDERLINE_BOLD: + case UNDERLINE_BOLDDOTTED: + case UNDERLINE_BOLDDASH: + case UNDERLINE_BOLDLONGDASH: + case UNDERLINE_BOLDDASHDOT: + case UNDERLINE_BOLDDASHDOTDOT: + if ( bIsAbove ) + { + nLineHeight = pFontEntry->maMetric.mnAboveBUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnAboveBUnderlineOffset; + } + else + { + nLineHeight = pFontEntry->maMetric.mnBUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnBUnderlineOffset; + } + break; + case UNDERLINE_DOUBLE: + if ( bIsAbove ) + { + nLineHeight = pFontEntry->maMetric.mnAboveDUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnAboveDUnderlineOffset1; + nLinePos2 = nY + pFontEntry->maMetric.mnAboveDUnderlineOffset2; + } + else + { + nLineHeight = pFontEntry->maMetric.mnDUnderlineSize; + nLinePos = nY + pFontEntry->maMetric.mnDUnderlineOffset1; + nLinePos2 = nY + pFontEntry->maMetric.mnDUnderlineOffset2; + } + break; + default: + break; } if ( nLineHeight ) @@ -355,145 +355,161 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, switch ( eTextLine ) { - case UNDERLINE_SINGLE: - case UNDERLINE_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case UNDERLINE_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - case UNDERLINE_DOTTED: - case UNDERLINE_BOLDDOTTED: + case UNDERLINE_SINGLE: + case UNDERLINE_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case UNDERLINE_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + case UNDERLINE_DOTTED: + case UNDERLINE_BOLDDOTTED: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nTempWidth = nDotWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - long nTempWidth = nDotWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDotWidth*2; - } + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDotWidth*2; } - break; - case UNDERLINE_DASH: - case UNDERLINE_LONGDASH: - case UNDERLINE_BOLDDASH: - case UNDERLINE_BOLDLONGDASH: + } + break; + case UNDERLINE_DASH: + case UNDERLINE_LONGDASH: + case UNDERLINE_BOLDDASH: + case UNDERLINE_BOLDLONGDASH: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nMinDashWidth; + long nMinSpaceWidth; + long nSpaceWidth; + long nDashWidth; + if ( (eTextLine == UNDERLINE_LONGDASH) || + (eTextLine == UNDERLINE_BOLDLONGDASH) ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - long nMinDashWidth; - long nMinSpaceWidth; - long nSpaceWidth; - long nDashWidth; - if ( (eTextLine == UNDERLINE_LONGDASH) || - (eTextLine == UNDERLINE_BOLDLONGDASH) ) - { - nMinDashWidth = nDotWidth*6; - nMinSpaceWidth = nDotWidth*2; - nDashWidth = 200; - nSpaceWidth = 100; - } - else - { - nMinDashWidth = nDotWidth*4; - nMinSpaceWidth = (nDotWidth*150)/100; - nDashWidth = 100; - nSpaceWidth = 50; - } - nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; - nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - if ( nSpaceWidth < nMinSpaceWidth ) - nSpaceWidth = nMinSpaceWidth; - long nTempWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDashWidth+nSpaceWidth; - } + nMinDashWidth = nDotWidth*6; + nMinSpaceWidth = nDotWidth*2; + nDashWidth = 200; + nSpaceWidth = 100; } - break; - case UNDERLINE_DASHDOT: - case UNDERLINE_BOLDDASHDOT: + else { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + nMinDashWidth = nDotWidth*4; + nMinSpaceWidth = (nDotWidth*150)/100; + nDashWidth = 100; + nSpaceWidth = 50; } - break; - case UNDERLINE_DASHDOTDOT: - case UNDERLINE_BOLDDASHDOTDOT: + nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; + nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + if ( nSpaceWidth < nMinSpaceWidth ) + nSpaceWidth = nMinSpaceWidth; + + long nTempWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDashWidth+nSpaceWidth; } - break; - default: - break; + } + break; + case UNDERLINE_DASHDOT: + case UNDERLINE_BOLDDASHDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; + + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; + } + } + break; + case UNDERLINE_DASHDOTDOT: + case UNDERLINE_BOLDDASHDOTDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; + + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; + + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; + + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; + } + } + break; + default: + break; } } } @@ -515,21 +531,21 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, switch ( eStrikeout ) { - case STRIKEOUT_SINGLE: - nLineHeight = pFontEntry->maMetric.mnStrikeoutSize; - nLinePos = nY + pFontEntry->maMetric.mnStrikeoutOffset; - break; - case STRIKEOUT_BOLD: - nLineHeight = pFontEntry->maMetric.mnBStrikeoutSize; - nLinePos = nY + pFontEntry->maMetric.mnBStrikeoutOffset; - break; - case STRIKEOUT_DOUBLE: - nLineHeight = pFontEntry->maMetric.mnDStrikeoutSize; - nLinePos = nY + pFontEntry->maMetric.mnDStrikeoutOffset1; - nLinePos2 = nY + pFontEntry->maMetric.mnDStrikeoutOffset2; - break; - default: - break; + case STRIKEOUT_SINGLE: + nLineHeight = pFontEntry->maMetric.mnStrikeoutSize; + nLinePos = nY + pFontEntry->maMetric.mnStrikeoutOffset; + break; + case STRIKEOUT_BOLD: + nLineHeight = pFontEntry->maMetric.mnBStrikeoutSize; + nLinePos = nY + pFontEntry->maMetric.mnBStrikeoutOffset; + break; + case STRIKEOUT_DOUBLE: + nLineHeight = pFontEntry->maMetric.mnDStrikeoutSize; + nLinePos = nY + pFontEntry->maMetric.mnDStrikeoutOffset1; + nLinePos2 = nY + pFontEntry->maMetric.mnDStrikeoutOffset2; + break; + default: + break; } if ( nLineHeight ) @@ -546,16 +562,16 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, switch ( eStrikeout ) { - case STRIKEOUT_SINGLE: - case STRIKEOUT_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case STRIKEOUT_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - default: - break; + case STRIKEOUT_SINGLE: + case STRIKEOUT_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case STRIKEOUT_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + default: + break; } } } @@ -571,16 +587,14 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, return; // prepare string for strikeout measurement - static char cStrikeoutChar; - if ( eStrikeout == STRIKEOUT_SLASH ) - cStrikeoutChar = '/'; - else // ( eStrikeout == STRIKEOUT_X ) - cStrikeoutChar = 'X'; + static char cStrikeoutChar = eStrikeout == STRIKEOUT_SLASH ? '/' : 'X'; static const int nTestStrLen = 4; static const int nMaxStrikeStrLen = 2048; sal_Unicode aChars[nMaxStrikeStrLen+1]; // +1 for valgrind... + for( int i = 0; i < nTestStrLen; ++i) aChars[i] = cStrikeoutChar; + const OUString aStrikeoutTest(aChars, nTestStrLen); // calculate approximation of strikeout atom size @@ -601,10 +615,12 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // build the strikeout string for( int i = nTestStrLen; i < nStrikeStrLen; ++i) aChars[i] = cStrikeoutChar; + const OUString aStrikeoutText(aChars, nStrikeStrLen); if( mpFontEntry->mnOrientation ) ImplRotatePos( 0, 0, nDistX, nDistY, mpFontEntry->mnOrientation ); + nBaseX += nDistX; nBaseY += nDistY; @@ -661,12 +677,12 @@ void OutputDevice::ImplDrawTextLine( long nX, long nY, if ( !nWidth ) return; - Color aStrikeoutColor = GetTextColor(); - Color aUnderlineColor = GetTextLineColor(); - Color aOverlineColor = GetOverlineColor(); - bool bStrikeoutDone = false; - bool bUnderlineDone = false; - bool bOverlineDone = false; + Color aStrikeoutColor = GetTextColor(); + Color aUnderlineColor = GetTextLineColor(); + Color aOverlineColor = GetOverlineColor(); + bool bStrikeoutDone = false; + bool bUnderlineDone = false; + bool bOverlineDone = false; if ( IsRTLEnabled() ) { @@ -674,6 +690,7 @@ void OutputDevice::ImplDrawTextLine( long nX, long nY, long nXAdd = nWidth - nDistX; if( mpFontEntry->mnOrientation ) nXAdd = FRound( nXAdd * cos( mpFontEntry->mnOrientation * F_PI1800 ) ); + nX += nXAdd - 1; } @@ -717,8 +734,9 @@ void OutputDevice::ImplDrawTextLine( long nX, long nY, ImplDrawStrikeoutLine( nX, nY, nDistX, 0, nWidth, eStrikeout, aStrikeoutColor ); } -void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, - FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, bool bWordLine, bool bUnderlineAbove ) +void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, FontStrikeout eStrikeout, + FontUnderline eUnderline, FontUnderline eOverline, + bool bWordLine, bool bUnderlineAbove ) { if( bWordLine ) { @@ -757,7 +775,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, { // draw the textline for each word ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, - eStrikeout, eUnderline, eOverline, bUnderlineAbove ); + eStrikeout, eUnderline, eOverline, bUnderlineAbove ); nWidth = 0; } } @@ -766,7 +784,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, if( nWidth > 0 ) { ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, - eStrikeout, eUnderline, eOverline, bUnderlineAbove ); + eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } else @@ -774,7 +792,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, Point aStartPt = rSalLayout.GetDrawPosition(); int nWidth = rSalLayout.GetTextWidth() / rSalLayout.GetUnitsPerPixel(); ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), 0, nWidth, - eStrikeout, eUnderline, eOverline, bUnderlineAbove ); + eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } @@ -815,19 +833,25 @@ void OutputDevice::SetTextLineColor( const Color& rColor ) DRAWMODE_SETTINGSTEXT ) ) { if ( mnDrawMode & DRAWMODE_BLACKTEXT ) + { aColor = Color( COL_BLACK ); + } else if ( mnDrawMode & DRAWMODE_WHITETEXT ) + { aColor = Color( COL_WHITE ); + } else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) + { aColor = GetSettings().GetStyleSettings().GetFontColor(); + } - if( (mnDrawMode & DRAWMODE_GHOSTEDTEXT) - && (aColor.GetColor() != COL_TRANSPARENT) ) + if( (mnDrawMode & DRAWMODE_GHOSTEDTEXT) && + (aColor.GetColor() != COL_TRANSPARENT) ) { aColor = Color( (aColor.GetRed() >> 1) | 0x80, (aColor.GetGreen() >> 1) | 0x80, @@ -866,19 +890,25 @@ void OutputDevice::SetOverlineColor( const Color& rColor ) DRAWMODE_SETTINGSTEXT ) ) { if ( mnDrawMode & DRAWMODE_BLACKTEXT ) + { aColor = Color( COL_BLACK ); + } else if ( mnDrawMode & DRAWMODE_WHITETEXT ) + { aColor = Color( COL_WHITE ); + } else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) + { aColor = GetSettings().GetStyleSettings().GetFontColor(); + } - if( (mnDrawMode & DRAWMODE_GHOSTEDTEXT) - && (aColor.GetColor() != COL_TRANSPARENT) ) + if( (mnDrawMode & DRAWMODE_GHOSTEDTEXT) && + (aColor.GetColor() != COL_TRANSPARENT) ) { aColor = Color( (aColor.GetRed() >> 1) | 0x80, (aColor.GetGreen() >> 1) | 0x80, @@ -908,24 +938,27 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth, if ( ((eUnderline == UNDERLINE_NONE) || (eUnderline == UNDERLINE_DONTKNOW)) && ((eOverline == UNDERLINE_NONE) || (eOverline == UNDERLINE_DONTKNOW)) && ((eStrikeout == STRIKEOUT_NONE) || (eStrikeout == STRIKEOUT_DONTKNOW)) ) + { return; - + } if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) return; // we need a graphics if( !mpGraphics && !AcquireGraphics() ) return; + if( mbInitClipRegion ) InitClipRegion(); + if( mbOutputClipped ) return; // initialize font if needed to get text offsets // TODO: only needed for mnTextOff!=(0,0) - if( mbNewFont ) - if( !ImplNewFont() ) - return; + if( mbNewFont && !ImplNewFont() ) + return; + if( mbInitFont ) InitFont(); @@ -945,18 +978,17 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos ) return; // we need a graphics - if( !mpGraphics ) - if( !AcquireGraphics() ) - return; + if( !mpGraphics && !AcquireGraphics() ) + return; if ( mbInitClipRegion ) InitClipRegion(); + if ( mbOutputClipped ) return; - if( mbNewFont ) - if( !ImplNewFont() ) - return; + if( mbNewFont && !ImplNewFont() ) + return; Point aStartPt = ImplLogicToDevicePixel( rStartPos ); Point aEndPt = ImplLogicToDevicePixel( rEndPos ); @@ -998,11 +1030,12 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos ) // #109280# make sure the waveline does not exceed the descent to avoid paint problems ImplFontEntry* pFontEntry = mpFontEntry; if( nWaveHeight > pFontEntry->maMetric.mnWUnderlineSize ) + { nWaveHeight = pFontEntry->maMetric.mnWUnderlineSize; - + } ImplDrawWaveLine(nStartX, nStartY, 0, 0, - nEndX-nStartX, nWaveHeight, - mnDPIScaleFactor, nOrientation, GetLineColor()); + nEndX-nStartX, nWaveHeight, + mnDPIScaleFactor, nOrientation, GetLineColor()); if( mpAlphaVDev ) mpAlphaVDev->DrawWaveLine( rStartPos, rEndPos ); diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 65e1ae8fa2d7..ec4351f664b5 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -16,18 +16,15 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/types.h> - +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <boost/scoped_array.hpp> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> #include <vcl/bmpacc.hxx> -#include <salgdi.hxx> - -#include <basegfx/matrix/b2dhommatrixtools.hxx> - -#include <boost/scoped_array.hpp> - +#include "salgdi.hxx" namespace { @@ -127,11 +124,11 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask } // do painting - const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight(); - long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight; + const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight(); + long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight; boost::scoped_array<long> pMapX(new long[ nSrcWidth + 1 ]); boost::scoped_array<long> pMapY(new long[ nSrcHeight + 1 ]); - const bool bOldMap = mbMap; + const bool bOldMap = mbMap; mbMap = false; @@ -150,9 +147,8 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) { const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]); - const Size aMapSz( - pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 - pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y + const Size aMapSz( pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 + pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y Bitmap aBandBmp(aPaint); aBandBmp.Crop(*aRectIter); @@ -174,23 +170,24 @@ void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, return; // we need a graphics - if( !mpGraphics ) - if( !AcquireGraphics() ) - return; + if( !mpGraphics && !AcquireGraphics() ) + return; if( mbInitClipRegion ) InitClipRegion(); + if( mbOutputClipped ) return; if( mbInitLineColor ) InitLineColor(); + if( mbInitFillColor ) ImplInitFillColor(); - if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() ) + if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && + mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && + (ROP_OVERPAINT == GetRasterOp()) ) { // b2dpolygon support not implemented yet on non-UNX platforms const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); @@ -203,6 +200,7 @@ void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, bool bDrawnOk = true; if( IsFillColor() ) bDrawnOk = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, fTransparency, this ); + if( bDrawnOk && IsLineColor() ) { const basegfx::B2DVector aHairlineWidth(1,1); @@ -218,6 +216,7 @@ void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, { if( mpMetaFile ) mpMetaFile->AddAction( new MetaTransparentAction( PolyPolygon( rB2DPolyPoly ), static_cast< sal_uInt16 >(fTransparency * 100.0))); + return; } } @@ -247,10 +246,10 @@ bool OutputDevice::DrawTransparentNatively ( const PolyPolygon& rPolyPoly, // debug helper: static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); - if( !pDisableNative - && mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) + if( !pDisableNative && + mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) #if defined UNX && ! defined MACOSX && ! defined IOS - && GetBitCount() > 8 + && GetBitCount() > 8 #endif #ifdef WIN32 // workaround bad dithering on remote displaying when using GDI+ with toolbar button highlighting @@ -261,10 +260,13 @@ bool OutputDevice::DrawTransparentNatively ( const PolyPolygon& rPolyPoly, // prepare the graphics device if( mbInitClipRegion ) InitClipRegion(); + if( mbOutputClipped ) return false; + if( mbInitLineColor ) InitLineColor(); + if( mbInitFillColor ) ImplInitFillColor(); @@ -298,7 +300,8 @@ bool OutputDevice::DrawTransparentNatively ( const PolyPolygon& rPolyPoly, for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx ) { const ::basegfx::B2DPolygon& rPolygon = aB2DPolyPolygon.getB2DPolygon( nPolyIdx ); - bDrawn = mpGraphics->DrawPolyLine( rPolygon, fTransparency, aLineWidths, ::basegfx::B2DLINEJOIN_NONE, com::sun::star::drawing::LineCap_BUTT, this ); + bDrawn = mpGraphics->DrawPolyLine( rPolygon, fTransparency, aLineWidths, + ::basegfx::B2DLINEJOIN_NONE, css::drawing::LineCap_BUTT, this ); } // prepare to restore the fill color mbInitFillColor = mbFillColor; @@ -312,7 +315,7 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ) { // debug helper: - static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); + static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA" ); // #110958# Disable alpha VDev, we perform the necessary VirtualDevice* pOldAlphaVDev = mpAlphaVDev; @@ -324,10 +327,10 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, GDIMetaFile* pOldMetaFile = mpMetaFile; mpMetaFile = NULL; - PolyPolygon aPolyPoly( LogicToPixel( rPolyPoly ) ); - Rectangle aPolyRect( aPolyPoly.GetBoundRect() ); - Point aPoint; - Rectangle aDstRect( aPoint, GetOutputSizePixel() ); + PolyPolygon aPolyPoly( LogicToPixel( rPolyPoly ) ); + Rectangle aPolyRect( aPolyPoly.GetBoundRect() ); + Point aPoint; + Rectangle aDstRect( aPoint, GetOutputSizePixel() ); aDstRect.Intersection( aPolyRect ); @@ -347,8 +350,10 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, // to basic OutDev methods) if ( mbInitClipRegion ) InitClipRegion(); + if ( mbInitLineColor ) InitLineColor(); + if ( mbInitFillColor ) ImplInitFillColor(); @@ -357,25 +362,26 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, if( !mbOutputClipped ) { - bDrawn = mpGraphics->DrawAlphaRect( - aPixelRect.Left(), aPixelRect.Top(), + bDrawn = mpGraphics->DrawAlphaRect( aPixelRect.Left(), aPixelRect.Top(), // #i98405# use methods with small g, else one pixel too much will be painted. // This is because the source is a polygon which when painted would not paint // the rightmost and lowest pixel line(s), so use one pixel less for the // rectangle, too. - aPixelRect.getWidth(), aPixelRect.getHeight(), - sal::static_int_cast<sal_uInt8>(nTransparencePercent), - this ); + aPixelRect.getWidth(), aPixelRect.getHeight(), + sal::static_int_cast<sal_uInt8>(nTransparencePercent), + this ); } else + { bDrawn = true; + } } if( !bDrawn ) { - VirtualDevice aVDev( *this, 1 ); - const Size aDstSz( aDstRect.GetSize() ); - const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); + VirtualDevice aVDev( *this, 1 ); + const Size aDstSz( aDstRect.GetSize() ); + const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); if( aDstRect.Left() || aDstRect.Top() ) aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() ); @@ -390,30 +396,33 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, aVDev.SetFillColor( COL_BLACK ); aVDev.DrawPolyPolygon( aPolyPoly ); - Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) ); - Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) ); + Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) ); + Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) ); // #107766# check for non-empty bitmaps before accessing them if( !!aPaint && !!aPolyMask ) { - BitmapWriteAccess* pW = aPaint.AcquireWriteAccess(); - BitmapReadAccess* pR = aPolyMask.AcquireReadAccess(); + BitmapWriteAccess* pW = aPaint.AcquireWriteAccess(); + BitmapReadAccess* pR = aPolyMask.AcquireReadAccess(); if( pW && pR ) { - BitmapColor aPixCol; - const BitmapColor aFillCol( GetFillColor() ); - const BitmapColor aWhite( pR->GetBestMatchingColor( Color( COL_WHITE ) ) ); - const BitmapColor aBlack( pR->GetBestMatchingColor( Color( COL_BLACK ) ) ); - const long nWidth = pW->Width(), nHeight = pW->Height(); - const long nR = aFillCol.GetRed(), nG = aFillCol.GetGreen(), nB = aFillCol.GetBlue(); - long nX, nY; + BitmapColor aPixCol; + const BitmapColor aFillCol( GetFillColor() ); + const BitmapColor aWhite( pR->GetBestMatchingColor( Color( COL_WHITE ) ) ); + const BitmapColor aBlack( pR->GetBestMatchingColor( Color( COL_BLACK ) ) ); + const long nWidth = pW->Width(); + const long nHeight = pW->Height(); + const long nR = aFillCol.GetRed(); + const long nG = aFillCol.GetGreen(); + const long nB = aFillCol.GetBlue(); + long nX, nY; if( aPaint.GetBitCount() <= 8 ) { - const BitmapPalette& rPal = pW->GetPalette(); - const sal_uInt16 nCount = rPal.GetEntryCount(); - BitmapColor* pMap = (BitmapColor*) new sal_uInt8[ nCount * sizeof( BitmapColor ) ]; + const BitmapPalette& rPal = pW->GetPalette(); + const sal_uInt16 nCount = rPal.GetEntryCount(); + BitmapColor* pMap = (BitmapColor*) new sal_uInt8[ nCount * sizeof( BitmapColor ) ]; for( sal_uInt16 i = 0; i < nCount; i++ ) { @@ -428,28 +437,37 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, for( nY = 0; nY < nHeight; nY++ ) { - Scanline pWScan = pW->GetScanline( nY ); - Scanline pRScan = pR->GetScanline( nY ); - sal_uInt8 cBit = 128; + Scanline pWScan = pW->GetScanline( nY ); + Scanline pRScan = pR->GetScanline( nY ); + sal_uInt8 cBit = 128; for( nX = 0; nX < nWidth; nX++, cBit >>= 1, pWScan++ ) { if( !cBit ) - cBit = 128, pRScan++; - + { + cBit = 128; + pRScan += 1; + } if( ( *pRScan & cBit ) == cBlack ) + { *pWScan = (sal_uInt8) pMap[ *pWScan ].GetIndex(); + } } } } else { for( nY = 0; nY < nHeight; nY++ ) + { for( nX = 0; nX < nWidth; nX++ ) + { if( pR->GetPixel( nY, nX ) == aBlack ) + { pW->SetPixel( nY, nX, pMap[ pW->GetPixel( nY, nX ).GetIndex() ] ); + } + } + } } - delete[] (sal_uInt8*) pMap; } else @@ -461,15 +479,17 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, for( nY = 0; nY < nHeight; nY++ ) { - Scanline pWScan = pW->GetScanline( nY ); - Scanline pRScan = pR->GetScanline( nY ); - sal_uInt8 cBit = 128; + Scanline pWScan = pW->GetScanline( nY ); + Scanline pRScan = pR->GetScanline( nY ); + sal_uInt8 cBit = 128; for( nX = 0; nX < nWidth; nX++, cBit >>= 1, pWScan += 3 ) { if( !cBit ) - cBit = 128, pRScan++; - + { + cBit = 128; + pRScan += 1; + } if( ( *pRScan & cBit ) == cBlack ) { pWScan[ 0 ] = COLOR_CHANNEL_MERGE( pWScan[ 0 ], nB, cTrans ); @@ -513,7 +533,9 @@ void OutputDevice::EmulateDrawTransparent ( const PolyPolygon& rPolyPoly, } } else + { DrawPolyPolygon( rPolyPoly ); + } } } @@ -548,9 +570,8 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, return; // get the device graphics as drawing target - if( !mpGraphics ) - if( !AcquireGraphics() ) - return; + if( !mpGraphics && !AcquireGraphics() ) + return; // try hard to draw it directly, because the emulation layers are slower bDrawn = DrawTransparentNatively( rPolyPoly, nTransparencePercent ); @@ -597,10 +618,10 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, } else { - GDIMetaFile* pOldMetaFile = mpMetaFile; - Rectangle aOutRect( LogicToPixel( rPos ), LogicToPixel( rSize ) ); - Point aPoint; - Rectangle aDstRect( aPoint, GetOutputSizePixel() ); + GDIMetaFile* pOldMetaFile = mpMetaFile; + Rectangle aOutRect( LogicToPixel( rPos ), LogicToPixel( rSize ) ); + Point aPoint; + Rectangle aDstRect( aPoint, GetOutputSizePixel() ); mpMetaFile = NULL; aDstRect.Intersection( aOutRect ); @@ -640,10 +661,9 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, pVDev->EnableMapMode(false); // copy content from original to buffer - pVDev->DrawOutDev( - aPoint, pVDev->GetOutputSizePixel(), // dest - aDstRect.TopLeft(), pVDev->GetOutputSizePixel(), // source - *this); + pVDev->DrawOutDev( aPoint, pVDev->GetOutputSizePixel(), // dest + aDstRect.TopLeft(), pVDev->GetOutputSizePixel(), // source + *this); // draw MetaFile to buffer pVDev->EnableMapMode(bBufferMapModeEnabled); @@ -653,6 +673,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, // get content bitmap from buffer pVDev->EnableMapMode(false); + const Bitmap aPaint(pVDev->GetBitmap(aPoint, pVDev->GetOutputSizePixel())); // create alpha mask from gradient and get as Bitmap @@ -661,6 +682,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, pVDev->DrawGradient(Rectangle(rPos, rSize), rTransparenceGradient); pVDev->SetDrawMode(DRAWMODE_DEFAULT); pVDev->EnableMapMode(false); + const AlphaMask aAlpha(pVDev->GetBitmap(aPoint, pVDev->GetOutputSizePixel())); pVDev.reset(); @@ -671,15 +693,15 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, } else { - Bitmap aPaint, aMask; - AlphaMask aAlpha; - MapMode aMap( GetMapMode() ); - Point aOutPos( PixelToLogic( aDstRect.TopLeft() ) ); - const bool bOldMap = mbMap; + Bitmap aPaint, aMask; + AlphaMask aAlpha; + MapMode aMap( GetMapMode() ); + Point aOutPos( PixelToLogic( aDstRect.TopLeft() ) ); + const bool bOldMap = mbMap; aMap.SetOrigin( Point( -aOutPos.X(), -aOutPos.Y() ) ); pVDev->SetMapMode( aMap ); - const bool bVDevOldMap = pVDev->IsMapModeEnabled(); + const bool bVDevOldMap = pVDev->IsMapModeEnabled(); // create paint bitmap ( (GDIMetaFile&) rMtf ).WindStart(); diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx index 757b0b25c272..a46c3b495125 100644 --- a/vcl/source/outdev/wallpaper.cxx +++ b/vcl/source/outdev/wallpaper.cxx @@ -48,8 +48,8 @@ void OutputDevice::DrawWallpaper( const Rectangle& rRect, } void OutputDevice::DrawWallpaper( long nX, long nY, - long nWidth, long nHeight, - const Wallpaper& rWallpaper ) + long nWidth, long nHeight, + const Wallpaper& rWallpaper ) { if( rWallpaper.IsBitmap() ) DrawBitmapWallpaper( nX, nY, nWidth, nHeight, rWallpaper ); @@ -68,6 +68,7 @@ void OutputDevice::DrawColorWallpaper( long nX, long nY, Color aOldFillColor = GetFillColor(); SetLineColor(); SetFillColor( rWallpaper.GetColor() ); + bool bMap = mbMap; EnableMapMode( false ); DrawRect( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) ); @@ -80,16 +81,16 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ) { - BitmapEx aBmpEx; - const BitmapEx* pCached = rWallpaper.ImplGetImpWallpaper()->ImplGetCachedBitmap(); - Point aPos; - Size aSize; - GDIMetaFile* pOldMetaFile = mpMetaFile; - const WallpaperStyle eStyle = rWallpaper.GetStyle(); - const bool bOldMap = mbMap; - bool bDrawn = false; - bool bDrawGradientBackground = false; - bool bDrawColorBackground = false; + BitmapEx aBmpEx; + const BitmapEx* pCached = rWallpaper.ImplGetImpWallpaper()->ImplGetCachedBitmap(); + Point aPos; + Size aSize; + GDIMetaFile* pOldMetaFile = mpMetaFile; + const WallpaperStyle eStyle = rWallpaper.GetStyle(); + const bool bOldMap = mbMap; + bool bDrawn = false; + bool bDrawGradientBackground = false; + bool bDrawColorBackground = false; if( pCached ) aBmpEx = *pCached; @@ -156,73 +157,63 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, switch( eStyle ) { - case( WALLPAPER_SCALE ): + case( WALLPAPER_SCALE ): + if( !pCached || ( pCached->GetSizePixel() != aSize ) ) { - if( !pCached || ( pCached->GetSizePixel() != aSize ) ) - { - if( pCached ) - rWallpaper.ImplGetImpWallpaper()->ImplReleaseCachedBitmap(); + if( pCached ) + rWallpaper.ImplGetImpWallpaper()->ImplReleaseCachedBitmap(); - aBmpEx = rWallpaper.GetBitmap(); - aBmpEx.Scale( aSize ); - aBmpEx = BitmapEx( aBmpEx.GetBitmap().CreateDisplayBitmap( this ), aBmpEx.GetMask() ); - } + aBmpEx = rWallpaper.GetBitmap(); + aBmpEx.Scale( aSize ); + aBmpEx = BitmapEx( aBmpEx.GetBitmap().CreateDisplayBitmap( this ), aBmpEx.GetMask() ); } break; - case( WALLPAPER_TOPLEFT ): + case( WALLPAPER_TOPLEFT ): break; - case( WALLPAPER_TOP ): - aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; + case( WALLPAPER_TOP ): + aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; break; - case( WALLPAPER_TOPRIGHT ): - aPos.X() += ( aSize.Width() - nBmpWidth ); + case( WALLPAPER_TOPRIGHT ): + aPos.X() += ( aSize.Width() - nBmpWidth ); break; - case( WALLPAPER_LEFT ): - aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; + case( WALLPAPER_LEFT ): + aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; break; - case( WALLPAPER_CENTER ): - { - aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; - aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; - } + case( WALLPAPER_CENTER ): + aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; + aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; break; - case( WALLPAPER_RIGHT ): - { - aPos.X() += ( aSize.Width() - nBmpWidth ); - aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; - } + case( WALLPAPER_RIGHT ): + aPos.X() += ( aSize.Width() - nBmpWidth ); + aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1; break; - case( WALLPAPER_BOTTOMLEFT ): - aPos.Y() += ( aSize.Height() - nBmpHeight ); + case( WALLPAPER_BOTTOMLEFT ): + aPos.Y() += ( aSize.Height() - nBmpHeight ); break; - case( WALLPAPER_BOTTOM ): - { - aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; - aPos.Y() += ( aSize.Height() - nBmpHeight ); - } + case( WALLPAPER_BOTTOM ): + aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1; + aPos.Y() += ( aSize.Height() - nBmpHeight ); break; - case( WALLPAPER_BOTTOMRIGHT ): - { - aPos.X() += ( aSize.Width() - nBmpWidth ); - aPos.Y() += ( aSize.Height() - nBmpHeight ); - } + case( WALLPAPER_BOTTOMRIGHT ): + aPos.X() += ( aSize.Width() - nBmpWidth ); + aPos.Y() += ( aSize.Height() - nBmpHeight ); break; - default: + default: { - const long nRight = nX + nWidth - 1L; - const long nBottom = nY + nHeight - 1L; - long nFirstX; - long nFirstY; + const long nRight = nX + nWidth - 1L; + const long nBottom = nY + nHeight - 1L; + long nFirstX; + long nFirstY; if( eStyle == WALLPAPER_TILE ) { @@ -235,10 +226,10 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, nFirstY = aPos.Y() + ( ( aSize.Height() - nBmpHeight ) >> 1 ); } - const long nOffX = ( nFirstX - nX ) % nBmpWidth; - const long nOffY = ( nFirstY - nY ) % nBmpHeight; - long nStartX = nX + nOffX; - long nStartY = nY + nOffY; + const long nOffX = ( nFirstX - nX ) % nBmpWidth; + const long nOffY = ( nFirstY - nY ) % nBmpHeight; + long nStartX = nX + nOffX; + long nStartY = nY + nOffY; if( nOffX > 0L ) nStartX -= nBmpWidth; @@ -247,9 +238,12 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, nStartY -= nBmpHeight; for( long nBmpY = nStartY; nBmpY <= nBottom; nBmpY += nBmpHeight ) + { for( long nBmpX = nStartX; nBmpX <= nRight; nBmpX += nBmpWidth ) + { DrawBitmapEx( Point( nBmpX, nBmpY ), aBmpEx ); - + } + } bDrawn = true; } break; @@ -260,11 +254,11 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, // optimized for non-transparent bitmaps if( bDrawColorBackground ) { - const Size aBmpSize( aBmpEx.GetSizePixel() ); - const Point aTmpPoint; + const Size aBmpSize( aBmpEx.GetSizePixel() ); + const Point aTmpPoint; const Rectangle aOutRect( aTmpPoint, GetOutputSizePixel() ); const Rectangle aColRect( Point( nX, nY ), Size( nWidth, nHeight ) ); - Rectangle aWorkRect; + Rectangle aWorkRect; aWorkRect = Rectangle( 0, 0, aOutRect.Right(), aPos.Y() - 1L ); aWorkRect.Justify(); @@ -272,8 +266,8 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, if( !aWorkRect.IsEmpty() ) { DrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(), - aWorkRect.GetWidth(), aWorkRect.GetHeight(), - rWallpaper ); + aWorkRect.GetWidth(), aWorkRect.GetHeight(), + rWallpaper ); } aWorkRect = Rectangle( 0, aPos.Y(), aPos.X() - 1L, aPos.Y() + aBmpSize.Height() - 1L ); @@ -282,28 +276,30 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, if( !aWorkRect.IsEmpty() ) { DrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(), - aWorkRect.GetWidth(), aWorkRect.GetHeight(), - rWallpaper ); + aWorkRect.GetWidth(), aWorkRect.GetHeight(), + rWallpaper ); } - aWorkRect = Rectangle( aPos.X() + aBmpSize.Width(), aPos.Y(), aOutRect.Right(), aPos.Y() + aBmpSize.Height() - 1L ); + aWorkRect = Rectangle( aPos.X() + aBmpSize.Width(), aPos.Y(), + aOutRect.Right(), aPos.Y() + aBmpSize.Height() - 1L ); aWorkRect.Justify(); aWorkRect.Intersection( aColRect ); if( !aWorkRect.IsEmpty() ) { DrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(), - aWorkRect.GetWidth(), aWorkRect.GetHeight(), - rWallpaper ); + aWorkRect.GetWidth(), aWorkRect.GetHeight(), + rWallpaper ); } - aWorkRect = Rectangle( 0, aPos.Y() + aBmpSize.Height(), aOutRect.Right(), aOutRect.Bottom() ); + aWorkRect = Rectangle( 0, aPos.Y() + aBmpSize.Height(), + aOutRect.Right(), aOutRect.Bottom() ); aWorkRect.Justify(); aWorkRect.Intersection( aColRect ); if( !aWorkRect.IsEmpty() ) { DrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(), - aWorkRect.GetWidth(), aWorkRect.GetHeight(), - rWallpaper ); + aWorkRect.GetWidth(), aWorkRect.GetHeight(), + rWallpaper ); } } @@ -321,9 +317,9 @@ void OutputDevice::DrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ) { - Rectangle aBound; - GDIMetaFile* pOldMetaFile = mpMetaFile; - const bool bOldMap = mbMap; + Rectangle aBound; + GDIMetaFile* pOldMetaFile = mpMetaFile; + const bool bOldMap = mbMap; aBound = Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ); |