diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-02-19 18:36:23 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-02-24 12:40:13 +0100 |
commit | 5ba5ac948db1092712ffeaef41983ea5f5dcb5cc (patch) | |
tree | 1efc83d9f17c5f458908300eb9d918e665531662 /canvas | |
parent | f57872d2da23c8a3f90c67b6ad4a3ad0f699a276 (diff) |
add additional 0-1 alpha argument to DrawTransformedBitmap()
This allows the VCL backends the apply the extra alpha transformation
as it sees fit, rather than it being done manually elsewhere (and
even if the backend doesn't implement it, at least do it in one
place in the function).
With the document from tdf#136223, going from slide 2 to slide 3,
this easily saves 10-30% of CPU cycles. As an additional bonus,
using AlphaMask::BlendWith() rather than AlphaMask::Replace()
makes edges of shapes noticeably more smooth.
Change-Id: I036dc9b887d6def0c7cdad3982becabdc7cd5206
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111247
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/vcl/canvashelper.cxx | 5 | ||||
-rw-r--r-- | canvas/source/vcl/spritehelper.cxx | 23 |
2 files changed, 4 insertions, 24 deletions
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 89ee207989c6..bec73b3d336a 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -723,13 +723,14 @@ namespace vclcanvas // itself serves this purpose return uno::Reference< rendering::XCachedPrimitive >(nullptr); } - else if( !bModulateColors && mpOutDevProvider->getOutDev().HasFastDrawTransformedBitmap()) + else if( mpOutDevProvider->getOutDev().HasFastDrawTransformedBitmap()) { ::basegfx::B2DHomMatrix aSizeTransform; aSizeTransform.scale( aBmpEx.GetSizePixel().Width(), aBmpEx.GetSizePixel().Height() ); aMatrix = aMatrix * aSizeTransform; + const double fAlpha = bModulateColors ? renderState.DeviceColor[3] : 1.0; - mpOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmpEx ); + mpOutDevProvider->getOutDev().DrawTransformedBitmapEx( aMatrix, aBmpEx, fAlpha ); if( mp2ndOutDevProvider ) { // HACK. Normally, CanvasHelper does not care about diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx index 31d16032e576..e8d4fa726e10 100644 --- a/canvas/source/vcl/spritehelper.cxx +++ b/canvas/source/vcl/spritehelper.cxx @@ -210,28 +210,7 @@ namespace vclcanvas aMoveTransform.translate( aOutPos.X(), aOutPos.Y() ); aTransform = aMoveTransform * aTransform * aSizeTransform; - if( ::rtl::math::approxEqual(fAlpha, 1.0) ) - { - // no alpha modulation -> just copy to output - rTargetSurface.DrawTransformedBitmapEx( aTransform, *maContent ); - } - else - { - // TODO(P3): Switch to OutputDevice::DrawTransparent() - // here - - // draw semi-transparent - sal_uInt8 nColor( static_cast<sal_uInt8>( ::basegfx::fround( 255.0*(1.0 - fAlpha) + .5) ) ); - AlphaMask aAlpha( maContent->GetSizePixel(), - &nColor ); - - // mask out fully transparent areas - if( maContent->IsTransparent() ) - aAlpha.Replace( maContent->GetMask(), 255 ); - - // alpha-blend to output - rTargetSurface.DrawTransformedBitmapEx( aTransform, BitmapEx( maContent->GetBitmap(), aAlpha ) ); - } + rTargetSurface.DrawTransformedBitmapEx( aTransform, *maContent, fAlpha ); rTargetSurface.Pop(); |