From 09bd5846d57bf6b506b0967d664b2f80562e03fc Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 28 Jul 2015 17:40:22 +0200 Subject: tdf#92982 vcl: move Invert() member functions from vcl::Window to OutputDevice With this, vcl::Cursor will be able to paint to a vcl::RenderContext, too; not just directly, which is needed for double-buffering. Change-Id: I868f6cd9b08afe59611ef266911a894a26cacedc --- vcl/source/outdev/rect.cxx | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'vcl/source/outdev') diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index b06a52baa51f..d786649c0cb4 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -129,6 +129,72 @@ void OutputDevice::DrawRect( const Rectangle& rRect, mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound ); } +void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags ) +{ + if ( !IsDeviceOutputNecessary() ) + return; + + Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); + + if ( aRect.IsEmpty() ) + return; + aRect.Justify(); + + // we need a graphics + if ( !mpGraphics ) + { + if ( !AcquireGraphics() ) + return; + } + + if ( mbInitClipRegion ) + InitClipRegion(); + + if ( mbOutputClipped ) + return; + + SalInvert nSalFlags = 0; + if ( nFlags & InvertFlags::Highlight ) + nSalFlags |= SAL_INVERT_HIGHLIGHT; + if ( nFlags & InvertFlags::N50 ) + nSalFlags |= SAL_INVERT_50; + mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this ); +} + +void OutputDevice::Invert( const Polygon& rPoly, InvertFlags nFlags ) +{ + if ( !IsDeviceOutputNecessary() ) + return; + + sal_uInt16 nPoints = rPoly.GetSize(); + + if ( nPoints < 2 ) + return; + + Polygon aPoly( ImplLogicToDevicePixel( rPoly ) ); + + // we need a graphics + if ( !mpGraphics ) + { + if ( !AcquireGraphics() ) + return; + } + + if ( mbInitClipRegion ) + InitClipRegion(); + + if ( mbOutputClipped ) + return; + + SalInvert nSalFlags = 0; + if ( nFlags & InvertFlags::Highlight ) + nSalFlags |= SAL_INVERT_HIGHLIGHT; + if ( nFlags & InvertFlags::N50 ) + nSalFlags |= SAL_INVERT_50; + const SalPoint* pPtAry = reinterpret_cast(aPoly.GetConstPointAry()); + mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this ); +} + void OutputDevice::DrawCheckered(const Point& rPos, const Size& rSize, sal_uInt32 nLen, Color aStart, Color aEnd) { assert(!is_double_buffered_window()); -- cgit