summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-18 12:34:53 -0500
committerJan Holesovsky <kendy@collabora.com>2014-11-22 20:14:16 +0100
commit4b6feefa51405e1313de62e1a19c4c213e79c22f (patch)
tree13796bcb39957f93c01bf338fc605204027bee48 /vcl/source
parent121b8487f13b4ac3e3a9517a02000c9fe55afd68 (diff)
vcl: Add support for backend-dependent blending of bitmaps (mask and alpha)
Change-Id: Iba64eb42965c86ca5655b9a105ef3f397e033ecf
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/salgdilayout.cxx30
-rw-r--r--vcl/source/outdev/bitmap.cxx27
2 files changed, 54 insertions, 3 deletions
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 59b39ced9cee..dc419a0b7ef4 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -738,6 +738,36 @@ bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart,
rNativeBoundingRegion, rNativeContentRegion );
}
+bool SalGraphics::BlendBitmap( const SalTwoRect& rPosAry,
+ const SalBitmap& rBitmap,
+ const OutputDevice *pOutDev )
+{
+ if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
+ {
+ SalTwoRect aPosAry2 = rPosAry;
+ mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
+ return blendBitmap( aPosAry2, rBitmap );
+ }
+ else
+ return blendBitmap( rPosAry, rBitmap );
+}
+
+bool SalGraphics::BlendAlphaBitmap( const SalTwoRect& rPosAry,
+ const SalBitmap& rSrcBitmap,
+ const SalBitmap& rMaskBitmap,
+ const SalBitmap& rAlphaBitmap,
+ const OutputDevice *pOutDev )
+{
+ if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
+ {
+ SalTwoRect aPosAry2 = rPosAry;
+ mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
+ return blendAlphaBitmap( aPosAry2, rSrcBitmap, rMaskBitmap, rAlphaBitmap );
+ }
+ else
+ return blendAlphaBitmap( rPosAry, rSrcBitmap, rMaskBitmap, rAlphaBitmap );
+}
+
bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry,
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap,
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 93a04b850372..cb7d594aea89 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -648,7 +648,7 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA");
// #i83087# Naturally, system alpha blending cannot work with
// separate alpha VDev
- bool bTryDirectPaint(!mpAlphaVDev && !pDisableNative && !bHMirr && !bVMirr);
+ bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr);
if(bTryDirectPaint)
{
@@ -662,8 +662,22 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
SalBitmap* pSalSrcBmp = rBmp.ImplGetImpBitmap()->ImplGetSalBitmap();
SalBitmap* pSalAlphaBmp = rAlpha.ImplGetImpBitmap()->ImplGetSalBitmap();
- if (mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this ))
- return;
+ // try the blen the alpha bitmap with the alpha virtual device
+ if( mpAlphaVDev )
+ {
+ Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) );
+ SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetImpBitmap()->ImplGetSalBitmap();
+ if( mpGraphics->BlendAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this ) )
+ {
+ mpAlphaVDev->BlendBitmap( aTR, rAlpha );
+ return;
+ }
+ }
+ else
+ {
+ if (mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this ))
+ return;
+ }
}
// we need to make sure OpenGL never reaches this slow code path
@@ -1194,6 +1208,13 @@ namespace
}
}
+bool OutputDevice::BlendBitmap(
+ const SalTwoRect& rPosAry,
+ const Bitmap& rBmp )
+{
+ return mpGraphics->BlendBitmap( rPosAry, *rBmp.ImplGetImpBitmap()->ImplGetSalBitmap(), this );
+}
+
Bitmap OutputDevice::BlendBitmapWithAlpha(
Bitmap& aBmp,
BitmapReadAccess* pP,