[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 17 10:22:23 UTC 2019


 include/vcl/bitmapaccess.hxx             |    8 ++
 vcl/source/gdi/bmpacc.cxx                |   85 ++++++++++++++++++++++++++-----
 vcl/source/gdi/bmpacc2.cxx               |   84 ++++++++++++++++++++++++++++++
 vcl/unx/generic/print/genpspgraphics.cxx |   34 ++++++++++--
 4 files changed, 194 insertions(+), 17 deletions(-)

New commits:
commit 09470e24332f6216900419cc1e76421992ae6b73
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 5 17:31:01 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Sep 17 12:21:40 2019 +0200

    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/78666
    Tested-by: Jenkins
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/include/vcl/bitmapaccess.hxx b/include/vcl/bitmapaccess.hxx
index e1adbf10c4c1..ad478df19591 100644
--- a/include/vcl/bitmapaccess.hxx
+++ b/include/vcl/bitmapaccess.hxx
@@ -252,9 +252,13 @@ public:
     static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, long nX, const ColorMask& rMask);
+    static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, long nX, const ColorMask& rMask);
+    static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, long nX, const ColorMask& rMask);
+    static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, long nX, const ColorMask& rMask);
+    static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, long nX, const ColorMask& rMask);
     static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask);
 
     static void SetPixelForN1BitMsbPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
@@ -268,9 +272,13 @@ public:
     static void SetPixelForN24BitTcBgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN24BitTcRgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN32BitTcAbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
+    static void SetPixelForN32BitTcXbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN32BitTcArgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
+    static void SetPixelForN32BitTcXrgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN32BitTcBgra(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
+    static void SetPixelForN32BitTcBgrx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN32BitTcRgba(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
+    static void SetPixelForN32BitTcRgbx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
     static void SetPixelForN32BitTcMask(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
 
 };
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;
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index b62bd7f90e8f..0c2f9d91cffa 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -80,6 +80,15 @@ public:
     virtual sal_uInt32  GetDepth () const override;
 };
 
+namespace
+{
+    bool Bitmap32IsPreMultipled()
+    {
+        auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
+        return pBackendCapabilities->mbSupportsBitmap32;
+    }
+}
+
 SalPrinterBmp::SalPrinterBmp (BitmapBuffer* pBuffer)
     : mpBmpBuffer(pBuffer)
 {
@@ -122,16 +131,31 @@ SalPrinterBmp::SalPrinterBmp (BitmapBuffer* pBuffer)
         case ScanlineFormat::N24BitTcRgb:
             mpFncGetPixel = BitmapReadAccess::GetPixelForN24BitTcRgb;  break;
         case ScanlineFormat::N32BitTcAbgr:
-            mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcAbgr; break;
+            if (Bitmap32IsPreMultipled())
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcAbgr;
+            else
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcXbgr;
+            break;
         case ScanlineFormat::N32BitTcArgb:
-            mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcArgb; break;
+            if (Bitmap32IsPreMultipled())
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcArgb;
+            else
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcXrgb;
+            break;
         case ScanlineFormat::N32BitTcBgra:
-            mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcBgra; break;
+            if (Bitmap32IsPreMultipled())
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcBgra;
+            else
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcBgrx;
+            break;
         case ScanlineFormat::N32BitTcRgba:
-            mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcRgba; break;
+            if (Bitmap32IsPreMultipled())
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcRgba;
+            else
+                mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcRgbx;
+            break;
         case ScanlineFormat::N32BitTcMask:
             mpFncGetPixel = BitmapReadAccess::GetPixelForN32BitTcMask; break;
-
         default:
             OSL_FAIL("Error: SalPrinterBmp::SalPrinterBmp() unknown bitmap format");
             mpFncGetPixel = nullptr;


More information about the Libreoffice-commits mailing list