summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-09-05 17:31:01 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-09-06 10:09:01 +0200
commit966a51dfc63e2a783282dfd0379bf5c987b1e136 (patch)
tree8ace17f60c22eaef42c5a4bc56e46d61031bc29b /vcl/source/gdi
parent00df1cd5d663216cf59465d3c6c23dafd0de6f81 (diff)
Resolves: tdf#125461 32bit XImage is not premultiplied
regressions since... commit 86ea64f216819696cd86d1926aff0a138ace2baf Date: Fri Feb 15 13:14:32 2019 +0100 Support for native 32bit Bitmap in VCL and SVP (cairo) backend 32bit cairo data is premultiplied with alpha but not so 32bit XImages which don't have alpha at all, so restore the pre-change 32bit accessors, which effectively ignore their alpha channel, beside the post-change ones and toggle which one to use depending on the back end capability Change-Id: Ibfec18b4ddb6e93ab19e44e7127e7a16982e2f49 Reviewed-on: https://gerrit.libreoffice.org/78665 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/bmpacc.cxx85
-rw-r--r--vcl/source/gdi/bmpacc2.cxx84
2 files changed, 157 insertions, 12 deletions
diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx
index a03147696c7e..d2c46350ec55 100644
--- a/vcl/source/gdi/bmpacc.cxx
+++ b/vcl/source/gdi/bmpacc.cxx
@@ -110,6 +110,15 @@ BitmapReadAccess::~BitmapReadAccess()
{
}
+namespace
+{
+ bool Bitmap32IsPreMultipled()
+ {
+ auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
+ return pBackendCapabilities->mbSupportsBitmap32;
+ }
+}
+
bool BitmapReadAccess::ImplSetAccessPointers( ScanlineFormat nFormat )
{
bool bRet = true;
@@ -178,26 +187,58 @@ bool BitmapReadAccess::ImplSetAccessPointers( ScanlineFormat nFormat )
break;
case ScanlineFormat::N32BitTcAbgr:
{
- mFncGetPixel = GetPixelForN32BitTcAbgr;
- mFncSetPixel = SetPixelForN32BitTcAbgr;
+ if (Bitmap32IsPreMultipled())
+ {
+ mFncGetPixel = GetPixelForN32BitTcAbgr;
+ mFncSetPixel = SetPixelForN32BitTcAbgr;
+ }
+ else
+ {
+ mFncGetPixel = GetPixelForN32BitTcXbgr;
+ mFncSetPixel = SetPixelForN32BitTcXbgr;
+ }
}
break;
case ScanlineFormat::N32BitTcArgb:
{
- mFncGetPixel = GetPixelForN32BitTcArgb;
- mFncSetPixel = SetPixelForN32BitTcArgb;
+ if (Bitmap32IsPreMultipled())
+ {
+ mFncGetPixel = GetPixelForN32BitTcArgb;
+ mFncSetPixel = SetPixelForN32BitTcArgb;
+ }
+ else
+ {
+ mFncGetPixel = GetPixelForN32BitTcXrgb;
+ mFncSetPixel = SetPixelForN32BitTcXrgb;
+ }
}
break;
case ScanlineFormat::N32BitTcBgra:
{
- mFncGetPixel = GetPixelForN32BitTcBgra;
- mFncSetPixel = SetPixelForN32BitTcBgra;
+ if (Bitmap32IsPreMultipled())
+ {
+ mFncGetPixel = GetPixelForN32BitTcBgra;
+ mFncSetPixel = SetPixelForN32BitTcBgra;
+ }
+ else
+ {
+ mFncGetPixel = GetPixelForN32BitTcBgrx;
+ mFncSetPixel = SetPixelForN32BitTcBgrx;
+ }
}
break;
case ScanlineFormat::N32BitTcRgba:
{
- mFncGetPixel = GetPixelForN32BitTcRgba;
- mFncSetPixel = SetPixelForN32BitTcRgba;
+ if (Bitmap32IsPreMultipled())
+ {
+ mFncGetPixel = GetPixelForN32BitTcRgba;
+ mFncSetPixel = SetPixelForN32BitTcRgba;
+ }
+ else
+ {
+ mFncGetPixel = GetPixelForN32BitTcRgbx;
+ mFncSetPixel = SetPixelForN32BitTcRgbx;
+ }
}
break;
case ScanlineFormat::N32BitTcMask:
@@ -390,10 +431,30 @@ void BitmapWriteAccess::CopyScanline( long nY, ConstScanline aSrcScanline,
case ScanlineFormat::N16BitTcLsbMask: pFncGetPixel = GetPixelForN16BitTcLsbMask; break;
case ScanlineFormat::N24BitTcBgr: pFncGetPixel = GetPixelForN24BitTcBgr; break;
case ScanlineFormat::N24BitTcRgb: pFncGetPixel = GetPixelForN24BitTcRgb; break;
- case ScanlineFormat::N32BitTcAbgr: pFncGetPixel = GetPixelForN32BitTcAbgr; break;
- case ScanlineFormat::N32BitTcArgb: pFncGetPixel = GetPixelForN32BitTcArgb; break;
- case ScanlineFormat::N32BitTcBgra: pFncGetPixel = GetPixelForN32BitTcBgra; break;
- case ScanlineFormat::N32BitTcRgba: pFncGetPixel = GetPixelForN32BitTcRgba; break;
+ case ScanlineFormat::N32BitTcAbgr:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcAbgr;
+ else
+ pFncGetPixel = GetPixelForN32BitTcXbgr;
+ break;
+ case ScanlineFormat::N32BitTcArgb:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcArgb;
+ else
+ pFncGetPixel = GetPixelForN32BitTcXrgb;
+ break;
+ case ScanlineFormat::N32BitTcBgra:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcBgra;
+ else
+ pFncGetPixel = GetPixelForN32BitTcBgrx;
+ break;
+ case ScanlineFormat::N32BitTcRgba:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcRgba;
+ else
+ pFncGetPixel = GetPixelForN32BitTcRgbx;
+ break;
case ScanlineFormat::N32BitTcMask: pFncGetPixel = GetPixelForN32BitTcMask; break;
default:
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index 0c382d08db91..510cb04e04cc 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -195,6 +195,18 @@ BitmapColor BitmapReadAccess::GetPixelForN32BitTcAbgr(ConstScanline pScanline, l
0xFF - a);
}
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcXbgr(ConstScanline pScanline, long nX, const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + ( nX << 2 ) + 1;
+ aBitmapColor.SetBlue( *pScanline++ );
+ aBitmapColor.SetGreen( *pScanline++ );
+ aBitmapColor.SetRed( *pScanline );
+
+ return aBitmapColor;
+}
+
void BitmapReadAccess::SetPixelForN32BitTcAbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -206,6 +218,15 @@ void BitmapReadAccess::SetPixelForN32BitTcAbgr(Scanline pScanline, long nX, cons
*pScanline = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
}
+void BitmapReadAccess::SetPixelForN32BitTcXbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + ( nX << 2 );
+ *pScanline++ = 0xFF;
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetRed();
+}
+
BitmapColor BitmapReadAccess::GetPixelForN32BitTcArgb(ConstScanline pScanline, long nX, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -222,6 +243,18 @@ BitmapColor BitmapReadAccess::GetPixelForN32BitTcArgb(ConstScanline pScanline, l
0xFF - a);
}
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcXrgb(ConstScanline pScanline, long nX, const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + ( nX << 2 ) + 1;
+ aBitmapColor.SetRed( *pScanline++ );
+ aBitmapColor.SetGreen( *pScanline++ );
+ aBitmapColor.SetBlue( *pScanline );
+
+ return aBitmapColor;
+}
+
void BitmapReadAccess::SetPixelForN32BitTcArgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -233,6 +266,15 @@ void BitmapReadAccess::SetPixelForN32BitTcArgb(Scanline pScanline, long nX, cons
*pScanline = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
}
+void BitmapReadAccess::SetPixelForN32BitTcXrgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + ( nX << 2 );
+ *pScanline++ = 0xFF;
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetBlue();
+}
+
BitmapColor BitmapReadAccess::GetPixelForN32BitTcBgra(ConstScanline pScanline, long nX, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -249,6 +291,18 @@ BitmapColor BitmapReadAccess::GetPixelForN32BitTcBgra(ConstScanline pScanline, l
0xFF - a);
}
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcBgrx(ConstScanline pScanline, long nX, const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + ( nX << 2 );
+ aBitmapColor.SetBlue( *pScanline++ );
+ aBitmapColor.SetGreen( *pScanline++ );
+ aBitmapColor.SetRed( *pScanline );
+
+ return aBitmapColor;
+}
+
void BitmapReadAccess::SetPixelForN32BitTcBgra(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -260,6 +314,15 @@ void BitmapReadAccess::SetPixelForN32BitTcBgra(Scanline pScanline, long nX, cons
*pScanline = alpha;
}
+void BitmapReadAccess::SetPixelForN32BitTcBgrx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + ( nX << 2 );
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline = 0xFF;
+}
+
BitmapColor BitmapReadAccess::GetPixelForN32BitTcRgba(ConstScanline pScanline, long nX, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -276,6 +339,18 @@ BitmapColor BitmapReadAccess::GetPixelForN32BitTcRgba(ConstScanline pScanline, l
0xFF - a);
}
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcRgbx(ConstScanline pScanline, long nX, const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + ( nX << 2 );
+ aBitmapColor.SetRed( *pScanline++ );
+ aBitmapColor.SetGreen( *pScanline++ );
+ aBitmapColor.SetBlue( *pScanline );
+
+ return aBitmapColor;
+}
+
void BitmapReadAccess::SetPixelForN32BitTcRgba(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
{
pScanline = pScanline + nX * 4;
@@ -287,6 +362,15 @@ void BitmapReadAccess::SetPixelForN32BitTcRgba(Scanline pScanline, long nX, cons
*pScanline = alpha;
}
+void BitmapReadAccess::SetPixelForN32BitTcRgbx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + ( nX << 2 );
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline = 0xFF;
+}
+
BitmapColor BitmapReadAccess::GetPixelForN32BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask)
{
BitmapColor aColor;