Kaydet (Commit) c5551a6a authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Tor Lillqvist

tdf#93325 ImplAnimView rendercontext: stop painting animgifs directly

(cherry picked from commits 131d5b01 and
cd064472)

Change-Id: I34fb235a2e44eb510a630fb8dbcc2ec68cf96b79
Reviewed-on: https://gerrit.libreoffice.org/17642Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
Tested-by: 's avatarTor Lillqvist <tml@collabora.com>
üst 4eb0e4ac
......@@ -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();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment