[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - vcl/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 11 07:03:29 PDT 2015


 vcl/source/gdi/impanmvw.cxx |   49 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 12 deletions(-)

New commits:
commit c5551a6a9ed7dbeb15cda52f0de0a5113f5c1551
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Aug 10 15:49:09 2015 +0200

    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 at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index 9d7cea0b..8dc2c49 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();
         }
     }
 }


More information about the Libreoffice-commits mailing list