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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2025-01-14 08:17:07 +02:00
parent 1f1ac2464e
commit 94e9c45d9a
2 changed files with 18 additions and 11 deletions

View File

@@ -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;

View File

@@ -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 )