diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-09-02 11:45:10 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-09-04 17:29:13 +0200 |
commit | c5b6f8d6469850e14362f2c8f08cdf8c956cbf07 (patch) | |
tree | c2805f3ce0e36c26e88d9ba3e44de2d47e0e3461 /vcl/source/outdev | |
parent | c4ea034beb2fa0f1e874a39391a9498bdd7c7aad (diff) |
fix erasing virtual device with alpha
The background cannot be simply set as background also for the internal
alpha virtual device, since this hackish alpha uses black = opaque
and white = transparent. So e.g. setting to background to COL_WHITE
actually resulted in the content being transparent.
Try to map to what the alpha virtual device actually needs.
Change-Id: Ie5179769d9bce989eddfc96f5cbd2b94d1d88d53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101927
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r-- | vcl/source/outdev/outdevstate.cxx | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 804ba883c210..4ab3093b573b 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -455,7 +455,44 @@ void OutputDevice::SetBackground( const Wallpaper& rBackground ) mbBackground = true; if( mpAlphaVDev ) - mpAlphaVDev->SetBackground( rBackground ); + { + // Some of these are probably wrong (e.g. if the gradient has transparency), + // but hopefully nobody uses that. If you do, feel free to implement it properly. + if( rBackground.GetStyle() == WallpaperStyle::NONE ) + mpAlphaVDev->SetBackground( rBackground ); + else if( rBackground.IsBitmap()) + { + BitmapEx bitmap = rBackground.GetBitmap(); + if( bitmap.IsAlpha()) + mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( Bitmap( bitmap.GetAlpha())))); + else + { + switch( bitmap.GetTransparentType()) + { + case TransparentType::NONE: + mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); + break; + case TransparentType::Color: + { + AlphaMask mask( bitmap.GetBitmap().CreateMask( bitmap.GetTransparentColor())); + mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( bitmap.GetBitmap(), mask ))); + break; + } + case TransparentType::Bitmap: + mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( bitmap.GetMask()))); + break; + } + } + } + else if( rBackground.IsGradient()) + mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); + else + { + // Color background. + int transparency = rBackground.GetColor().GetTransparency(); + mpAlphaVDev->SetBackground( Wallpaper( Color( transparency, transparency, transparency ))); + } + } } void OutputDevice::SetFont( const vcl::Font& rNewFont ) |