summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-08-10 15:49:09 +0200
committerTor Lillqvist <tml@collabora.com>2015-08-11 14:03:09 +0000
commitc5551a6a9ed7dbeb15cda52f0de0a5113f5c1551 (patch)
treeccbf633d96d2f9afbdd6466f1f2f443be088967c
parent4eb0e4ace354df4c633aebc2f525911dd50e6f06 (diff)
tdf#93325 ImplAnimView rendercontext: stop painting animgifs directly
(cherry picked from commits 131d5b01f400899470925757658841080b09283a and cd064472ce4ff9d1dd6720c32fde22f36eb232f4) Change-Id: I34fb235a2e44eb510a630fb8dbcc2ec68cf96b79 Reviewed-on: https://gerrit.libreoffice.org/17642 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--vcl/source/gdi/impanmvw.cxx49
1 files changed, 37 insertions, 12 deletions
diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index 9d7cea0b529a..8dc2c49c8335 100644
--- a/vcl/source/gdi/impanmvw.cxx
+++ b/vcl/source/gdi/impanmvw.cxx
@@ -18,6 +18,7 @@
*/
#include "impanmvw.hxx"
+#include <window.h>
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
#include <tools/helpers.hxx>
@@ -153,8 +154,18 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size
void ImplAnimView::drawToPos( sal_uLong nPos )
{
+ VclPtr<vcl::RenderContext> pRenderContext = mpOut;
+
+ std::unique_ptr<PaintBufferGuard> pGuard;
+ if (mpOut->GetOutDevType() == OUTDEV_WINDOW)
+ {
+ vcl::Window* pWindow = static_cast<vcl::Window*>(mpOut.get());
+ pGuard.reset(new PaintBufferGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow));
+ pRenderContext = pGuard->GetRenderContext();
+ }
+
ScopedVclPtrInstance<VirtualDevice> aVDev;
- std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( mpOut->GetClipRegion() ) : NULL);
+ std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : NULL);
aVDev->SetOutputSizePixel( maSzPix, false );
nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1UL );
@@ -163,17 +174,29 @@ void ImplAnimView::drawToPos( sal_uLong nPos )
draw( i, aVDev.get() );
if (xOldClip)
- mpOut->SetClipRegion( maClip );
+ pRenderContext->SetClipRegion( maClip );
- mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *aVDev.get() );
+ pRenderContext->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *aVDev.get() );
+ if (pGuard)
+ pGuard->SetPaintRect(Rectangle(maDispPt, maDispSz));
if (xOldClip)
- mpOut->SetClipRegion(*xOldClip);
+ pRenderContext->SetClipRegion(*xOldClip);
}
void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
{
- Rectangle aOutRect( mpOut->PixelToLogic( Point() ), mpOut->GetOutputSize() );
+ VclPtr<vcl::RenderContext> pRenderContext = mpOut;
+
+ std::unique_ptr<PaintBufferGuard> pGuard;
+ if (!pVDev && mpOut->GetOutDevType() == OUTDEV_WINDOW)
+ {
+ vcl::Window* pWindow = static_cast<vcl::Window*>(mpOut.get());
+ pGuard.reset(new PaintBufferGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow));
+ pRenderContext = pGuard->GetRenderContext();
+ }
+
+ Rectangle aOutRect( pRenderContext->PixelToLogic( Point() ), pRenderContext->GetOutputSize() );
// check, if output lies out of display
if( aOutRect.Intersection( Rectangle( maDispPt, maDispSz ) ).IsEmpty() )
@@ -219,7 +242,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
{
pDev = VclPtr<VirtualDevice>::Create();
pDev->SetOutputSizePixel( maSzPix, false );
- pDev->DrawOutDev( Point(), maSzPix, maDispPt, maDispSz, *mpOut );
+ pDev->DrawOutDev( Point(), maSzPix, maDispPt, maDispSz, *pRenderContext );
}
else
pDev = pVDev;
@@ -260,23 +283,25 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev )
if( !pVDev )
{
- std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( mpOut->GetClipRegion() ) : NULL);
+ std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : NULL);
if (xOldClip)
- mpOut->SetClipRegion( maClip );
+ pRenderContext->SetClipRegion( maClip );
- mpOut->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *pDev );
+ pRenderContext->DrawOutDev( maDispPt, maDispSz, Point(), maSzPix, *pDev );
+ if (pGuard)
+ pGuard->SetPaintRect(Rectangle(maDispPt, maDispSz));
if( xOldClip)
{
- mpOut->SetClipRegion(*xOldClip);
+ pRenderContext->SetClipRegion(*xOldClip);
xOldClip.reset();
}
pDev.disposeAndClear();
- if( mpOut->GetOutDevType() == OUTDEV_WINDOW )
- static_cast<vcl::Window*>( mpOut.get() )->Sync();
+ if( pRenderContext->GetOutDevType() == OUTDEV_WINDOW )
+ static_cast<vcl::Window*>( pRenderContext.get() )->Sync();
}
}
}