Bugzilla – Attachment 188163 Details for
Bug 155912
Rendering problems in conversion of internal vcl bitmap formats transparency->alpha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Debug patch that removes all about dialog, slideshow, and export as PDF alpha mask hacks
reversealphamaskhacks.diff (text/plain), 18.19 KB, created by
Patrick Luby (volunteer)
on 2023-07-02 20:31:02 UTC
(
hide
)
Description:
Debug patch that removes all about dialog, slideshow, and export as PDF alpha mask hacks
Filename:
MIME Type:
Creator:
Patrick Luby (volunteer)
Created:
2023-07-02 20:31:02 UTC
Size:
18.19 KB
patch
obsolete
>diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx >index 271ede69f5e6..238ec4016559 100644 >--- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx >+++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx >@@ -230,7 +230,7 @@ namespace cppcanvas::internal > // VirtualDevice with alpha channel > ScopedVclPtrInstance<VirtualDevice> aVDev( > *::Application::GetDefaultDevice(), DeviceFormat::WITH_ALPHA ); >- aVDev->SetOutputSizePixel( aBitmapSizePixel, true, true ); >+ aVDev->SetOutputSizePixel( aBitmapSizePixel ); > > #if HAVE_FEATURE_SKIA > // When Skia is enabled, the output of the DrawTransparent() >diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx >index ce82e418cf9e..41d17b2a06d5 100644 >--- a/cui/source/dialogs/about.cxx >+++ b/cui/source/dialogs/about.cxx >@@ -26,9 +26,9 @@ > #include <osl/process.h> //osl_getProcessLocale > #include <rtl/bootstrap.hxx> > #include <sal/log.hxx> //SAL_WARN >-#include <vcl/graph.hxx> //Graphic > #include <vcl/settings.hxx> //GetSettings > #include <vcl/svapp.hxx> //Application:: >+#include <vcl/virdev.hxx> //VirtualDevice > #include <vcl/weld.hxx> > #include <unotools/resmgr.hxx> //Translate > >@@ -105,20 +105,20 @@ AboutDialog::AboutDialog(weld::Window *pParent) > ? "shell/logo_inverted" > : "shell/logo", > aBackgroundBitmap, nWidth * 0.8)) { >- // Eliminate white background when Skia is disabled by not drawing the >- // background bitmap to a VirtualDevice. On most platforms, non-Skia >- // VirtualDevices will be filled with a solid color when drawing >- // the bitmap. >- Graphic aGraphic(aBackgroundBitmap); >- m_pBrandImage->set_image(aGraphic.GetXGraphic()); >+ ScopedVclPtr<VirtualDevice> m_pVirDev = >+ m_pBrandImage->create_virtual_device(); >+ m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel()); >+ m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap); >+ m_pBrandImage->set_image(m_pVirDev.get()); >+ m_pVirDev.disposeAndClear(); > } > if (SfxApplication::loadBrandSvg("shell/about", aBackgroundBitmap, nWidth * 0.9)) { >- // Eliminate white background when Skia is disabled by not drawing the >- // background bitmap to a VirtualDevice. On most platforms, non-Skia >- // VirtualDevices will be filled with a solid color when drawing >- // the bitmap. >- Graphic aGraphic(aBackgroundBitmap); >- m_pAboutImage->set_image(aGraphic.GetXGraphic()); >+ ScopedVclPtr<VirtualDevice> m_pVirDev = >+ m_pAboutImage->create_virtual_device(); >+ m_pVirDev->SetOutputSizePixel(aBackgroundBitmap.GetSizePixel()); >+ m_pVirDev->DrawBitmapEx(Point(0, 0), aBackgroundBitmap); >+ m_pAboutImage->set_image(m_pVirDev.get()); >+ m_pVirDev.disposeAndClear(); > } > > // Links >diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx >index 40cf445f0390..0f6ec8ee1857 100644 >--- a/include/vcl/virdev.hxx >+++ b/include/vcl/virdev.hxx >@@ -58,7 +58,7 @@ private: > 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 ); >+ sal_uInt8* pBuffer ); > > VirtualDevice (const VirtualDevice &) = delete; > VirtualDevice & operator= (const VirtualDevice &) = delete; >@@ -124,7 +124,7 @@ public: > > virtual void EnableRTL( bool bEnable = true ) override; > >- bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true, bool bAlphaMaskTransparent = false ); >+ bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true ); > bool SetOutputSizePixelScaleOffsetAndLOKBuffer( const Size& rNewSize, > const Fraction& rScale, > const Point& rNewOffset, >diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx >index 78a4189e75be..e309cc21a3b9 100644 >--- a/vcl/source/gdi/pdfwriter_impl2.cxx >+++ b/vcl/source/gdi/pdfwriter_impl2.cxx >@@ -45,7 +45,6 @@ > > #include <cppuhelper/implbase.hxx> > #include <o3tl/unit_conversion.hxx> >-#include <vcl/skia/SkiaHelper.hxx> > > #include <sal/log.hxx> > #include <memory> >@@ -463,15 +462,16 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa > if ( nPixelX && nPixelY ) > { > Size aDstSizePixel( nPixelX, nPixelY ); >- ScopedVclPtrInstance<VirtualDevice> xVDev(DeviceFormat::WITH_ALPHA); >- if( xVDev->SetOutputSizePixel( aDstSizePixel, true, true ) ) >+ ScopedVclPtrInstance<VirtualDevice> xVDev; >+ if( xVDev->SetOutputSizePixel( aDstSizePixel ) ) > { >+ Bitmap aPaint, aMask; >+ AlphaMask aAlpha; > Point aPoint; > > MapMode aMapMode( pDummyVDev->GetMapMode() ); > aMapMode.SetOrigin( aPoint ); > xVDev->SetMapMode( aMapMode ); >- const bool bVDevOldMap = xVDev->IsMapModeEnabled(); > Size aDstSize( xVDev->PixelToLogic( aDstSizePixel ) ); > > Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() ); >@@ -487,37 +487,34 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa > aTmpMtf.WindStart(); > aTmpMtf.Play(*xVDev, aPoint, aDstSize); > aTmpMtf.WindStart(); >+ > xVDev->EnableMapMode( false ); >- BitmapEx aPaint = xVDev->GetBitmapEx(aPoint, xVDev->GetOutputSizePixel()); >- xVDev->EnableMapMode( bVDevOldMap ); // #i35331#: MUST NOT use EnableMapMode( sal_True ) here! >+ aPaint = xVDev->GetBitmap( aPoint, aDstSizePixel ); >+ xVDev->EnableMapMode(); >+ >+ // create mask bitmap >+ xVDev->SetLineColor( COL_BLACK ); >+ xVDev->SetFillColor( COL_BLACK ); >+ xVDev->DrawRect( tools::Rectangle( aPoint, aDstSize ) ); >+ xVDev->SetDrawMode( DrawModeFlags::WhiteLine | DrawModeFlags::WhiteFill | DrawModeFlags::WhiteText | >+ DrawModeFlags::WhiteBitmap | DrawModeFlags::WhiteGradient ); >+ aTmpMtf.WindStart(); >+ aTmpMtf.Play(*xVDev, aPoint, aDstSize); >+ aTmpMtf.WindStart(); >+ xVDev->EnableMapMode( false ); >+ aMask = xVDev->GetBitmap( aPoint, aDstSizePixel ); >+ xVDev->EnableMapMode(); > > // create alpha mask from gradient > xVDev->SetDrawMode( DrawModeFlags::GrayGradient ); > xVDev->DrawGradient( tools::Rectangle( aPoint, aDstSize ), rTransparenceGradient ); > xVDev->SetDrawMode( DrawModeFlags::Default ); > xVDev->EnableMapMode( false ); >- >- AlphaMask aAlpha(xVDev->GetBitmap(Point(), xVDev->GetOutputSizePixel())); >- AlphaMask aPaintAlpha(aPaint.GetAlphaMask()); >-#if HAVE_FEATURE_SKIA >- // One of the alpha masks is inverted from what >- // is expected so invert it again >- if ( SkiaHelper::isVCLSkiaEnabled() ) >- { >- aAlpha.Invert(); // convert to alpha >- } >- else >-#endif >- { >- aPaintAlpha.Invert(); // convert to alpha >- } >- aAlpha.BlendWith(aPaintAlpha); >- aAlpha.Invert(); // convert to alpha >- >- xVDev.disposeAndClear(); >+ xVDev->DrawMask( aPoint, aDstSizePixel, aMask, COL_WHITE ); >+ aAlpha = xVDev->GetBitmap( aPoint, aDstSizePixel ); > > Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); >- implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint.GetBitmap(), aAlpha ), aGraphic, pDummyVDev, i_rContext ); >+ implWriteBitmapEx( rPos, rSize, BitmapEx( aPaint, aAlpha ), aGraphic, pDummyVDev, i_rContext ); > } > } > } >@@ -761,17 +758,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa > case MetaActionType::BMPEX: > { > const MetaBmpExAction* pA = static_cast<const MetaBmpExAction*>(pAction); >- >- // When rendering an image with an alpha mask during PDF >- // export, the alpha mask needs to be inverted >- BitmapEx aBitmapEx( pA->GetBitmapEx() ); >- if ( aBitmapEx.IsAlpha()) >- { >- AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); >- aAlpha.Invert(); >- aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); >- } >- >+ const BitmapEx& aBitmapEx( pA->GetBitmapEx() ); > Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(), > aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); > Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); >@@ -782,36 +769,15 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa > case MetaActionType::BMPEXSCALE: > { > const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction); >- >- // When rendering an image with an alpha mask during PDF >- // export, the alpha mask needs to be inverted >- BitmapEx aBitmapEx( pA->GetBitmapEx() ); >- if ( aBitmapEx.IsAlpha()) >- { >- AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); >- aAlpha.Invert(); >- aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); >- } >- > Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); >- implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext ); >+ implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), aGraphic, pDummyVDev, i_rContext ); > } > break; > > case MetaActionType::BMPEXSCALEPART: > { > const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pAction); >- >- // When rendering an image with an alpha mask during PDF >- // export, the alpha mask needs to be inverted > BitmapEx aBitmapEx( pA->GetBitmapEx() ); >- if ( aBitmapEx.IsAlpha()) >- { >- AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); >- aAlpha.Invert(); >- aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); >- } >- > aBitmapEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); > Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); > implWriteBitmapEx( pA->GetDestPoint(), pA->GetDestSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext ); >diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx >index b86c4ae49624..bbd0c77a1583 100644 >--- a/vcl/source/gdi/virdev.cxx >+++ b/vcl/source/gdi/virdev.cxx >@@ -352,7 +352,7 @@ void VirtualDevice::ImplFillOpaqueRectangle( const tools::Rectangle& rRect ) > } > > bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, >- sal_uInt8 *const pBuffer, bool bAlphaMaskTransparent ) >+ sal_uInt8 *const pBuffer) > { > if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) ) > { >@@ -368,7 +368,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, > { > mpAlphaVDev = VclPtr<VirtualDevice>::Create(*this, meFormatAndAlpha); > mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, nullptr); >- mpAlphaVDev->SetBackground( Wallpaper(bAlphaMaskTransparent ? COL_ALPHA_TRANSPARENT : COL_ALPHA_OPAQUE) ); >+ mpAlphaVDev->SetBackground( Wallpaper(COL_ALPHA_TRANSPARENT) ); > mpAlphaVDev->Erase(); > } > >@@ -402,9 +402,9 @@ void VirtualDevice::EnableRTL( bool bEnable ) > OutputDevice::EnableRTL(bEnable); > } > >-bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase, bool bAlphaMaskTransparent ) >+bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase ) > { >- return ImplSetOutputSizePixel(rNewSize, bErase, nullptr, bAlphaMaskTransparent); >+ return ImplSetOutputSizePixel(rNewSize, bErase, nullptr); > } > > bool VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer( >diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx >index d172d71c356a..209ad2b37f9e 100644 >--- a/vcl/source/outdev/transparent.cxx >+++ b/vcl/source/outdev/transparent.cxx >@@ -30,7 +30,6 @@ > #include <vcl/settings.hxx> > #include <vcl/svapp.hxx> > #include <vcl/virdev.hxx> >-#include <vcl/skia/SkiaHelper.hxx> > > #include <bitmap/BitmapWriteAccess.hxx> > #include <pdf/pdfwriter_impl.hxx> >@@ -602,12 +601,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, > xVDev->mnDPIX = mnDPIX; > xVDev->mnDPIY = mnDPIY; > >- bool bTransparentBackground = true; >-#if HAVE_FEATURE_SKIA >- if ( SkiaHelper::isVCLSkiaEnabled() ) >- bTransparentBackground = ( rTransparenceGradient.GetStartColor() == rTransparenceGradient.GetEndColor() ? false : true ); >-#endif >- if( xVDev->SetOutputSizePixel( aDstRect.GetSize(), true, bTransparentBackground ) ) >+ if( xVDev->SetOutputSizePixel( aDstRect.GetSize() ) ) > { > if(GetAntialiasing() != AntialiasingFlags::NONE) > { >@@ -646,7 +640,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, > // get content bitmap from buffer > xVDev->EnableMapMode(false); > >- const BitmapEx aPaint(xVDev->GetBitmapEx(aPoint, xVDev->GetOutputSizePixel())); >+ const Bitmap aPaint(xVDev->GetBitmap(aPoint, xVDev->GetOutputSizePixel())); > > // create alpha mask from gradient and get as Bitmap > xVDev->EnableMapMode(bBufferMapModeEnabled); >@@ -655,26 +649,12 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, > xVDev->SetDrawMode(DrawModeFlags::Default); > xVDev->EnableMapMode(false); > >- AlphaMask aAlpha(xVDev->GetBitmap(aPoint, xVDev->GetOutputSizePixel())); >- AlphaMask aPaintAlpha(aPaint.GetAlphaMask()); >-#if HAVE_FEATURE_SKIA >- // One of the alpha masks is inverted from what >- // is expected so invert it again >- if ( SkiaHelper::isVCLSkiaEnabled() ) >- { >- aAlpha.Invert(); // convert to alpha >- } >- else >-#endif >- { >- aPaintAlpha.Invert(); // convert to alpha >- } >- aAlpha.BlendWith(aPaintAlpha); >+ const AlphaMask aAlpha(xVDev->GetBitmap(aPoint, xVDev->GetOutputSizePixel())); > > xVDev.disposeAndClear(); > > // draw masked content to target and restore MapMode >- DrawBitmapEx(aDstRect.TopLeft(), BitmapEx(aPaint.GetBitmap(), aAlpha)); >+ DrawBitmapEx(aDstRect.TopLeft(), BitmapEx(aPaint, aAlpha)); > EnableMapMode(bOrigMapModeEnabled); > } > else >@@ -702,20 +682,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, > xVDev->EnableMapMode( false ); > > AlphaMask aAlpha(xVDev->GetBitmap(Point(), xVDev->GetOutputSizePixel())); >- AlphaMask aPaintAlpha(aPaint.GetAlphaMask()); >-#if HAVE_FEATURE_SKIA >- // One of the alpha masks is inverted from what >- // is expected so invert it again >- if ( SkiaHelper::isVCLSkiaEnabled() ) >- { >- aAlpha.Invert(); // convert to alpha >- } >- else >-#endif >- { >- aPaintAlpha.Invert(); // convert to alpha >- } >- aAlpha.BlendWith(aPaintAlpha); >+ aAlpha.BlendWith(aPaint.GetAlphaMask()); > > xVDev.disposeAndClear(); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 155912
:
187972
|
187973
|
188073
|
188074
|
188084
|
188091
|
188092
|
188093
|
188131
|
188132
|
188141
| 188163 |
188222
|
188233
|
188268
|
188395
|
188419
|
188515
|
188536
|
188541