diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 14 | ||||
-rw-r--r-- | vcl/inc/vcl/salgdi.hxx | 9 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 131 | ||||
-rw-r--r-- | vcl/source/gdi/outdev.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/outdev6.cxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 13 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi2.cxx | 1 | ||||
-rw-r--r-- | vcl/util/makefile.mk | 3 | ||||
-rw-r--r-- | vcl/win/inc/saldata.hxx | 3 | ||||
-rw-r--r-- | vcl/win/inc/salgdi.h | 4 | ||||
-rw-r--r-- | vcl/win/source/app/salinst.cxx | 34 | ||||
-rw-r--r-- | vcl/win/source/gdi/MAKEFILE.MK | 1 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi.cxx | 21 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi2.cxx | 4 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi_gdiplus.cxx | 195 |
17 files changed, 363 insertions, 96 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index ce986cd468d3..bc7082c33d1c 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -462,6 +462,14 @@ static void AddPolygonToPath( CGMutablePathRef xPath, } ::basegfx::B2DPoint aPoint = rPolygon.getB2DPoint( nClosedIdx ); + + if(bPixelSnap) + { + // snap device coordinates to full pixels + aPoint.setX( basegfx::fround( aPoint.getX() ) ); + aPoint.setY( basegfx::fround( aPoint.getY() ) ); + } + if( bLineDraw ) aPoint += aHalfPointOfs; @@ -554,7 +562,7 @@ bool AquaSalGraphics::unionClipRegion( const ::basegfx::B2DPolyPolygon& rPolyPol if( !mxClipPath ) mxClipPath = CGPathCreateMutable(); - AddPolyPolygonToPath( mxClipPath, rPolyPolygon, false, false ); + AddPolyPolygonToPath( mxClipPath, rPolyPolygon, !getAntiAliasB2DDraw(), false ); return true; } @@ -906,7 +914,7 @@ bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPol for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx ) { const ::basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx ); - AddPolygonToPath( xPath, rPolygon, true, false, IsPenVisible() ); + AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() ); } CGContextSaveGState( mrContext ); CGContextBeginPath( mrContext ); @@ -952,7 +960,7 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, // setup poly-polygon path CGMutablePathRef xPath = CGPathCreateMutable(); - AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), false, true ); + AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true ); CGContextSaveGState( mrContext ); CGContextAddPath( mrContext, xPath ); const CGRect aRefreshRect = CGPathGetBoundingBox( xPath ); diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx index 16ff921ba003..2bbb44d67b42 100644 --- a/vcl/inc/vcl/salgdi.hxx +++ b/vcl/inc/vcl/salgdi.hxx @@ -102,7 +102,16 @@ typedef std::vector< sal_Int32 > Int32Vector; class VCL_DLLPUBLIC SalGraphics { int m_nLayout; // 0: mirroring off, 1: mirror x-axis + +protected: + // flags which hold the SetAntialiasing() value from OutputDevice + bool m_bAntiAliasB2DDraw; + public: + // get/set AA + void setAntiAliasB2DDraw(bool bNew) { m_bAntiAliasB2DDraw = bNew; } + bool getAntiAliasB2DDraw() const { return m_bAntiAliasB2DDraw; } + SalGraphics(); virtual ~SalGraphics(); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 6291c011fee1..a67d6fa7feac 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1504,92 +1504,99 @@ SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic ) // read Id rIStm >> nTmp; - if( !rIStm.GetError() && NATIVE_FORMAT_50 == nTmp ) + // if there is no more data, avoid further expensive + // reading which will create VDevs and other stuff, just to + // read nothing. CAUTION: Eof is only true AFTER reading another + // byte, a speciality of SvMemoryStream (!) + if(!rIStm.GetError() && !rIStm.IsEof()) { - Graphic aGraphic; - GfxLink aLink; - VersionCompat* pCompat; + if( NATIVE_FORMAT_50 == nTmp ) + { + Graphic aGraphic; + GfxLink aLink; + VersionCompat* pCompat; - // read compat info - pCompat = new VersionCompat( rIStm, STREAM_READ ); - delete pCompat; + // read compat info + pCompat = new VersionCompat( rIStm, STREAM_READ ); + delete pCompat; - rIStm >> aLink; + rIStm >> aLink; - // set dummy link to avoid creation of additional link after filtering; - // we set a default link to avoid unnecessary swapping of native data - aGraphic.SetLink( GfxLink() ); + // set dummy link to avoid creation of additional link after filtering; + // we set a default link to avoid unnecessary swapping of native data + aGraphic.SetLink( GfxLink() ); - if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) ) - { - // set link only, if no other link was set - const BOOL bSetLink = ( rImpGraphic.mpGfxLink == NULL ); + if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) ) + { + // set link only, if no other link was set + const BOOL bSetLink = ( rImpGraphic.mpGfxLink == NULL ); - // assign graphic - rImpGraphic = *aGraphic.ImplGetImpGraphic(); + // assign graphic + rImpGraphic = *aGraphic.ImplGetImpGraphic(); - if( aLink.IsPrefMapModeValid() ) - rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() ); + if( aLink.IsPrefMapModeValid() ) + rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() ); - if( aLink.IsPrefSizeValid() ) - rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() ); + if( aLink.IsPrefSizeValid() ) + rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() ); - if( bSetLink ) - rImpGraphic.ImplSetLink( aLink ); + if( bSetLink ) + rImpGraphic.ImplSetLink( aLink ); + } + else + { + rIStm.Seek( nStmPos1 ); + rIStm.SetError( ERRCODE_IO_WRONGFORMAT ); + } } else { - rIStm.Seek( nStmPos1 ); - rIStm.SetError( ERRCODE_IO_WRONGFORMAT ); - } - } - else - { - BitmapEx aBmpEx; - const USHORT nOldFormat = rIStm.GetNumberFormatInt(); + BitmapEx aBmpEx; + const USHORT nOldFormat = rIStm.GetNumberFormatInt(); - rIStm.SeekRel( -4 ); - rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - rIStm >> aBmpEx; + rIStm.SeekRel( -4 ); + rIStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + rIStm >> aBmpEx; - if( !rIStm.GetError() ) - { - UINT32 nMagic1(0), nMagic2(0); - ULONG nActPos = rIStm.Tell(); + if( !rIStm.GetError() ) + { + UINT32 nMagic1(0), nMagic2(0); + ULONG nActPos = rIStm.Tell(); - rIStm >> nMagic1 >> nMagic2; - rIStm.Seek( nActPos ); + rIStm >> nMagic1 >> nMagic2; + rIStm.Seek( nActPos ); - rImpGraphic = ImpGraphic( aBmpEx ); + rImpGraphic = ImpGraphic( aBmpEx ); - if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) ) - { - delete rImpGraphic.mpAnimation; - rImpGraphic.mpAnimation = new Animation; - rIStm >> *rImpGraphic.mpAnimation; + if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) ) + { + delete rImpGraphic.mpAnimation; + rImpGraphic.mpAnimation = new Animation; + rIStm >> *rImpGraphic.mpAnimation; - // #108077# manually set loaded BmpEx to Animation - // (which skips loading its BmpEx if already done) - rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx); + // #108077# manually set loaded BmpEx to Animation + // (which skips loading its BmpEx if already done) + rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx); + } + else + rIStm.ResetError(); } else + { + GDIMetaFile aMtf; + + rIStm.Seek( nStmPos1 ); rIStm.ResetError(); - } - else - { - GDIMetaFile aMtf; + rIStm >> aMtf; - rIStm.Seek( nStmPos1 ); - rIStm.ResetError(); - rIStm >> aMtf; + if( !rIStm.GetError() ) + rImpGraphic = aMtf; + else + rIStm.Seek( nStmPos1 ); + } - if( !rIStm.GetError() ) - rImpGraphic = aMtf; - else - rIStm.Seek( nStmPos1 ); + rIStm.SetNumberFormatInt( nOldFormat ); } - - rIStm.SetNumberFormatInt( nOldFormat ); } } diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 9c94811e0122..2c33d069b007 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -791,6 +791,7 @@ int OutputDevice::ImplGetGraphics() const if ( mpGraphics ) { mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp ); + mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW); return TRUE; } @@ -2735,15 +2736,14 @@ void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly if( mbInitFillColor ) ImplInitFillColor(); - if(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) + if( (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) != 0 + && mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) ) { -#ifdef UNX // b2dpolygon support not implemented yet on non-UNX platforms const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); ::basegfx::B2DPolyPolygon aB2DPP = rB2DPolyPoly; aB2DPP.transform( aTransform ); if( mpGraphics->DrawPolyPolygon( aB2DPP, 0.0, this ) ) return; -#endif } // fallback to old polygon drawing if needed diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 4a682c4cecc9..19a9778ebb04 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -5351,6 +5351,11 @@ void OutputDevice::SetAntialiasing( USHORT nMode ) { mnAntialiasing = nMode; mbInitFont = TRUE; + + if(mpGraphics) + { + mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW); + } } if( mpAlphaVDev ) diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index 4e3bba322bc8..d4c24ff44e20 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -186,9 +186,9 @@ fprintf(stderr,"OD::DT( fT=%f, bAA=%d)\n",fTransparency,mnAntialiasing);//###### if( mbInitFillColor ) ImplInitFillColor(); - if(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) + if( (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) != 0 + && mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) ) { -#ifdef UNX // b2dpolygon support not implemented yet on non-UNX platforms const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); ::basegfx::B2DPolyPolygon aB2DPP = rB2DPolyPoly; @@ -209,7 +209,6 @@ fprintf(stderr,"OD::DT( fT=%f, bAA=%d)\n",fTransparency,mnAntialiasing);//###### #endif return; } -#endif } // fallback to old polygon drawing if needed @@ -265,7 +264,12 @@ void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly, // try hard to draw it directly, because the emulation layers are slower if( !pDisableNative - && mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) ) + && mpGraphics->supportsOperation( OutDevSupport_B2DDraw ) +#ifdef WIN32 + // workaround bad dithering on remote displaying when using GDI+ with toolbar buttoin hilighting + && !rPolyPoly.IsRect() +#endif + ) { // prepare the graphics device if( mbInitClipRegion ) diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 339cc875256f..509ad4f725ce 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -81,7 +81,8 @@ SalFrameGeometry SalFrame::GetGeometry() // ---------------------------------------------------------------------------- SalGraphics::SalGraphics() - : m_nLayout( 0 ) +: m_nLayout( 0 ), + m_bAntiAliasB2DDraw(false) { // read global RTL settings if( Application::GetSettings().GetLayoutRTL() ) diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index bc50f464269b..dabce7c59b9e 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1183,9 +1183,18 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly { const int k = (nPointIdx < nPointCount) ? nPointIdx : 0; const ::basegfx::B2DPoint& aPoint = aInnerPolygon.getB2DPoint( k ); + // convert the B2DPoint into XRENDER units - aNewXPF.x = XDoubleToFixed( aPoint.getX() ); - aNewXPF.y = XDoubleToFixed( aPoint.getY() ); + if(getAntiAliasB2DDraw()) + { + aNewXPF.x = XDoubleToFixed( aPoint.getX() ); + aNewXPF.y = XDoubleToFixed( aPoint.getY() ); + } + else + { + aNewXPF.x = XDoubleToFixed( basegfx::fround( aPoint.getX() ) ); + aNewXPF.y = XDoubleToFixed( basegfx::fround( aPoint.getY() ) ); + } // check if enough data is available for a new HalfTrapezoid if( nPointIdx == 0 ) diff --git a/vcl/unx/source/gdi/salgdi2.cxx b/vcl/unx/source/gdi/salgdi2.cxx index 8086ea8e8ea5..c10abac60bb0 100644 --- a/vcl/unx/source/gdi/salgdi2.cxx +++ b/vcl/unx/source/gdi/salgdi2.cxx @@ -1158,6 +1158,7 @@ bool X11SalGraphics::supportsOperation( OutDevSupportType eType ) const switch( eType ) { case OutDevSupport_TransparentRect: + case OutDevSupport_B2DDraw: { XRenderPeer& rPeer = XRenderPeer::GetInstance(); if( rPeer.GetVersion() >= 0x02 ) diff --git a/vcl/util/makefile.mk b/vcl/util/makefile.mk index 34b0e331a9e5..98fe62caae26 100644 --- a/vcl/util/makefile.mk +++ b/vcl/util/makefile.mk @@ -229,7 +229,8 @@ SHL1STDLIBS += $(PSPLIB) SHL1STDLIBS += $(UWINAPILIB) \ $(GDI32LIB) \ - $(MSIMG32LIB) \ + $(GDIPLUSLIB) \ + $(MSIMG32LIB) \ $(WINSPOOLLIB) \ $(OLE32LIB) \ $(SHELL32LIB) \ diff --git a/vcl/win/inc/saldata.hxx b/vcl/win/inc/saldata.hxx index abd88cbbc639..d743a7b7dae1 100644 --- a/vcl/win/inc/saldata.hxx +++ b/vcl/win/inc/saldata.hxx @@ -135,6 +135,9 @@ public: TempFontItem* mpTempFontItem; BOOL mbThemeChanged; // true if visual theme was changed: throw away theme handles + // for GdiPlus GdiplusStartup/GdiplusShutdown + ULONG_PTR gdiplusToken; + std::set< HMENU > mhMenuSet; // keeps track of menu handles created by VCL, used by IsKnownMenuHandle() std::map< UINT,USHORT > maVKMap; // map some dynamic VK_* entries }; diff --git a/vcl/win/inc/salgdi.h b/vcl/win/inc/salgdi.h index b2f1158f91f5..cea6fc5dbbb3 100644 --- a/vcl/win/inc/salgdi.h +++ b/vcl/win/inc/salgdi.h @@ -167,6 +167,10 @@ public: BOOL mbScreen; // is Screen compatible bool mbXORMode; // _every_ output with RasterOp XOR + // remember RGB values for SetLineColor/SetFillColor + SalColor maLineColor; + SalColor maFillColor; + HFONT ImplDoSetFont( ImplFontSelectData* i_pFont, float& o_rFontScale, HFONT& o_rOldFont ); public: diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx index b1ee05a9c2e3..d57cdd48eed2 100644 --- a/vcl/win/source/app/salinst.cxx +++ b/vcl/win/source/app/salinst.cxx @@ -56,6 +56,25 @@ #include <vcl/timer.hxx> #include <wincomp.hxx> // CS_DROPSHADOW +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#if defined _MSC_VER +#pragma warning(push, 1) +#endif + +#include <GdiPlus.h> +#include <GdiPlusEnums.h> +#include <GdiPlusColor.h> + +#if defined _MSC_VER +#pragma warning(pop) +#endif + // ======================================================================= void SalAbort( const XubString& rErrorText ) @@ -418,6 +437,9 @@ SalData::SalData() mpTempFontItem = 0; mbThemeChanged = FALSE; // true if visual theme was changed: throw away theme handles + // init with NULL + gdiplusToken = 0; + initKeyCodeMap(); SetSalData( this ); @@ -433,8 +455,11 @@ SalData::~SalData() void InitSalData() { SalData* pSalData = new SalData; - (void)pSalData; CoInitialize(0); +
+ // init GDIPlus
+ static Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&pSalData->gdiplusToken, &gdiplusStartupInput, NULL);
} @@ -442,6 +467,13 @@ void DeInitSalData() { CoUninitialize(); SalData* pSalData = GetSalData(); + + // deinit GDIPlus + if(pSalData) + { + Gdiplus::GdiplusShutdown(pSalData->gdiplusToken);
+ } + delete pSalData; } diff --git a/vcl/win/source/gdi/MAKEFILE.MK b/vcl/win/source/gdi/MAKEFILE.MK index d9cdd067edb3..d50abc1b5aa3 100644 --- a/vcl/win/source/gdi/MAKEFILE.MK +++ b/vcl/win/source/gdi/MAKEFILE.MK @@ -54,6 +54,7 @@ CFLAGS += -DWINVER=0x0400 SLOFILES= $(SLO)$/salgdi.obj \ $(SLO)$/salgdi2.obj \ $(SLO)$/salgdi3.obj \ + $(SLO)$/salgdi_gdiplus.obj \ $(SLO)$/salvd.obj \ $(SLO)$/salprn.obj \ $(SLO)$/salbmp.obj \ diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index 100e338fb45d..55caa086a57a 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -1006,6 +1006,7 @@ void WinSalGraphics::SetLineColor() void WinSalGraphics::SetLineColor( SalColor nSalColor ) { + maLineColor = nSalColor; COLORREF nPenColor = PALETTERGB( SALCOLOR_RED( nSalColor ), SALCOLOR_GREEN( nSalColor ), SALCOLOR_BLUE( nSalColor ) ); @@ -1087,6 +1088,7 @@ void WinSalGraphics::SetFillColor() void WinSalGraphics::SetFillColor( SalColor nSalColor ) { + maFillColor = nSalColor; SalData* pSalData = GetSalData(); BYTE nRed = SALCOLOR_RED( nSalColor ); BYTE nGreen = SALCOLOR_GREEN( nSalColor ); @@ -1418,25 +1420,6 @@ void WinSalGraphics::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoint // ----------------------------------------------------------------------- -bool WinSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) -{ - // TODO: implement and advertise OutDevSupport_B2DDraw support - return false; -} - -// ----------------------------------------------------------------------- - -bool WinSalGraphics::drawPolyLine( - const basegfx::B2DPolygon& /*rPolygon*/, - const basegfx::B2DVector& /*rLineWidths*/, - basegfx::B2DLineJoin /*eLineJoin*/) -{ - // TODO: implement - return false; -} - -// ----------------------------------------------------------------------- - #define SAL_POLY_STACKBUF 32 // ----------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salgdi2.cxx b/vcl/win/source/gdi/salgdi2.cxx index 0498a57f43fc..0a60c6971213 100644 --- a/vcl/win/source/gdi/salgdi2.cxx +++ b/vcl/win/source/gdi/salgdi2.cxx @@ -46,12 +46,16 @@ bool WinSalGraphics::supportsOperation( OutDevSupportType eType ) const { + static bool bAllowForTest(true); bool bRet = false; + switch( eType ) { case OutDevSupport_TransparentRect: bRet = mbVirDev || mbWindow; break; + case OutDevSupport_B2DDraw: + bRet = bAllowForTest; default: break; } return bRet; diff --git a/vcl/win/source/gdi/salgdi_gdiplus.cxx b/vcl/win/source/gdi/salgdi_gdiplus.cxx new file mode 100644 index 000000000000..8709fc872540 --- /dev/null +++ b/vcl/win/source/gdi/salgdi_gdiplus.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * 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: salgdi.cxx,v $ + * $Revision: 1.36 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_vcl.hxx" + +#include <stdio.h> +#include <string.h> +#include <tools/svwin.h> +#include <wincomp.hxx> +#include <saldata.hxx> +#include <salgdi.h> +#include <tools/debug.hxx> + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#if defined _MSC_VER +#pragma warning(push, 1) +#endif + +#include <GdiPlus.h> +#include <GdiPlusEnums.h> +#include <GdiPlusColor.h> + +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include <basegfx/polygon/b2dpolygon.hxx> + +// ----------------------------------------------------------------------- + +void impAddB2DPolygonToGDIPlusGraphicsPath(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon) +{ + const 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::PointF aFCurr(Gdiplus::REAL(aCurr.getX()), Gdiplus::REAL(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::PointF aFNext(Gdiplus::REAL(aNext.getX()), Gdiplus::REAL(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(
+ aFCurr,
+ Gdiplus::PointF(Gdiplus::REAL(aCa.getX()), Gdiplus::REAL(aCa.getY())),
+ Gdiplus::PointF(Gdiplus::REAL(aCb.getX()), Gdiplus::REAL(aCb.getY())),
+ aFNext);
+ }
+ else
+ {
+ rPath.AddLine(aFCurr, aFNext);
+ }
+
+ if(a + 1 < nEdgeCount)
+ {
+ aCurr = aNext;
+ aFCurr = aFNext;
+ }
+ }
+ }
+} + +bool WinSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency) +{ + const sal_uInt32 nCount(rPolyPolygon.count());
+ + if(mbBrush && nCount && (fTransparency >= 0.0 && fTransparency < 1.0)) + { + Gdiplus::Graphics aGraphics(mhDC);
+ const sal_uInt8 aTrans((sal_uInt8)255 - (sal_uInt8)basegfx::fround(fTransparency * 255.0)); + Gdiplus::Color aTestColor(aTrans, SALCOLOR_RED(maFillColor), SALCOLOR_GREEN(maFillColor), SALCOLOR_BLUE(maFillColor));
+ Gdiplus::SolidBrush aTestBrush(aTestColor);
+ Gdiplus::GraphicsPath aPath;
+ + for(sal_uInt32 a(0); a < nCount; a++) + { + aPath.StartFigure(); + impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolyPolygon.getB2DPolygon(a)); + aPath.CloseFigure(); + } + + if(getAntiAliasB2DDraw()) + { + aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
+ }
+ else
+ {
+ aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
+ }
+
+ aGraphics.FillPath(&aTestBrush, &aPath);
+ } + + return true; +} + +bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin eLineJoin) +{ + const sal_uInt32 nCount(rPolygon.count());
+ + if(mbPen && nCount) + { + Gdiplus::Graphics aGraphics(mhDC);
+ Gdiplus::Color aTestColor(255, SALCOLOR_RED(maLineColor), SALCOLOR_GREEN(maLineColor), SALCOLOR_BLUE(maLineColor));
+ Gdiplus::Pen aTestPen(aTestColor, Gdiplus::REAL(rLineWidths.getX()));
+ Gdiplus::GraphicsPath aPath;
+
+ switch(eLineJoin)
+ {
+ default : // basegfx::B2DLINEJOIN_NONE : + { + break; + } + case basegfx::B2DLINEJOIN_BEVEL : + { + aTestPen.SetLineJoin(Gdiplus::LineJoinBevel);
+ break; + } + case basegfx::B2DLINEJOIN_MIDDLE : + case basegfx::B2DLINEJOIN_MITER : + { + const Gdiplus::REAL aMiterLimit(15.0); + aTestPen.SetMiterLimit(aMiterLimit);
+ aTestPen.SetLineJoin(Gdiplus::LineJoinMiter);
+ break; + } + case basegfx::B2DLINEJOIN_ROUND : + { + aTestPen.SetLineJoin(Gdiplus::LineJoinRound);
+ break; + } + }
+ + impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolygon); +
+ if(getAntiAliasB2DDraw())
+ {
+ aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
+ }
+ else
+ {
+ aGraphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
+ }
+
+ aGraphics.DrawPath(&aTestPen, &aPath);
+ } + + return true; +} + +// ----------------------------------------------------------------------- |