summaryrefslogtreecommitdiff
path: root/vcl/source/outdev
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-09-29 09:42:14 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-09-30 11:38:37 +0200
commit6b709ad5d46dc33f29ec28183cea40cf9e77e2af (patch)
tree5d43b248f42543c88862a84c5283969dc63e3f59 /vcl/source/outdev
parent09c24681a3414092fde50ec0f617c9f7c79e8a61 (diff)
fix DrawDeviceAlphaBitmap() with mirroring (tdf#136223)
It turns out even the slow path was broken, so make it work (a hack, but it's already slow anyway, and apparently not used often). Also make the fast paths work directly, even with manual mirroring it should be still faster. Change-Id: Id798351f349e9906e85c1685f269df98a1b833b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103595 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r--vcl/source/outdev/bitmap.cxx47
1 files changed, 33 insertions, 14 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index a9f264fa2854..bcab1a4d7793 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -632,23 +632,34 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
ClipToPaintRegion(aDstRect);
+ BmpMirrorFlags mirrorFlags = BmpMirrorFlags::NONE;
if (bHMirr)
{
aOutSz.setWidth( -aOutSz.Width() );
aOutPt.AdjustX( -(aOutSz.Width() - 1) );
+ mirrorFlags |= BmpMirrorFlags::Horizontal;
}
if (bVMirr)
{
aOutSz.setHeight( -aOutSz.Height() );
aOutPt.AdjustY( -(aOutSz.Height() - 1) );
+ mirrorFlags |= BmpMirrorFlags::Vertical;
}
if (aDstRect.Intersection(tools::Rectangle(aOutPt, aOutSz)).IsEmpty())
return;
+ bool bTryDirectPaint = false;
+ if(SkiaHelper::isVCLSkiaEnabled())
+ bTryDirectPaint = true;
+#if HAVE_FEATURE_OPENGL
+ if(OpenGLHelper::isVCLOpenGLEnabled())
+ bTryDirectPaint = true;
+#endif
static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA");
- bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr);
+ if(pDisableNative)
+ bTryDirectPaint = false;
if (bTryDirectPaint)
{
@@ -659,8 +670,15 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
aRelPt.X(), aRelPt.Y(),
aOutSz.Width(), aOutSz.Height());
- SalBitmap* pSalSrcBmp = rBmp.ImplGetSalBitmap().get();
- SalBitmap* pSalAlphaBmp = rAlpha.ImplGetSalBitmap().get();
+ Bitmap bitmap(rBmp);
+ AlphaMask alpha(rAlpha);
+ if(bHMirr || bVMirr)
+ {
+ bitmap.Mirror(mirrorFlags);
+ alpha.Mirror(mirrorFlags);
+ }
+ SalBitmap* pSalSrcBmp = bitmap.ImplGetSalBitmap().get();
+ SalBitmap* pSalAlphaBmp = alpha.ImplGetSalBitmap().get();
// #i83087# Naturally, system alpha blending (SalGraphics::DrawAlphaBitmap) cannot work
// with separate alpha VDev
@@ -683,25 +701,26 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
if (mpGraphics->DrawAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, this))
return;
}
+ assert(false);
}
- // we need to make sure OpenGL never reaches this slow code path
- // tdf#136223: The slow code path will be obviously also reached if mirroring
- // is used, which makes the block above be skipped, as the blend bitmap calls
- // do not handle that case. Given that this seems to be rather rare, just
- // disable the assert, until faster mirroring is actually needed.
-
- assert(!SkiaHelper::isVCLSkiaEnabled() || !bTryDirectPaint);
-#if HAVE_FEATURE_OPENGL
- assert(!OpenGLHelper::isVCLOpenGLEnabled() || !bTryDirectPaint);
-#endif
tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel());
if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty())
{
Point auxOutPt(LogicToPixel(rDestPt));
Size auxOutSz(LogicToPixel(rDestSize));
- DrawDeviceAlphaBitmapSlowPath(rBmp, rAlpha, aDstRect, aBmpRect, auxOutSz, auxOutPt);
+ // HACK: The function is broken with alpha vdev and mirroring, mirror here.
+ Bitmap bitmap(rBmp);
+ AlphaMask alpha(rAlpha);
+ if(mpAlphaVDev && (bHMirr || bVMirr))
+ {
+ bitmap.Mirror(mirrorFlags);
+ alpha.Mirror(mirrorFlags);
+ auxOutPt = aOutPt;
+ auxOutSz = aOutSz;
+ }
+ DrawDeviceAlphaBitmapSlowPath(bitmap, alpha, aDstRect, aBmpRect, auxOutSz, auxOutPt);
}
}