include/vcl/virdev.hxx    |    2 --
 vcl/source/gdi/virdev.cxx |   27 ++++++++++++++++++---------
 2 files changed, 18 insertions(+), 11 deletions(-)

New commits:
commit 94e9c45d9a82d917738f46243173b4521e1ccd09
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jan 14 08:17:07 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jan 14 12:33:31 2025 +0100

    we never actually erase device in SetOutputSizePixelScaleOffsetAndLOKBuffer
    
    So simplify the code.
    
    The reason this currently "works" is that we always set the
    background to COL_TRANSPARENT, and when we do that,
    the DrawRect() logic will short-circuit and do nothing.
    
    Which also means we can inline ImplSetOutputSizePixel
    into SetOutputSizePixel, since it has only one call site.
    
    Change-Id: I0ae000e187fb7d18801ccfb61d1066f71f0c6cad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180213
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 40cf445f0390..6025658ce099 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -57,8 +57,6 @@ private:
     SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, 
tools::Long nDX, tools::Long nDY, const SystemGraphicsData *pData = nullptr );
     SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, 
bool bErase,
                                                      sal_uInt8* pBuffer );
-    SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool 
bErase,
-                                                sal_uInt8* pBuffer, bool 
bAlphaMaskTransparent = false );
 
     VirtualDevice (const VirtualDevice &) = delete;
     VirtualDevice & operator= (const VirtualDevice &) = delete;
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index b16cdb764a2b..9615cb8fa01e 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -351,10 +351,9 @@ void VirtualDevice::ImplFillOpaqueRectangle( const 
tools::Rectangle& rRect )
     Pop();
 }
 
-bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
-                                            sal_uInt8 *const pBuffer, bool 
bAlphaMaskTransparent )
+bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase, 
bool bAlphaMaskTransparent )
 {
-    if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
+    if( InnerImplSetOutputSizePixel(rNewSize, bErase, /*pBuffer*/nullptr) )
     {
         if (meFormatAndAlpha != DeviceFormat::WITHOUT_ALPHA)
         {
@@ -402,11 +401,6 @@ void VirtualDevice::EnableRTL( bool bEnable )
     OutputDevice::EnableRTL(bEnable);
 }
 
-bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase, 
bool bAlphaMaskTransparent )
-{
-    return ImplSetOutputSizePixel(rNewSize, bErase, nullptr, 
bAlphaMaskTransparent);
-}
-
 bool VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer(
     const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
     sal_uInt8 *const pBuffer)
@@ -420,7 +414,22 @@ bool 
VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer(
     mm.SetScaleX( rScale );
     mm.SetScaleY( rScale );
     SetMapMode( mm );
-    return ImplSetOutputSizePixel(rNewSize, true, pBuffer);
+
+    assert(meFormatAndAlpha == DeviceFormat::WITHOUT_ALPHA);
+    assert(mpVirDev);
+    assert( rNewSize != GetOutputSizePixel() &&  "Trying to re-use a 
VirtualDevice but this time using a pre-allocated buffer");
+    assert( rNewSize.Width() >= 1 );
+    assert( rNewSize.Height() >= 1 );
+
+    bool bRet = mpVirDev->SetSizeUsingBuffer( rNewSize.Width(), 
rNewSize.Height(), pBuffer );
+    if ( bRet )
+    {
+        mnOutWidth  = rNewSize.Width();
+        mnOutHeight = rNewSize.Height();
+    }
+
+    return bRet;
+
 }
 
 void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )

Reply via email to